From 0fd53d8f5697d5ceaf3704ae4e1a50c5c5cfa3bb Mon Sep 17 00:00:00 2001 From: OldHawk Date: Thu, 19 Apr 2018 15:07:32 +0800 Subject: [PATCH] feat(torrents): show a seeding guide after torrent upload successfully. --- modules/core/client/app/trans-string-en.js | 3 + modules/core/client/app/trans-string-zh.js | 3 + .../client/config/core.client.route-filter.js | 1 + .../controllers/header.client.controller.js | 4 +- modules/core/client/less/mt.less | 4 +- .../controllers/uploads.client.controller.js | 59 +++++++++++++------ modules/torrents/client/less/torrents.less | 44 ++++++++++++++ .../views/uploads-torrents.client.view.html | 16 ++++- 8 files changed, 111 insertions(+), 23 deletions(-) diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 51e3cd2a..86f7cb51 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -476,6 +476,9 @@ TORRENTS_UPLOAD_SUCCESSFULLY: 'Successfully upload file', TORRENTS_UPLOAD_FAILED: 'Failed to upload file', TORRENTS_NO_FILE_SELECTED: 'No file selected', + BUTTON_UPLOADED_POPUP_CLOSE: 'OK', + POPUP_UPLOADED_TOOLTIP:'The torrent is uploaded successfully and is waiting for the administrator to review. The new torrent file with your Passkey will be automatically downloaded after you click the "OK" button, and you can use this new torrent file to start seeding.', + TORRENT_DOWNLOADING_FILENAME: 'Downloading file name:', SELECT_RESOURCE_TYPE: '2. Please select the resource type', SELECT_TORRENT_FILE: '1. Please select the torrent file', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index b313d4d7..f2af43f3 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -476,6 +476,9 @@ TORRENTS_UPLOAD_SUCCESSFULLY: '文件上传成功', TORRENTS_UPLOAD_FAILED: '文件上传失败', TORRENTS_NO_FILE_SELECTED: '请选择种子文件后再做尝试', + BUTTON_UPLOADED_POPUP_CLOSE: '确定', + POPUP_UPLOADED_TOOLTIP:'种子上传成功并等待管理员的审核,带有您 Passkey 的种子文件会在您点击 "确定" 按钮后被自动下载,然后您就可以使用这个新的种子文件开始做种了。', + TORRENT_DOWNLOADING_FILENAME: '种子文件名:', SELECT_RESOURCE_TYPE: '2. 请选择上传资源类型', SELECT_TORRENT_FILE: '1. 请选择种子文件', diff --git a/modules/core/client/config/core.client.route-filter.js b/modules/core/client/config/core.client.route-filter.js index 8f18b290..fa641206 100644 --- a/modules/core/client/config/core.client.route-filter.js +++ b/modules/core/client/config/core.client.route-filter.js @@ -14,6 +14,7 @@ function stateChangeStart(event, toState, toParams, fromState, fromParams) { $('.side-background').remove(); $('.textcomplete-dropdown').remove(); + $('.popup_wrapper').remove(); // Check authentication before changing state if (toState.data && toState.data.roles && toState.data.roles.length > 0) { var allowed = false; diff --git a/modules/core/client/controllers/header.client.controller.js b/modules/core/client/controllers/header.client.controller.js index 06083296..1fe8e005 100644 --- a/modules/core/client/controllers/header.client.controller.js +++ b/modules/core/client/controllers/header.client.controller.js @@ -119,9 +119,7 @@ if (vm.appConfig.showDemoWarningPopup && !sw) { $timeout(function () { $('#warning_popup').popup('show'); - //$('.warning_popup_open').trigger('click'); - //angular.element('#myselector').triggerHandler('click'); - }, 300); + }, 10); localStorageService.set('showed_warning', true); } diff --git a/modules/core/client/less/mt.less b/modules/core/client/less/mt.less index 99bdc567..2a260311 100644 --- a/modules/core/client/less/mt.less +++ b/modules/core/client/less/mt.less @@ -1865,7 +1865,7 @@ body { } #warning_popup_background { - transition: all 0.3s 0.3s; + transition: all 0.3s 0.05s; } #warning_popup, @@ -1887,7 +1887,7 @@ body { background-color: #fff; opacity: 0.8 !important; width: 80%; - margin-top: 100px; + top: 20%; border-radius: 4px; h3, .h3 { diff --git a/modules/torrents/client/controllers/uploads.client.controller.js b/modules/torrents/client/controllers/uploads.client.controller.js index b71b661e..eb0cf0a7 100644 --- a/modules/torrents/client/controllers/uploads.client.controller.js +++ b/modules/torrents/client/controllers/uploads.client.controller.js @@ -7,11 +7,11 @@ TorrentsUploadController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'MeanTorrentConfig', 'Upload', 'Notification', 'TorrentsService', 'getStorageLangService', '$filter', 'DownloadService', 'DebugConsoleService', 'NotifycationService', 'SideOverlay', - '$templateRequest', 'marked']; + '$templateRequest', 'marked', '$rootScope']; function TorrentsUploadController($scope, $state, $translate, $timeout, Authentication, MeanTorrentConfig, Upload, Notification, TorrentsService, getStorageLangService, $filter, DownloadService, mtDebug, NotifycationService, SideOverlay, - $templateRequest, marked) { + $templateRequest, marked, $rootScope) { var vm = this; vm.announceConfig = MeanTorrentConfig.meanTorrentConfig.announce; vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig; @@ -47,6 +47,31 @@ vm.videoNfo = ''; vm.customTorrent = {}; + $rootScope.announceConfig = vm.announceConfig; + /** + * document.ready + * #uploaded_popup.popup + */ + $(document).ready(function () { + $('#uploaded_popup').popup({ + outline: false, + focusdelay: 400, + vertical: 'top', + autoopen: false, + opacity: 0.6, + blur: false, + escape: false, + closetransitionend: function () { + // Notification.success({message: ' Torrent created successfully!'}); + if (vm.downloadingTorrent) { + vm.downloadTorrent(vm.downloadingTorrent._id); + } + $state.reload('torrents.uploads'); + document.body.scrollTop = document.documentElement.scrollTop = 0; + } + }); + }); + /** * getTemplateFileContent * @param file @@ -469,11 +494,7 @@ }); function successCallback(res) { - vm.downloadTorrent(res._id); - Notification.success({message: ' Torrent created successfully!'}); - - $state.reload('torrents.uploads'); - document.body.scrollTop = document.documentElement.scrollTop = 0; + vm.showUploadedPopup(res); } function errorCallback(res) { @@ -514,11 +535,7 @@ }); function successCallback(res) { - vm.downloadTorrent(res._id); - Notification.success({message: ' Torrent created successfully!'}); - - $state.reload('torrents.uploads'); - document.body.scrollTop = document.documentElement.scrollTop = 0; + vm.showUploadedPopup(res); } function errorCallback(res) { @@ -580,11 +597,7 @@ }); function successCallback(res) { - vm.downloadTorrent(res._id); - Notification.success({message: ' Torrent created successfully!'}); - - $state.reload('torrents.uploads'); - document.body.scrollTop = document.documentElement.scrollTop = 0; + vm.showUploadedPopup(res); } function errorCallback(res) { @@ -651,6 +664,18 @@ vm.tags = []; }; + /** + * showUploadedPopup + * @param t + */ + vm.showUploadedPopup = function (t) { + vm.downloadingTorrent = t; + $rootScope.downloadingTorrent = t; + $timeout(function () { + $('#uploaded_popup').popup('show'); + }, 10); + }; + /** * downloadTorrent * @param id diff --git a/modules/torrents/client/less/torrents.less b/modules/torrents/client/less/torrents.less index 6317edd1..11ccf8f8 100644 --- a/modules/torrents/client/less/torrents.less +++ b/modules/torrents/client/less/torrents.less @@ -175,3 +175,47 @@ pre.prettyprint { } } /* csslint ignore:end */ + +//popup overlay---------------------------------------------- +/* csslint ignore:start */ +.uploaded_popup { + box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); + display: none; +} + +#uploaded_popup_background { + transition: all 0.3s 0.05s; +} + +#uploaded_popup, +#uploaded_popup_wrapper { + transition: all 0.3s ease-out; +} + +#uploaded_popup { + transform: translateX(0) translateY(-40%); +} + +.popup_visible #uploaded_popup { + transform: translateX(0) translateY(0); +} + +#uploaded_popup, +#uploaded_popup_wrapper { + .popup_content { + background-color: #fff; + opacity: 0.8 !important; + width: 80%; + top: 20%; + border-radius: 4px; + h3, + .h3 { + line-height: 1.6 !important; + } + } + .downloading-filename { + word-break: break-all; + } +} +/* csslint ignore:end */ +//popup overlay end ------------------------------------------- diff --git a/modules/torrents/client/views/uploads-torrents.client.view.html b/modules/torrents/client/views/uploads-torrents.client.view.html index 3f73a045..19fcb549 100644 --- a/modules/torrents/client/views/uploads-torrents.client.view.html +++ b/modules/torrents/client/views/uploads-torrents.client.view.html @@ -770,5 +770,19 @@ + - \ No newline at end of file +