From 7eea910b10db0f0e6681a35d84357dd8d93daedc Mon Sep 17 00:00:00 2001 From: OldHawk Date: Thu, 21 Sep 2017 13:18:29 +0800 Subject: [PATCH] feat(torrents): hide vip torrents in normal list page --- modules/core/client/app/trans-string-en.js | 1 + modules/core/client/app/trans-string-zh.js | 1 + modules/core/client/less/mt.less | 26 ++++++++++++++++++- .../admin/admin-list.client.controller.js | 15 ++++++++++- .../torrent-info.client.controller.js | 13 ++++++++++ .../views/admin/admin-list.client.view.html | 12 +++++++++ .../controllers/torrents.server.controller.js | 11 +++++++- 7 files changed, 76 insertions(+), 3 deletions(-) diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 1b542ae7..a80fab70 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -207,6 +207,7 @@ CA_KEYWORD: 'Keyword', CA_TORRENT_STATUS: 'Torrent status', CA_TORRENT_HNR: 'Hit and Run', + CA_TORRENT_VIP: 'VIP resources', CA_RESOURCE_TYPE: 'Resource type', PH_KEYWORD: 'Search keyword', CLEAR_ALL_CONDITION: 'Clear All Condition', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 224dd0a4..83f50bed 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -207,6 +207,7 @@ CA_KEYWORD: '关键字', CA_TORRENT_STATUS: '种子状态', CA_TORRENT_HNR: 'Hit and Run', + CA_TORRENT_VIP: 'VIP 资源', CA_RESOURCE_TYPE: '资源类型', PH_KEYWORD: '搜索关键字', CLEAR_ALL_CONDITION: '清空所有条件', diff --git a/modules/core/client/less/mt.less b/modules/core/client/less/mt.less index 3bb3f88c..7e969aa0 100644 --- a/modules/core/client/less/mt.less +++ b/modules/core/client/less/mt.less @@ -614,7 +614,7 @@ body { min-width: 90px; } .td-admin-cmd { - min-width: 140px; + min-width: 143px; } } @@ -741,6 +741,22 @@ body { } } +.label-vip-info { + color: @mt-base-color; + font-weight: bold; + background-color: #f1f8ff; + &:hover { + cursor: pointer; + color: #f00; + } + &:active { + color: #0366d6; + } + &.used { + background-color: #c9e4ff !important; + } +} + .label-se-info { color: @mt-base-color; background-color: #f1f8ff; @@ -800,6 +816,14 @@ body { } } +.checkbox-vip { + margin-top: 0; + margin-bottom: 0; + input[type="checkbox"] { + margin-top: 8px; + } +} + .incline-block-valign { display: inline-block; vertical-align: middle; 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 f0cea03e..36a84c3e 100644 --- a/modules/torrents/client/controllers/admin/admin-list.client.controller.js +++ b/modules/torrents/client/controllers/admin/admin-list.client.controller.js @@ -25,6 +25,7 @@ vm.searchKey = ''; vm.releaseYear = undefined; vm.filterHnR = false; + vm.filterVIP = false; vm.torrentStatus = 'reviewed'; vm.torrentRLevel = 'none'; @@ -187,7 +188,8 @@ torrent_type: vm.selectedType, torrent_release: vm.releaseYear, torrent_tags: vm.searchTags, - torrent_hnr: vm.filterHnR + torrent_hnr: vm.filterHnR, + torrent_vip: vm.filterVIP }, function (items) { if (items.length === 0) { Notification.error({ @@ -279,6 +281,17 @@ vm.torrentBuildPager(); }; + /** + * onVIPClicked, onVIPChanged + */ + vm.onVIPClicked = function () { + vm.filterVIP = !vm.filterVIP; + vm.torrentBuildPager(); + }; + vm.onVIPChanged = function () { + vm.torrentBuildPager(); + }; + /** * onRLevelClicked * @param y diff --git a/modules/torrents/client/controllers/torrent-info.client.controller.js b/modules/torrents/client/controllers/torrent-info.client.controller.js index e5b87e51..7bd57db4 100644 --- a/modules/torrents/client/controllers/torrent-info.client.controller.js +++ b/modules/torrents/client/controllers/torrent-info.client.controller.js @@ -148,6 +148,19 @@ }); }; + /** + * toggleVIP + */ + vm.toggleVIP = function () { + vm.torrentLocalInfo.$toggleVIPStatus(function (res) { + mtDebug.info(res); + vm.torrentLocalInfo = res; + NotifycationService.showSuccessNotify('TORRENT_TOGGLE_VIP_SUCCESSFULLY'); + }, function (res) { + NotifycationService.showErrorNotify(res.data.message, 'TORRENT_TOGGLE_VIP_FAILED'); + }); + }; + /** * doScrape */ diff --git a/modules/torrents/client/views/admin/admin-list.client.view.html b/modules/torrents/client/views/admin/admin-list.client.view.html index 74cc3835..25491bc9 100644 --- a/modules/torrents/client/views/admin/admin-list.client.view.html +++ b/modules/torrents/client/views/admin/admin-list.client.view.html @@ -51,6 +51,15 @@ +
{{ 'CA_TORRENT_HNR' | translate}}:
+
+
+ +
+
+
{{ 'CA_TORRENT_STATUS' | translate}}:
@@ -201,6 +210,9 @@ H&R + VIP + diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js index b7acac29..798f6135 100644 --- a/modules/torrents/server/controllers/torrents.server.controller.js +++ b/modules/torrents/server/controllers/torrents.server.controller.js @@ -824,6 +824,7 @@ exports.list = function (req, res) { var stype = 'movie'; var newest = false; var hnr = false; + var vip = undefined; var release = undefined; var userid = undefined; var tagsA = []; @@ -852,6 +853,9 @@ exports.list = function (req, res) { if (req.query.torrent_hnr !== undefined) { hnr = req.query.torrent_hnr; } + if (req.query.torrent_vip !== undefined) { + vip = req.query.torrent_vip; + } if (req.query.newest !== undefined) { newest = (req.query.newest === 'true'); } @@ -896,6 +900,11 @@ exports.list = function (req, res) { if (hnr === 'true') { condition.torrent_hnr = hnr; } + if (vip === 'true') { + condition.torrent_vip = true; + } else if (vip === undefined) { + condition.torrent_vip = false; + } if (tagsA.length > 0) { condition.torrent_tags = {$all: tagsA}; @@ -1114,7 +1123,7 @@ exports.torrentByID = function (req, res, next, id) { mtDebug.debugGreen(condition); - var fields = 'user torrent_filename torrent_tags torrent_seeds torrent_leechers torrent_finished torrent_seasons torrent_episodes torrent_size torrent_sale_status torrent_type torrent_hnr torrent_sale_expires createdat'; + var fields = 'user torrent_filename torrent_tags torrent_seeds torrent_leechers torrent_finished torrent_seasons torrent_episodes torrent_size torrent_sale_status torrent_type torrent_hnr torrent_vip torrent_sale_expires createdat'; Torrent.find(condition, fields) .sort('-createdat')