feat(users): add ban reason when admin banned a user

This commit is contained in:
OldHawk
2018-06-09 21:37:10 +08:00
parent a314a1e4bf
commit 0402626c23
10 changed files with 112 additions and 32 deletions

View File

@@ -7,11 +7,11 @@
UserController.$inject = ['$scope', '$state', '$window', 'Authentication', 'userResolve', 'Notification', 'NotifycationService', 'MeanTorrentConfig',
'AdminService', 'ScoreLevelService', 'DebugConsoleService', 'TorrentGetInfoServices', 'SideOverlay', 'MakerGroupService', '$filter', '$translate',
'marked'];
'marked', 'ModalConfirmService'];
function UserController($scope, $state, $window, Authentication, user, Notification, NotifycationService, MeanTorrentConfig,
AdminService, ScoreLevelService, mtDebug, TorrentGetInfoServices, SideOverlay, MakerGroupService, $filter, $translate,
marked) {
marked, ModalConfirmService) {
var vm = this;
vm.TGI = TorrentGetInfoServices;
vm.authentication = Authentication;
@@ -326,12 +326,47 @@
*/
vm.onUserStatusChanged = function () {
var user = vm.user;
AdminService.setUserStatus({
userId: user._id,
userStatus: vm.selectedStatus
})
.then(onSuccess)
.catch(onError);
if (vm.selectedStatus === 'banned') {
var modalOptions = {
closeButtonText: $translate.instant('BANNED.CONFIRM_CANCEL'),
actionButtonText: $translate.instant('BANNED.CONFIRM_OK'),
headerText: $translate.instant('BANNED.CONFIRM_HEADER_TEXT'),
bodyText: $translate.instant('BANNED.CONFIRM_BODY_TEXT', {uname: user.displayName}),
selectOptions: {
enable: true,
title: 'BANNED.REASON_TITLE',
options: [
'BANNED.REASON_ILLEGAL_SIGN_IN',
'BANNED.REASON_ACCOUNT_TRADE',
'BANNED.REASON_EXAMINATION_NOT_FINISHED',
'BANNED.REASON_VIOLATED_RULES'
]
}
};
ModalConfirmService.showModal({}, modalOptions)
.then(function (result) {
var reason = result.reason;
if (reason === 'CUSTOM') reason = result.custom;
AdminService.setUserStatus({
userId: user._id,
userStatus: vm.selectedStatus,
banReason: reason
})
.then(onSuccess)
.catch(onError);
});
} else {
AdminService.setUserStatus({
userId: user._id,
userStatus: vm.selectedStatus,
banReason: ''
})
.then(onSuccess)
.catch(onError);
}
function onSuccess(response) {
vm.user = response;

View File

@@ -193,7 +193,7 @@
}
function onUserSigninError(response) {
NotifycationService.showErrorNotify(response.data.message, 'SIGN.SIGNIN_ERROR');
NotifycationService.showErrorNotify(response.data.message, 'SIGN.SIGNIN_ERROR', {reason: $translate.instant(response.data.reason)});
}
}

View File

@@ -251,7 +251,8 @@
url: '/api/users/:userId/status',
params: {
userId: '@userId',
userStatus: '@userStatus'
userStatus: '@userStatus',
banReason: '@banReason'
},
interceptor: {response: removeCache}
},