From 23852f774098705fe7c43f5e64dd92a4f2381733 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Tue, 5 Dec 2017 15:47:17 +0800 Subject: [PATCH] feat(invitations): oper/admin can delete All Expired Official Invitation #20 --- modules/core/client/app/trans-string-en.js | 10 +++++-- modules/core/client/app/trans-string-zh.js | 10 +++++-- .../admin-invitations.client.controller.js | 28 +++++++++++++++++-- .../services/invitations.client.service.js | 4 +++ .../views/admin/official.client.view.html | 7 +++-- .../invitations.server.controller.js | 24 ++++++++++++++++ .../policies/invitations.server.policy.js | 3 +- .../routes/invitations.server.routes.js | 3 ++ .../status/status.client.controller.js | 8 +++--- modules/vip/client/views/vip.client.view.html | 2 +- 10 files changed, 85 insertions(+), 14 deletions(-) diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index f0b1fff1..5e1558f7 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -767,6 +767,7 @@ }, GET_INVITATIONS_ERROR: 'Get invitations failed', BUTTON_INVITE: 'Send', + BUTTON_DELETE_EXPIRED: 'Delete All Expired Official Invitation', BUTTON_SEARCH: 'Search', INPUT_EMAIL: 'email', SEND_INVITE_SUCCESSFULLY: 'Send invitation successfully', @@ -774,10 +775,15 @@ INVALID_INVITATION_TIP: 'Invalid invitation, maybe the invitation is expired.', INVITATION_IS_EMPTY: 'There are no invitations available!', INVITATION_USED_IS_EMPTY: 'There are no used invitations!', - - ADMIN_SEND_OFFICIAL_INVITATION: 'Send official invitation', + ADMIN_SEND_OFFICIAL_INVITATION: 'Official invitation', ADMIN_INVITATION_SUCCESSFULLY: 'Send official invitation successfully', ADMIN_INVITATION_ERROR: 'Send official invitation failed', + DELETE_EXPIRED_CONFIRM_OK: 'Delete', + DELETE_EXPIRED_CONFIRM_CANCEL: 'Cancel', + DELETE_EXPIRED_CONFIRM_HEADER_TEXT: 'Delete Confirm', + DELETE_EXPIRED_CONFIRM_BODY_TEXT: 'Are you sure want to delete all the expired official invitations?', + DELETE_EXPIRED_SUCCESSFULLY: 'Delete all the expired official invitations successfully', + DELETE_EXPIRED_ERROR: 'Delete all the expired official invitations failed', //user message box MESSAGES_BOX: 'Messages Box', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 30d8a384..142d422d 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -767,6 +767,7 @@ }, GET_INVITATIONS_ERROR: '获取邀请列表失败', BUTTON_INVITE: '发送', + BUTTON_DELETE_EXPIRED: '删除所有已过期的官方邀请', BUTTON_SEARCH: '搜索', INPUT_EMAIL: '邮箱地址', SEND_INVITE_SUCCESSFULLY: '发送邀请成功', @@ -774,10 +775,15 @@ INVALID_INVITATION_TIP: '无效的邀请, 该邀请可能已过期.', INVITATION_IS_EMPTY: '没有可用的邀请函!', INVITATION_USED_IS_EMPTY: '没有发送过的邀请!', - - ADMIN_SEND_OFFICIAL_INVITATION: '发送官方邀请函', + ADMIN_SEND_OFFICIAL_INVITATION: '官方邀请函', ADMIN_INVITATION_SUCCESSFULLY: '官方邀请函发送成功', ADMIN_INVITATION_ERROR: '官方邀请函发送失败', + DELETE_EXPIRED_CONFIRM_OK: '删除', + DELETE_EXPIRED_CONFIRM_CANCEL: '取消', + DELETE_EXPIRED_CONFIRM_HEADER_TEXT: '删除确认', + DELETE_EXPIRED_CONFIRM_BODY_TEXT: '您确定要删除所有已过期的官方邀请吗?', + DELETE_EXPIRED_SUCCESSFULLY: '删除过期官方邀请成功', + DELETE_EXPIRED_ERROR: '删除过期官方邀请失败', //user message box MESSAGES_BOX: '站内消息', diff --git a/modules/invitations/client/controllers/admin-invitations.client.controller.js b/modules/invitations/client/controllers/admin-invitations.client.controller.js index 767ac0b5..d347896b 100644 --- a/modules/invitations/client/controllers/admin-invitations.client.controller.js +++ b/modules/invitations/client/controllers/admin-invitations.client.controller.js @@ -6,10 +6,10 @@ .controller('AdminInvitationController', AdminInvitationController); AdminInvitationController.$inject = ['$scope', '$state', 'Authentication', 'InvitationsService', 'NotifycationService', 'DebugConsoleService', '$translate', - 'MeanTorrentConfig', '$filter', '$timeout']; + 'MeanTorrentConfig', '$filter', '$timeout', 'ModalConfirmService']; function AdminInvitationController($scope, $state, Authentication, InvitationsService, NotifycationService, mtDebug, $translate, - MeanTorrentConfig, $filter, $timeout) { + MeanTorrentConfig, $filter, $timeout, ModalConfirmService) { var vm = this; vm.user = Authentication.user; vm.announce = MeanTorrentConfig.meanTorrentConfig.announce; @@ -106,5 +106,29 @@ } } }; + + /** + * deleteExpiredOfficialInvitation + */ + vm.deleteExpiredOfficialInvitation = function () { + var modalOptions = { + closeButtonText: $translate.instant('DELETE_EXPIRED_CONFIRM_CANCEL'), + actionButtonText: $translate.instant('DELETE_EXPIRED_CONFIRM_OK'), + headerText: $translate.instant('DELETE_EXPIRED_CONFIRM_HEADER_TEXT'), + bodyText: $translate.instant('DELETE_EXPIRED_CONFIRM_BODY_TEXT') + }; + + ModalConfirmService.showModal({}, modalOptions) + .then(function (result) { + InvitationsService.deleteExpiredOfficialInvitation(function (response) { + NotifycationService.showSuccessNotify('DELETE_EXPIRED_SUCCESSFULLY'); + $timeout(function () { + $state.reload(); + }, 100); + }, function (response) { + NotifycationService.showErrorNotify(response.data.message, 'DELETE_EXPIRED_ERROR'); + }); + }); + }; } }()); diff --git a/modules/invitations/client/services/invitations.client.service.js b/modules/invitations/client/services/invitations.client.service.js index dab39186..04e6d012 100644 --- a/modules/invitations/client/services/invitations.client.service.js +++ b/modules/invitations/client/services/invitations.client.service.js @@ -33,6 +33,10 @@ method: 'GET', url: '/api/invitations/official/list', isArray: true + }, + deleteExpiredOfficialInvitation: { + method: 'DELETE', + url: '/api/invitations/official/deleteExpired' } }); } diff --git a/modules/invitations/client/views/admin/official.client.view.html b/modules/invitations/client/views/admin/official.client.view.html index 32364b14..806e2d16 100644 --- a/modules/invitations/client/views/admin/official.client.view.html +++ b/modules/invitations/client/views/admin/official.client.view.html @@ -1,8 +1,8 @@
-