From 437566868bc7cb3a1c809078cf2670aa3233adf5 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Sun, 17 Dec 2017 13:57:11 +0800 Subject: [PATCH] feat(forums): new server notice message of torrent delete and support delete reason select or enter #20 --- config/env/torrents.js | 3 +- modules/core/client/app/trans-string-en.js | 14 +++++++- modules/core/client/app/trans-string-zh.js | 14 +++++++- .../forums-search-result.client.controller.js | 8 +++-- .../forums-search.client.controller.js | 6 ++-- .../forums-topic.client.controller.js | 1 - .../controllers/forums.server.controller.js | 2 +- .../controllers/messages.client.controller.js | 4 +-- .../admin/admin-list.client.controller.js | 21 +++++++++-- .../admin/uploader-list.client.controller.js | 1 - .../torrent-info.client.controller.js | 22 ++++++++++-- modules/torrents/client/less/torrents.less | 7 ++++ .../services/modal-confirm.client.service.js | 12 ++++++- .../templates/modal-confirm.client.view.html | 36 +++++++++++++++++-- .../controllers/torrents.server.controller.js | 14 +++++++- .../controllers/traces.server.controller.js | 4 ++- 16 files changed, 146 insertions(+), 23 deletions(-) diff --git a/config/env/torrents.js b/config/env/torrents.js index 37a229a3..0eb0d49e 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -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} } }, diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index c8f20aac..f1226f7d 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -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 demo and password demoAdmin12#, but don`t delete any demo data please, thanks!', WARNING_POPUP_STRING: 'This is a DEMO SITE, 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}}**.' } }; diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 34384a29..5e27b00d 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -17,6 +17,9 @@ DEMO_INFO: '欢迎进入meanTorrent演示站点, 您可以手动注册一个普通帐户或者使用admin演示帐号 demo 与密码 demoAdmin12#登录, 但请不要删除我们的演示数据, 谢谢!', WARNING_POPUP_STRING: '这里是一个 DEMO SITE, 所有资源仅供下载测试使用, 请在测试完毕后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}}**.' } }; diff --git a/modules/forums/client/controllers/forums-search-result.client.controller.js b/modules/forums/client/controllers/forums-search-result.client.controller.js index c7d54167..273f8344 100644 --- a/modules/forums/client/controllers/forums-search-result.client.controller.js +++ b/modules/forums/client/controllers/forums-search-result.client.controller.js @@ -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, diff --git a/modules/forums/client/controllers/forums-search.client.controller.js b/modules/forums/client/controllers/forums-search.client.controller.js index 35886e5c..3a5dc530 100644 --- a/modules/forums/client/controllers/forums-search.client.controller.js +++ b/modules/forums/client/controllers/forums-search.client.controller.js @@ -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}); diff --git a/modules/forums/client/controllers/forums-topic.client.controller.js b/modules/forums/client/controllers/forums-topic.client.controller.js index a77dd855..ed526c61 100644 --- a/modules/forums/client/controllers/forums-topic.client.controller.js +++ b/modules/forums/client/controllers/forums-topic.client.controller.js @@ -194,7 +194,6 @@ * onTopicTitleEdited */ $scope.onTopicTitleEdited = function (modifyed) { - console.log(modifyed); if (vm.topic && modifyed) { vm.topic.$update(function (res) { vm.topic = res; diff --git a/modules/forums/server/controllers/forums.server.controller.js b/modules/forums/server/controllers/forums.server.controller.js index 40ebad50..033faf0d 100644 --- a/modules/forums/server/controllers/forums.server.controller.js +++ b/modules/forums/server/controllers/forums.server.controller.js @@ -313,7 +313,7 @@ exports.globalTopics = function (req, res) { } }); - //console.log(ids); + mtDebug.debugBlue(ids); Topic.find({ isGlobal: true, diff --git a/modules/messages/client/controllers/messages.client.controller.js b/modules/messages/client/controllers/messages.client.controller.js index be811d6c..de304d6b 100644 --- a/modules/messages/client/controllers/messages.client.controller.js +++ b/modules/messages/client/controllers/messages.client.controller.js @@ -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); } }; diff --git a/modules/torrents/client/controllers/admin/admin-list.client.controller.js b/modules/torrents/client/controllers/admin/admin-list.client.controller.js index 1d611ce8..75c76848 100644 --- a/modules/torrents/client/controllers/admin/admin-list.client.controller.js +++ b/modules/torrents/client/controllers/admin/admin-list.client.controller.js @@ -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); diff --git a/modules/torrents/client/controllers/admin/uploader-list.client.controller.js b/modules/torrents/client/controllers/admin/uploader-list.client.controller.js index 08bd829f..70c8841d 100644 --- a/modules/torrents/client/controllers/admin/uploader-list.client.controller.js +++ b/modules/torrents/client/controllers/admin/uploader-list.client.controller.js @@ -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'); }); diff --git a/modules/torrents/client/controllers/torrent-info.client.controller.js b/modules/torrents/client/controllers/torrent-info.client.controller.js index f202a333..13ab3f0f 100644 --- a/modules/torrents/client/controllers/torrent-info.client.controller.js +++ b/modules/torrents/client/controllers/torrent-info.client.controller.js @@ -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); diff --git a/modules/torrents/client/less/torrents.less b/modules/torrents/client/less/torrents.less index 1a95061d..7a0c0bd0 100644 --- a/modules/torrents/client/less/torrents.less +++ b/modules/torrents/client/less/torrents.less @@ -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; } \ No newline at end of file diff --git a/modules/torrents/client/services/modal-confirm.client.service.js b/modules/torrents/client/services/modal-confirm.client.service.js index 314e9dd7..2db5d017 100644 --- a/modules/torrents/client/services/modal-confirm.client.service.js +++ b/modules/torrents/client/services/modal-confirm.client.service.js @@ -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); diff --git a/modules/torrents/client/templates/modal-confirm.client.view.html b/modules/torrents/client/templates/modal-confirm.client.view.html index 5f804641..79256e3b 100644 --- a/modules/torrents/client/templates/modal-confirm.client.view.html +++ b/modules/torrents/client/templates/modal-confirm.client.view.html @@ -3,11 +3,43 @@ \ No newline at end of file diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js index e6137f5a..3984704a 100644 --- a/modules/torrents/server/controllers/torrents.server.controller.js +++ b/modules/torrents/server/controllers/torrents.server.controller.js @@ -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 }); } }); diff --git a/modules/traces/server/controllers/traces.server.controller.js b/modules/traces/server/controllers/traces.server.controller.js index 04ae686b..bac13f7c 100644 --- a/modules/traces/server/controllers/traces.server.controller.js +++ b/modules/traces/server/controllers/traces.server.controller.js @@ -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]});