499 lines
13 KiB
JavaScript
499 lines
13 KiB
JavaScript
'use strict';
|
|
var app = angular.module('chat12306', ['ngCookies']);
|
|
|
|
(function filters() {
|
|
app.filter('range', function () {
|
|
return function (input, total) {
|
|
total = parseInt(total);
|
|
for (var i = 0; i < total; i++)
|
|
input.push(i);
|
|
return input;
|
|
};
|
|
});
|
|
app.filter('jsonDate', function () {
|
|
return function (input) {
|
|
var data = /^(\d{4}-\d{2}-\d{2})T([\d\:]+)/i.exec(input || "");
|
|
return data && String.format("{0} {1}", data[1], data[2]) || input;
|
|
};
|
|
});
|
|
app.filter('abuseStatusDesc', function () {
|
|
return function (input) {
|
|
return ["未处理", "已处理", "已忽略", "已自动处理"][parseInt(input)];
|
|
};
|
|
});
|
|
app.filter('pagelist', function () {
|
|
return function (current, max, pagePerSide) {
|
|
max = parseInt(max);
|
|
current = parseInt(current);
|
|
pagePerSide = parseInt(pagePerSide) || 4;
|
|
|
|
var result = [];
|
|
for (var i = 1; i <= pagePerSide + 1 && i <= max; i++) {
|
|
result.push(i);
|
|
}
|
|
if (current - pagePerSide > pagePerSide + 1 + 1) {
|
|
result.push(-1);
|
|
}
|
|
for (var j = current - pagePerSide; j <= current + pagePerSide; j++) {
|
|
if (j <= pagePerSide + 1 || j > max - pagePerSide + 1)
|
|
continue;
|
|
result.push(j);
|
|
}
|
|
if (max - pagePerSide > current + pagePerSide + 1)
|
|
result.push(-2);
|
|
for (var k = max - pagePerSide; k >= 1 && k <= max; k++) {
|
|
result.push(k);
|
|
}
|
|
|
|
return result;
|
|
};
|
|
});
|
|
})();
|
|
(function () {
|
|
app.controller('AccountLogin', accountLoginController);
|
|
accountLoginController.$inject = ['$scope', '$cookies', '$cookieStore', '$http', '$location'];
|
|
|
|
function accountLoginController($scope, $cookies, $cookieStore, $http, $location) {
|
|
$scope.operating = false;
|
|
$scope.user = {
|
|
password: ""
|
|
};
|
|
|
|
$scope.login = function () {
|
|
var notify = $.notify({
|
|
title: "登录中...",
|
|
message: "正在登录中,请稍等...",
|
|
"icon": "fa-spin fa fa-spinner"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$scope.operating = true;
|
|
|
|
$http.post("/api/account/login", $scope.user)
|
|
.success(function (data) {
|
|
if (data.success) {
|
|
notify.update({
|
|
"message": "登录成功!",
|
|
icon: "fa fa-check",
|
|
type: "success",
|
|
showProgressbar: false
|
|
});
|
|
setTimeout(function () {
|
|
self.location = "/";
|
|
}, 2000);
|
|
} else {
|
|
notify.update({
|
|
"message": "登录失败:" + data.message,
|
|
icon: "fa fa-ban",
|
|
type: "danger",
|
|
showProgressbar: false
|
|
});
|
|
setTimeout(notify.close, 2000);
|
|
}
|
|
$scope.operating = false;
|
|
}).error(function () {
|
|
notify.update({
|
|
"message": "登录失败,请重试。服务器错误啦....",
|
|
type: "danger",
|
|
icon: "fa fa-ban",
|
|
showProgressbar: false,
|
|
placement: ""
|
|
});
|
|
setTimeout(notify.close, 2000);
|
|
$scope.operating = false;
|
|
});
|
|
};
|
|
|
|
}
|
|
})();
|
|
|
|
(function abuseListControllerContainer() {
|
|
app.controller("AbuseListController", abuseListController);
|
|
|
|
function abuseListController($scope, $http) {
|
|
abuseListController.$inject = ['$scope', '$http'];
|
|
|
|
var controlApi = "/api/users/updateAbuseReport";
|
|
|
|
$scope.filters = [{ typeid: -1, title: "所有" }, { typeid: 0, title: "未处理" }, { typeid: 1, title: "已处理" }, { typeid: 2, title: "已忽略" }, { typeid: 3, title: "已自动处理" }];
|
|
$scope.filterid = -1;
|
|
$scope.items = [{ title: "test" }];
|
|
$scope.pages = 0;
|
|
$scope.pageSize = 50;
|
|
$scope.itemsCount = 0;
|
|
$scope.pageIndex = 1;
|
|
|
|
$scope.ignore = function (index) {
|
|
|
|
};
|
|
$scope.blockTarget = function (code) {
|
|
|
|
};
|
|
$scope.blockSource = function (code) {
|
|
|
|
};
|
|
|
|
var load = function () {
|
|
var notify = $.notify({
|
|
title: "正在加载数据,请稍等...",
|
|
message: "",
|
|
"icon": "fa-spin fa fa-spinner",
|
|
type: "info"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$http.post("/api/users/abuseList", { pageSize: $scope.pageSize, pageIndex: $scope.pageIndex, filter: $scope.filterid })
|
|
.success(function (data) {
|
|
notify.update({
|
|
"title": "加载成功...",
|
|
type: "success",
|
|
icon: "fa fa-check",
|
|
showProgressbar: false
|
|
});
|
|
notify.close();
|
|
|
|
$scope.items = data.items;
|
|
$scope.itemsCount = data.itemsCount || 0;
|
|
$scope.pages = Math.ceil($scope.itemsCount / $scope.pageSize);
|
|
}).error(function () {
|
|
notify.update({
|
|
"title": "加载失败,请重试。服务器错误啦....",
|
|
type: "danger",
|
|
icon: "fa fa-ban",
|
|
showProgressbar: false
|
|
});
|
|
setTimeout(notify.close, 2000);
|
|
$scope.items = [];
|
|
});
|
|
|
|
setTimeout(notify.close, 2000);
|
|
};
|
|
|
|
//重设过滤器
|
|
$scope.resetFilter = function (id) {
|
|
$scope.filterid = id;
|
|
};
|
|
$scope.goPage = function (page) {
|
|
if (page <= 0)
|
|
return;
|
|
$scope.pageIndex = page;
|
|
};
|
|
$scope.go = function (pageOffset) {
|
|
$scope.pageIndex = Math.max(1, Math.min($scope.pageIndex + pageOffset, $scope.pages));
|
|
};
|
|
$scope.reload = function () {
|
|
load();
|
|
};
|
|
|
|
//操作
|
|
$scope.op = function (index, status) {
|
|
var item = $scope.items[index];
|
|
if (!confirm("确认操作?"))
|
|
return;
|
|
|
|
var notify = $.notify({
|
|
title: "操作中,请稍等...",
|
|
"icon": "fa-spin fa fa-spinner",
|
|
type: "info"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$http.post(controlApi, { id: item.id, status: status, bantime: item.bantime || "0" })
|
|
.success(function (data) {
|
|
if (data.success) {
|
|
notify.update({
|
|
"title": "操作成功...",
|
|
type: "success",
|
|
icon: "fa fa-check",
|
|
showProgressbar: false
|
|
});
|
|
} else {
|
|
notify.changeStatus("danger", "fa fa-ban", "操作失败:" + data.message, null, -2);
|
|
}
|
|
setTimeout(notify.close, 2000);
|
|
|
|
$("tr[data-id=" + item.id + "] button.btn").remove();
|
|
}).error(function () {
|
|
notify.setTitle("操作失败,请重试。服务器错误啦....").setType("danger").setIcon("fa fa-ban").hideProgress().delayClose();
|
|
});
|
|
|
|
};
|
|
|
|
$scope.$watch("filterid+pageIndex", function () {
|
|
load();
|
|
});
|
|
}
|
|
})();
|
|
(function chatMessageListControllerContainer() {
|
|
function chatMessageListController($scope, $http) {
|
|
var listApi = "/api/msgs/list";
|
|
|
|
$scope.filter = {
|
|
searchUser: "",
|
|
pageIndex: 1,
|
|
pagesize: "20"
|
|
};
|
|
$scope.pages = 0;
|
|
$scope.itemsCount = 0;
|
|
$scope.items = [];
|
|
|
|
//加载
|
|
$scope.reload = function () {
|
|
var notify = $.notify({
|
|
title: "数据加载中...",
|
|
"icon": "fa-spin fa fa-spinner",
|
|
type: "info"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$http.post(listApi, $scope.filter)
|
|
.success(function (data) {
|
|
notify.update({
|
|
"title": "加载成功...",
|
|
type: "success",
|
|
icon: "fa fa-check",
|
|
showProgressbar: false
|
|
});
|
|
$scope.items = data.list;
|
|
$scope.itemsCount = data.count;
|
|
$scope.pages = Math.ceil($scope.itemsCount / parseInt($scope.filter.pagesize, 10));
|
|
setTimeout(notify.close, 2000);
|
|
}).error(function () {
|
|
notify.setTitle("加载失败,请重试。服务器错误啦....").setType("danger").setIcon("fa fa-ban").hideProgress().delayClose();
|
|
});
|
|
};
|
|
$scope.goPage = function (page) {
|
|
if (page <= 0)
|
|
return;
|
|
$scope.filter.pageIndex = page;
|
|
};
|
|
$scope.go = function (pageOffset) {
|
|
$scope.filter.pageIndex = Math.max(1, Math.min($scope.filter.pageIndex + pageOffset, $scope.pages));
|
|
};
|
|
|
|
|
|
$scope.$watch("filter", function (newvalue, oldvalue) {
|
|
$scope.reload();
|
|
}, true);
|
|
}
|
|
|
|
app.controller("ChatMessageListController", ['$scope', '$http', chatMessageListController]);
|
|
})();
|
|
(function ConnectionLogControllerContainer() {
|
|
function connectionLogController($scope, $http) {
|
|
var listApi = "/api/users/connectionlog";
|
|
|
|
$scope.filter = {
|
|
searchUser: "",
|
|
pageIndex: 1,
|
|
pagesize: "20"
|
|
};
|
|
$scope.pages = 0;
|
|
$scope.itemsCount = 0;
|
|
$scope.items = [];
|
|
|
|
//加载
|
|
$scope.reload = function () {
|
|
var notify = $.notify({
|
|
title: "数据加载中...",
|
|
"icon": "fa-spin fa fa-spinner",
|
|
type: "info"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$http.post(listApi, $scope.filter)
|
|
.success(function (data) {
|
|
notify.update({
|
|
"title": "加载成功...",
|
|
type: "success",
|
|
icon: "fa fa-check",
|
|
showProgressbar: false
|
|
});
|
|
$scope.items = data.list;
|
|
$scope.itemsCount = data.count;
|
|
$scope.pages = Math.ceil($scope.itemsCount / parseInt($scope.filter.pagesize, 10));
|
|
setTimeout(notify.close, 2000);
|
|
}).error(function () {
|
|
notify.setTitle("加载失败,请重试。服务器错误啦....").setType("danger").setIcon("fa fa-ban").hideProgress().delayClose();
|
|
});
|
|
};
|
|
$scope.goPage = function (page) {
|
|
if (page <= 0)
|
|
return;
|
|
$scope.filter.pageIndex = page;
|
|
};
|
|
$scope.go = function (pageOffset) {
|
|
$scope.filter.pageIndex = Math.max(1, Math.min($scope.filter.pageIndex + pageOffset, $scope.pages));
|
|
};
|
|
|
|
|
|
$scope.$watch("filter", function (newvalue, oldvalue) {
|
|
$scope.reload();
|
|
}, true);
|
|
}
|
|
|
|
app.controller("ConnectionLogController", ['$scope', '$http', connectionLogController]);
|
|
})();
|
|
//-------------------------------------------------------------
|
|
(function blockUserListControllerContainer() {
|
|
function blockUserListController($scope, $http) {
|
|
var listApi = "/api/users/blockList";
|
|
|
|
$scope.filter = {
|
|
searchUser: "",
|
|
pageIndex: 1,
|
|
pagesize: "20"
|
|
};
|
|
$scope.pages = 0;
|
|
$scope.itemsCount = 0;
|
|
$scope.items = [];
|
|
|
|
//加载
|
|
$scope.reload = function () {
|
|
var notify = $.notify({
|
|
title: "数据加载中...",
|
|
"icon": "fa-spin fa fa-spinner",
|
|
type: "info"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$http.post(listApi, $scope.filter)
|
|
.success(function (data) {
|
|
notify.update({
|
|
"title": "加载成功...",
|
|
type: "success",
|
|
icon: "fa fa-check",
|
|
showProgressbar: false
|
|
});
|
|
$scope.items = data.list;
|
|
$scope.itemsCount = data.count;
|
|
$scope.pages = Math.ceil($scope.itemsCount / parseInt($scope.filter.pagesize, 10));
|
|
setTimeout(notify.close, 2000);
|
|
}).error(function () {
|
|
notify.setTitle("加载失败,请重试。服务器错误啦....").setType("danger").setIcon("fa fa-ban").hideProgress().delayClose();
|
|
});
|
|
};
|
|
$scope.goPage = function (page) {
|
|
if (page <= 0)
|
|
return;
|
|
$scope.filter.pageIndex = page;
|
|
};
|
|
$scope.go = function (pageOffset) {
|
|
$scope.filter.pageIndex = Math.max(1, Math.min($scope.filter.pageIndex + pageOffset, $scope.pages));
|
|
};
|
|
|
|
|
|
$scope.$watch("filter", function (newvalue, oldvalue) {
|
|
$scope.reload();
|
|
}, true);
|
|
}
|
|
|
|
app.controller("BlockUserListController", ['$scope', '$http', blockUserListController]);
|
|
})();
|
|
//-------------------------------------------------------------
|
|
(function userListControllerContainer() {
|
|
function userListController($scope, $http) {
|
|
var listApi = "/api/users/list";
|
|
|
|
$scope.filter = {
|
|
user: "",
|
|
pageIndex: 1,
|
|
pagesize: "20"
|
|
};
|
|
$scope.pages = 0;
|
|
$scope.itemsCount = 0;
|
|
$scope.items = [];
|
|
|
|
//加载
|
|
$scope.reload = function () {
|
|
var notify = $.notify({
|
|
title: "数据加载中...",
|
|
"icon": "fa-spin fa fa-spinner",
|
|
type: "info"
|
|
}, {
|
|
delay: 0,
|
|
progress: -1,
|
|
showProgressbar: true,
|
|
allow_dismiss: false,
|
|
placement: {
|
|
from: "top",
|
|
align: "center"
|
|
}
|
|
});
|
|
$http.get(listApi, {
|
|
params: $scope.filter
|
|
})
|
|
.success(function (data) {
|
|
notify.update({
|
|
"title": "加载成功...",
|
|
type: "success",
|
|
icon: "fa fa-check",
|
|
showProgressbar: false
|
|
});
|
|
$scope.items = data.list;
|
|
$scope.itemsCount = data.count;
|
|
$scope.pages = Math.ceil($scope.itemsCount / parseInt($scope.filter.pagesize, 10));
|
|
setTimeout(notify.close, 2000);
|
|
}).error(function () {
|
|
notify.setTitle("加载失败,请重试。服务器错误啦....").setType("danger").setIcon("fa fa-ban").hideProgress().delayClose();
|
|
});
|
|
};
|
|
$scope.goPage = function (page) {
|
|
if (page <= 0)
|
|
return;
|
|
$scope.filter.pageIndex = page;
|
|
};
|
|
$scope.go = function (pageOffset) {
|
|
$scope.filter.pageIndex = Math.max(1, Math.min($scope.filter.pageIndex + pageOffset, $scope.pages));
|
|
};
|
|
|
|
|
|
$scope.$watch("filter", function (newvalue, oldvalue) {
|
|
$scope.reload();
|
|
}, true);
|
|
}
|
|
|
|
app.controller("UserListController", ['$scope', '$http', userListController]);
|
|
})(); |