feat(forums): new server notice message of torrent delete and support delete reason select or enter

#20
This commit is contained in:
OldHawk
2017-12-17 13:57:11 +08:00
parent ee467665b5
commit 437566868b
16 changed files with 146 additions and 23 deletions

View File

@@ -348,8 +348,9 @@ module.exports = {
torrentVipChanged: {title: 'TITLE_TORRENT_VIP_CHANGED', content: 'CONTENT_TORRENT_VIP_CHANGED', enable: true},
torrentHnRChanged: {title: 'TITLE_TORRENT_HNR_CHANGED', content: 'CONTENT_TORRENT_HNR_CHANGED', enable: true},
torrentSaleChanged: {title: 'TITLE_TORRENT_SALE_CHANGED', content: 'CONTENT_TORRENT_SALE_CHANGED', enable: true},
torrentDeleted: {title: 'TITLE_TORRENT_DELETED', content: 'CONTENT_TORRENT_DELETED', enable: true},
torrentDeleted: {title: 'TITLE_TORRENT_DELETED', content: 'CONTENT_TORRENT_DELETED', enable: true}
torrentSubtitleDeleted: {title: 'TITLE_TORRENT_SUBTITLE_DELETED', content: 'CONTENT_TORRENT_SUBTITLE_DELETED', enable: true}
}
},

View File

@@ -17,6 +17,9 @@
DEMO_INFO: 'Welcome to demo site, you can sign up manual to create a normal account or sign in as demo admin with account <mark>demo</mark> and password <mark>demoAdmin12#</mark>, but don`t delete any demo data please, thanks!',
WARNING_POPUP_STRING: 'This is a <strong style="color:#f00">DEMO SITE</strong>, all resources are for download testing only, please delete it within 24 hours after the test is completed, we recommend that you buy genuine resources!',
VALUE_NULL: 'NULL',
VALUE_CUSTOM: 'CUSTOM',
//client topbar menu
MENU_CHAT: 'Chat',
MENU_TORRENTS: 'Torrents',
@@ -357,6 +360,12 @@
TORRENT_DELETE_CONFIRM_BODY_TEXT: 'Are you sure want to delete this torrent?',
TORRENT_DELETE_SUCCESSFULLY: 'Torrent delete successfully',
TORRENT_DELETE_ERROR: 'Torrent delete failed',
TORRENT_DELETE_REASON: 'Please select or enter the delete reason for uploader:',
TORRENT_ENTER_DELETE_REASON: 'Please enter custom delete reason',
TORRENT_DELETE_REASON_OVERVIEW: 'The torrent overview info is not complete or missing',
TORRENT_DELETE_REASON_NFO: 'The torrent NFO info is not complete or missing',
TORRENT_DELETE_REASON_QUALITY: 'The torrent quality is too low',
TORRENT_DELETE_REASON_ILLEGAL: 'The torrent is illegal',
TORRENT_UPDATE_CONFIRM_OK: 'Update',
TORRENT_UPDATE_CONFIRM_CANCEL: 'Cancel',
TORRENT_UPDATE_CONFIRM_HEADER_TEXT: 'Update Confirm',
@@ -1336,7 +1345,10 @@
CONTENT_TORRENT_HNR_CHANGED: '### H&R status changed! \n You uploaded torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}) H&R status was changed by user [{{by_name}}](/userinfo/{{by_id}}), current status is **{{hnr_status}}**.',
TITLE_TORRENT_SALE_CHANGED: 'Torrent sale status changed',
CONTENT_TORRENT_SALE_CHANGED: '### Sale status changed! \n You uploaded torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}) sale status was changed by user [{{by_name}}](/userinfo/{{by_id}}), current status is **{{sale_status}}**.'
CONTENT_TORRENT_SALE_CHANGED: '### Sale status changed! \n You uploaded torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}) sale status was changed by user [{{by_name}}](/userinfo/{{by_id}}), current status is **{{sale_status}}**.',
TITLE_TORRENT_DELETED: 'Torrent was deleted',
CONTENT_TORRENT_DELETED: ':warning: You uploaded torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}) was deleted by user [{{by_name}}](/userinfo/{{by_id}}), reason is: **{{reason | translate}}**.'
}
};

View File

@@ -17,6 +17,9 @@
DEMO_INFO: '欢迎进入meanTorrent演示站点, 您可以手动注册一个普通帐户或者使用admin演示帐号 <mark>demo</mark> 与密码 <mark>demoAdmin12#</mark>登录, 但请不要删除我们的演示数据, 谢谢!',
WARNING_POPUP_STRING: '这里是一个 <strong style="color:#f00">DEMO SITE</strong>, 所有资源仅供下载测试使用, 请在测试完毕后24小时内立即删除, 我们推荐您使用正版资源!',
VALUE_NULL: '无',
VALUE_CUSTOM: '自定义',
//client topbar menu
MENU_CHAT: '聊天室',
MENU_TORRENTS: '种子',
@@ -357,6 +360,12 @@
TORRENT_DELETE_CONFIRM_BODY_TEXT: '你确定要删除这条种子吗?',
TORRENT_DELETE_SUCCESSFULLY: '种子删除成功',
TORRENT_DELETE_ERROR: '种子删除失败',
TORRENT_DELETE_REASON: '请选择或输入一个删除种子的理由给上传者:',
TORRENT_ENTER_DELETE_REASON: '请输入自定义删除理由',
TORRENT_DELETE_REASON_OVERVIEW: '种子简介信息缺少或者不完整',
TORRENT_DELETE_REASON_NFO: '种子NFO信息缺少或者不完整',
TORRENT_DELETE_REASON_QUALITY: '种子资源质量太低下',
TORRENT_DELETE_REASON_ILLEGAL: '该种子是非法的',
TORRENT_UPDATE_CONFIRM_OK: '更新',
TORRENT_UPDATE_CONFIRM_CANCEL: '取消',
TORRENT_UPDATE_CONFIRM_HEADER_TEXT: '更新确认',
@@ -1336,7 +1345,10 @@
CONTENT_TORRENT_HNR_CHANGED: '### H&R 状态改变! \n 您上传的种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}) H&R 状态已经由管理员用户 [{{by_name}}](/userinfo/{{by_id}}) 修改, 当前状态为: **{{hnr_status}}**.',
TITLE_TORRENT_SALE_CHANGED: '种子促销状态改变',
CONTENT_TORRENT_SALE_CHANGED: '### 促销状态改变! \n 您上传的种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}) 促销状态已经由管理员用户 [{{by_name}}](/userinfo/{{by_id}}) 修改, 当前状态为: **{{sale_status}}**.'
CONTENT_TORRENT_SALE_CHANGED: '### 促销状态改变! \n 您上传的种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}) 促销状态已经由管理员用户 [{{by_name}}](/userinfo/{{by_id}}) 修改, 当前状态为: **{{sale_status}}**.',
TITLE_TORRENT_DELETED: '种子被删除',
CONTENT_TORRENT_DELETED: ':warning: 您上传的种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}) 被管理员用户 [{{by_name}}](/userinfo/{{by_id}}) 删除, 理由是: **{{reason | translate}}**.'
}
};

View File

@@ -5,9 +5,11 @@
.module('forums')
.controller('ForumsSearchResultController', ForumsSearchResultController);
ForumsSearchResultController.$inject = ['$scope', '$state', '$timeout', 'Authentication', 'MeanTorrentConfig', 'ForumsService', '$sanitize', 'NotifycationService'];
ForumsSearchResultController.$inject = ['$scope', '$state', '$timeout', 'Authentication', 'MeanTorrentConfig', 'ForumsService', '$sanitize', 'NotifycationService',
'DebugConsoleService'];
function ForumsSearchResultController($scope, $state, $timeout, Authentication, MeanTorrentConfig, ForumsService, $sanitize, NotifycationService) {
function ForumsSearchResultController($scope, $state, $timeout, Authentication, MeanTorrentConfig, ForumsService, $sanitize, NotifycationService,
mtDebug) {
var vm = this;
vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig;
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
@@ -59,7 +61,7 @@
vm.isLoading = true;
vm.pagedItems = [];
console.log($state.params.forumId);
mtDebug.info($state.params.forumId);
var fs = new ForumsService({
forumId: $state.params.forumId || undefined,
keys: $state.params.keys,

View File

@@ -5,9 +5,9 @@
.module('forums')
.controller('ForumsSearchController', ForumsSearchController);
ForumsSearchController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsService'];
ForumsSearchController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsService', 'DebugConsoleService'];
function ForumsSearchController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsService) {
function ForumsSearchController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsService, mtDebug) {
var vm = this;
vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig;
vm.user = Authentication.user;
@@ -94,7 +94,7 @@
}
});
console.log(fid);
mtDebug.info(fid);
$state.go('forums.search', {forumId: fid, keys: vm.searchKeys});
} else {
$state.go('forums.search', {forumId: vm.selectedForum._id, keys: vm.searchKeys});

View File

@@ -194,7 +194,6 @@
* onTopicTitleEdited
*/
$scope.onTopicTitleEdited = function (modifyed) {
console.log(modifyed);
if (vm.topic && modifyed) {
vm.topic.$update(function (res) {
vm.topic = res;

View File

@@ -313,7 +313,7 @@ exports.globalTopics = function (req, res) {
}
});
//console.log(ids);
mtDebug.debugBlue(ids);
Topic.find({
isGlobal: true,

View File

@@ -195,7 +195,7 @@
SideOverlay.close(evt, 'popupSlide', function () {
vm.isClosing = true;
vm.selectedMessage = vm.contentToJSON(msg);
console.log(vm.selectedMessage);
mtDebug.info(vm.selectedMessage);
SideOverlay.open(evt, 'popupSlide');
vm.replyContent = undefined;
vm.updateReadStatus(msg);
@@ -204,7 +204,7 @@
vm.selectedMessage = vm.contentToJSON(msg);
SideOverlay.open(evt, 'popupSlide');
vm.replyContent = undefined;
console.log(vm.selectedMessage);
mtDebug.info(vm.selectedMessage);
vm.updateReadStatus(msg);
}
};

View File

@@ -358,13 +358,30 @@
actionButtonText: $translate.instant('TORRENT_DELETE_CONFIRM_OK'),
headerText: $translate.instant('TORRENT_DELETE_CONFIRM_HEADER_TEXT'),
bodyText: $translate.instant('TORRENT_DELETE_CONFIRM_BODY_TEXT'),
bodyParams: item.torrent_filename
bodyParams: item.torrent_filename,
selectOptions: {
enable: true,
title: 'TORRENT_DELETE_REASON',
options: [
'TORRENT_DELETE_REASON_OVERVIEW',
'TORRENT_DELETE_REASON_NFO',
'TORRENT_DELETE_REASON_QUALITY',
'TORRENT_DELETE_REASON_ILLEGAL'
]
}
};
ModalConfirmService.showModal({}, modalOptions)
.then(function (result) {
var reason = result.reason;
if (reason === 'NULL') reason = undefined;
if (reason === 'CUSTOM') reason = result.custom;
var dt = new TorrentsService(item);
dt.$remove(function (response) {
dt.$remove({
reason: reason
}, function (response) {
successCallback(response);
}, function (errorResponse) {
errorCallback(errorResponse);

View File

@@ -106,7 +106,6 @@
vm.onUploaderUserAccessChanged = function (u) {
var user = new AdminService(u);
user.$update(function (res) {
console.log(res);
vm.pagedItems[vm.pagedItems.indexOf(u)] = res;
NotifycationService.showSuccessNotify('UPLOADER.ACCESS_CHANGED_SUCCESSFULLY');
});

View File

@@ -916,12 +916,30 @@
closeButtonText: $translate.instant('TORRENT_DELETE_CONFIRM_CANCEL'),
actionButtonText: $translate.instant('TORRENT_DELETE_CONFIRM_OK'),
headerText: $translate.instant('TORRENT_DELETE_CONFIRM_HEADER_TEXT'),
bodyText: $translate.instant('TORRENT_DELETE_CONFIRM_BODY_TEXT')
bodyText: $translate.instant('TORRENT_DELETE_CONFIRM_BODY_TEXT'),
bodyParams: vm.torrentLocalInfo.torrent_filename,
selectOptions: {
enable: true,
title: 'TORRENT_DELETE_REASON',
options: [
'TORRENT_DELETE_REASON_OVERVIEW',
'TORRENT_DELETE_REASON_NFO',
'TORRENT_DELETE_REASON_QUALITY',
'TORRENT_DELETE_REASON_ILLEGAL'
]
}
};
ModalConfirmService.showModal({}, modalOptions)
.then(function (result) {
vm.torrentLocalInfo.$remove(function (response) {
var reason = result.reason;
if (reason === 'NULL') reason = undefined;
if (reason === 'CUSTOM') reason = result.custom;
vm.torrentLocalInfo.$remove({
reason: reason
}, function (response) {
successCallback(response);
}, function (errorResponse) {
errorCallback(errorResponse);

View File

@@ -38,4 +38,11 @@
line-height: 2.5;
font-size: 12px;
color: #999;
}
.modal-options {
background-color: #f8f8f8;
border-radius: 5px;
border: solid 1px #efefef;
padding: 10px;
}

View File

@@ -16,7 +16,12 @@
actionButtonText: 'Yes',
headerText: 'Confirm?',
bodyText: 'Confirm this action?',
bodyParams: undefined
bodyParams: undefined,
selectOptions: {
enable: false,
title: undefined,
options: []
}
};
var modalDefaults = {
@@ -67,6 +72,11 @@
ModalConfirmController.$inject = ['$scope', '$uibModalInstance', 'modalOptions'];
function ModalConfirmController($scope, $uibModalInstance, modalOptions) {
$scope.optionSelected = {
value: 'NULL',
custom: undefined
};
$scope.modalOptions = modalOptions;
$scope.modalOptions.ok = function (result) {
$uibModalInstance.close(result);

View File

@@ -3,11 +3,43 @@
</div>
<div class="modal-body">
<p>{{modalOptions.bodyText}}</p>
<p ng-show="modalOptions.bodyParams">{{modalOptions.bodyParams}}</p>
<div class="modal-options margin-top-30 margin-left-10 margin-right-10" ng-show="modalOptions.selectOptions.enable">
<p class="h5" translate="{{modalOptions.selectOptions.title}}"></p>
<div class="margin-left-10">
<div class="radio">
<label>
<input type="radio" id="option_x" name="option_item" ng-model="optionSelected.value" value="NULL"> {{'VALUE_NULL' | translate}}
</label>
</div>
<div class="radio" ng-repeat="o in modalOptions.selectOptions.options">
<label>
<input type="radio" id="option_{{$index}}" name="option_item" ng-model="optionSelected.value"
value="{{o}}"> {{o | translate}}
</label>
</div>
<div class="radio">
<label>
<input type="radio" id="option_y" name="option_item" ng-model="optionSelected.value"
value="CUSTOM"> {{'VALUE_CUSTOM' | translate}}
</label>
<input type="text" ng-show="optionSelected.value == 'CUSTOM'" class="form-control margin-top-10" maxlength="200"
placeholder="{{'TORRENT_ENTER_DELETE_REASON' | translate}}"
ng-model="optionSelected.custom">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-width-100"
data-ng-click="modalOptions.close()">{{modalOptions.closeButtonText}}</button>
data-ng-click="modalOptions.close()">{{modalOptions.closeButtonText}}
</button>
<button class="btn btn-success btn-width-100"
data-ng-click="modalOptions.ok();">{{modalOptions.actionButtonText}}</button>
data-ng-click="modalOptions.ok({reason: optionSelected.value, custom: optionSelected.custom});">{{modalOptions.actionButtonText}}
</button>
</div>

View File

@@ -1226,10 +1226,22 @@ exports.delete = function (req, res) {
} else {
res.json(torrent);
//add server message
if (serverNoticeConfig.action.torrentDeleted.enable) {
serverMessage.addMessage(torrent.user._id, serverNoticeConfig.action.torrentDeleted.title, serverNoticeConfig.action.torrentDeleted.content, {
torrent_file_name: torrent.torrent_filename,
torrent_id: torrent._id,
by_name: req.user.displayName,
by_id: req.user._id,
reason: req.query.reason
});
}
scoreUpdate(req, torrent.user, scoreConfig.action.uploadTorrentBeDeleted);
//create trace log
traceLogCreate(req, traceConfig.action.AdminTorrentDelete, {
torrent: torrent._id
torrent: torrent._id,
reason: req.query.reason
});
}
});

View File

@@ -11,6 +11,8 @@ var path = require('path'),
Trace = mongoose.model('Trace'),
async = require('async');
var mtDebug = require(path.resolve('./config/lib/debug'));
/**
* list Traces
* @param req
@@ -89,7 +91,7 @@ exports.list = function (req, res) {
async.parallel([countQuery, findQuery], function (err, results) {
if (err) {
console.log(err);
mtDebug.debugRed(err);
return res.status(422).send(err);
} else {
res.json({rows: results[1], total: results[0]});