mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-07 16:51:34 +02:00
feat(invitations): oper/admin can delete All Expired Official Invitation
#20
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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: '站内消息',
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
method: 'GET',
|
||||
url: '/api/invitations/official/list',
|
||||
isArray: true
|
||||
},
|
||||
deleteExpiredOfficialInvitation: {
|
||||
method: 'DELETE',
|
||||
url: '/api/invitations/official/deleteExpired'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<section class="container" ng-controller="AdminInvitationController as vm" ng-init="vm.getOfficialInvitations();">
|
||||
<div class="margin-top-50 alert alert-success" role="alert">
|
||||
<div class="margin-top-20 alert alert-success" role="alert">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="margin-bottom-20">
|
||||
<div class="margin-top-20 margin-bottom-20">
|
||||
<h4>{{'ADMIN_SEND_OFFICIAL_INVITATION' | translate}}</h4>
|
||||
<li class="status-divider"></li>
|
||||
</div>
|
||||
@@ -21,6 +21,9 @@
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="margin-bottom-20 text-center">
|
||||
<a href="#" ng-click="vm.deleteExpiredOfficialInvitation();">{{ 'BUTTON_DELETE_EXPIRED' | translate }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -100,6 +100,30 @@ exports.listOfficial = function (req, res) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* deleteExpiredOfficialInvitation
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.deleteExpiredOfficialInvitation = function (req, res) {
|
||||
Invitation.remove({
|
||||
isOfficial: true,
|
||||
status: 1,
|
||||
expiresat: {$lt: Date.now()}
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
res.json({
|
||||
message: 'SERVER.DELETE_EXPIRED_OFFICIAL_INVITATION_OK'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* List of Invitations
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,8 @@ exports.invokeRolesPolicies = function () {
|
||||
roles: ['admin', 'oper'],
|
||||
allows: [
|
||||
{resources: '/api/invitations/official/send', permissions: ['post']},
|
||||
{resources: '/api/invitations/official/list', permissions: ['get']}
|
||||
{resources: '/api/invitations/official/list', permissions: ['get']},
|
||||
{resources: '/api/invitations/official/deleteExpired', permissions: ['delete']}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -23,6 +23,9 @@ module.exports = function (app) {
|
||||
app.route('/api/invitations/official/list').all(invitationsPolicy.isAllowed)
|
||||
.get(invitations.listOfficial);
|
||||
|
||||
app.route('/api/invitations/official/deleteExpired').all(invitationsPolicy.isAllowed)
|
||||
.delete(invitations.deleteExpiredOfficialInvitation);
|
||||
|
||||
app.route('/api/invitations/:invitationId').all(invitationsPolicy.isAllowed)
|
||||
.put(invitations.update)
|
||||
.delete(invitations.delete);
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
ModalConfirmService.showModal({}, modalOptions)
|
||||
.then(function (result) {
|
||||
UsersService.userUnIdle()
|
||||
.then(onChangePasswordSuccess)
|
||||
.catch(onChangePasswordError);
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
|
||||
function onChangePasswordSuccess(response) {
|
||||
function onSuccess(response) {
|
||||
vm.user = Authentication.user = response;
|
||||
|
||||
NotifycationService.showSuccessNotify('ACTIVE_IDLE_SUCCESSFULLY');
|
||||
@@ -42,7 +42,7 @@
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function onChangePasswordError(response) {
|
||||
function onError(response) {
|
||||
NotifycationService.showErrorNotify(response.data.message, 'ACTIVE_IDLE_ERROR');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="col-sm-9">
|
||||
<h3>{{'VIP.VIP_TITLE' | translate}}
|
||||
<small>{{'VIP.VIP_SUB_TITLE' | translate}}
|
||||
<small class="text-mt">{{ vm.user.vip_start_at | date: 'yyyy-MM-dd' }} - {{ vm.user.vip_end_at | date: 'yyyy-MM-dd' }}</small>
|
||||
<small class="text-mt" ng-if="vm.user.isVip">{{ vm.user.vip_start_at | date: 'yyyy-MM-dd' }} - {{ vm.user.vip_end_at | date: 'yyyy-MM-dd' }}</small>
|
||||
</small>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user