diff --git a/config/env/torrents.js b/config/env/torrents.js index 7683cf55..9599c0ba 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -245,6 +245,7 @@ module.exports = { AdminUpdateUserScore: {name: 'AdminUpdateUserScore', enable: true}, AdminUpdateUserUploaded: {name: 'AdminUpdateUserUploaded', enable: true}, AdminUpdateUserDownloaded: {name: 'AdminUpdateUserDownloaded', enable: true}, + AdminUpdateUserVIPData: {name: 'AdminUpdateUserVIPData', enable: true}, AdminUserDelete: {name: 'AdminUserDelete', enable: true}, AdminUserEdit: {name: 'AdminUserEdit', enable: true}, userPasswordReset: {name: 'userPasswordReset', enable: true}, diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 2e9da578..5f5a9f32 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -421,6 +421,8 @@ SET_STATUS_FAILED: 'set user status failed', SET_IMAGE_SUCCESSFULLY: 'set user image successfully', SET_IMAGE_FAILED: 'set user image failed', + SET_VIP_MONTHS_SUCCESSFULLY: 'update user vip data successfully', + SET_VIP_MONTHS_FAILED: 'update user vip data failed', SCORE_NUMBER: 'Score number', SCORE_TITLE: 'Edit user score', @@ -490,6 +492,7 @@ STATUS_FIELD: { PICTURE: 'Profile picture', RESET_DEFAULT_PICTURE: 'Reset to default picture', + ADD_VIP_MONTHS: '+ VIP a month', USERNAME: 'Username', FIRST_NAME: 'First name', LAST_NAME: 'Last name', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index a4457782..6a9d4779 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -421,6 +421,8 @@ SET_STATUS_FAILED: '用户帐号状态设置失败', SET_IMAGE_SUCCESSFULLY: '用户帐号图片修改成功', SET_IMAGE_FAILED: '用户帐号图片修改失败', + SET_VIP_MONTHS_SUCCESSFULLY: '更新用户vip状态数据成功', + SET_VIP_MONTHS_FAILED: '更新用户vip状态数据失败', SCORE_NUMBER: '积分数', SCORE_TITLE: '修改积分', @@ -490,6 +492,7 @@ STATUS_FIELD: { PICTURE: '头像', RESET_DEFAULT_PICTURE: '重置为默认图片', + ADD_VIP_MONTHS: '+ VIP一个月', USERNAME: '用户名', FIRST_NAME: '姓', LAST_NAME: '名', diff --git a/modules/users/client/controllers/admin/user.client.controller.js b/modules/users/client/controllers/admin/user.client.controller.js index f9aba59a..be98df9d 100644 --- a/modules/users/client/controllers/admin/user.client.controller.js +++ b/modules/users/client/controllers/admin/user.client.controller.js @@ -113,19 +113,42 @@ AdminService.resetUserProfileImage({ userId: user._id }) - .then(onSetRoleSuccess) - .catch(onSetRoleError); + .then(onSuccess) + .catch(onError); - function onSetRoleSuccess(response) { + function onSuccess(response) { vm.user = response; NotifycationService.showSuccessNotify('SET_IMAGE_SUCCESSFULLY'); } - function onSetRoleError(response) { + function onError(response) { NotifycationService.showErrorNotify(response.data.message, 'SET_IMAGE_FAILED'); } + }; + /** + * addVIPMonths + */ + vm.addVIPMonths = function () { + var user = vm.user; + AdminService.addVIPMonths({ + userId: user._id, + months: 1 + }) + .then(onSuccess) + .catch(onError); + + function onSuccess(response) { + vm.user = response; + mtDebug.info(response); + + NotifycationService.showSuccessNotify('SET_VIP_MONTHS_SUCCESSFULLY'); + } + + function onError(response) { + NotifycationService.showErrorNotify(response.data.message, 'SET_VIP_MONTHS_FAILED'); + } }; /** @@ -138,16 +161,16 @@ userId: user._id, userRole: [vm.selectedRole] }) - .then(onSetRoleSuccess) - .catch(onSetRoleError); + .then(onSuccess) + .catch(onError); - function onSetRoleSuccess(response) { + function onSuccess(response) { vm.user = response; NotifycationService.showSuccessNotify('SET_ROLE_SUCCESSFULLY'); } - function onSetRoleError(response) { + function onError(response) { NotifycationService.showErrorNotify(response.data.message, 'SET_ROLE_FAILED'); } }; @@ -161,16 +184,16 @@ userId: user._id, userStatus: user.status === 'banned' ? 'normal' : 'banned' }) - .then(onSetRoleSuccess) - .catch(onSetRoleError); + .then(onSuccess) + .catch(onError); - function onSetRoleSuccess(response) { + function onSuccess(response) { vm.user = response; NotifycationService.showSuccessNotify('SET_STATUS_SUCCESSFULLY'); } - function onSetRoleError(response) { + function onError(response) { NotifycationService.showErrorNotify(response.data.message, 'SET_STATUS_FAILED'); } }; @@ -187,13 +210,13 @@ userId: user._id, userScore: vm.setUserScorePopover.number }) - .then(onSetScoreSuccess) - .catch(onSetScoreError); + .then(onSuccess) + .catch(onError); vm.setUserScorePopover.isOpen = false; } - function onSetScoreSuccess(response) { + function onSuccess(response) { vm.user = response; mtDebug.info(vm.scoreLevelData); vm.scoreLevelData = ScoreLevelService.getScoreLevelJson(vm.user.score); @@ -202,7 +225,7 @@ NotifycationService.showSuccessNotify('SET_SCORE_SUCCESSFULLY'); } - function onSetScoreError(response) { + function onError(response) { NotifycationService.showErrorNotify(response.data.message, 'SET_SCORE_FAILED'); } }; @@ -219,19 +242,19 @@ userId: user._id, userUploaded: vm.setUserUploadedPopover.number * 1024 * 1024 * 1024 }) - .then(onSetUploadedSuccess) - .catch(onSetUploadedError); + .then(onSuccess) + .catch(onError); vm.setUserUploadedPopover.isOpen = false; } - function onSetUploadedSuccess(response) { + function onSuccess(response) { vm.user = response; NotifycationService.showSuccessNotify('SET_UPLOADED_SUCCESSFULLY'); } - function onSetUploadedError(response) { + function onError(response) { NotifycationService.showErrorNotify(response.data.message, 'SET_UPLOADED_FAILED'); } }; @@ -248,19 +271,19 @@ userId: user._id, userDownloaded: vm.setUserDownloadedPopover.number * 1024 * 1024 * 1024 }) - .then(onSetDownloadedSuccess) - .catch(onSetDownloadedError); + .then(onSuccess) + .catch(onError); vm.setUserDownloadedPopover.isOpen = false; } - function onSetDownloadedSuccess(response) { + function onSuccess(response) { vm.user = response; NotifycationService.showSuccessNotify('SET_DOWNLOADED_SUCCESSFULLY'); } - function onSetDownloadedError(response) { + function onError(response) { NotifycationService.showErrorNotify(response.data.message, 'SET_DOWNLOADED_FAILED'); } }; diff --git a/modules/users/client/services/users.client.service.js b/modules/users/client/services/users.client.service.js index b3dd51c0..479dbda7 100644 --- a/modules/users/client/services/users.client.service.js +++ b/modules/users/client/services/users.client.service.js @@ -151,6 +151,14 @@ params: { userId: '@userId' } + }, + updateUserVIPMonths: { + method: 'PUT', + url: '/api/users/:userId/VIPMonths/:months', + params: { + userId: '@userId', + months: '@months' + } } }); @@ -175,6 +183,9 @@ }, resetUserProfileImage: function (params) { return this.setDefaultProfileImage(params).$promise; + }, + addVIPMonths: function (params) { + return this.updateUserVIPMonths(params).$promise; } }); diff --git a/modules/users/client/views/admin/view-user.client.view.html b/modules/users/client/views/admin/view-user.client.view.html index cf5155fe..9aea5f04 100644 --- a/modules/users/client/views/admin/view-user.client.view.html +++ b/modules/users/client/views/admin/view-user.client.view.html @@ -43,6 +43,9 @@