diff --git a/modules/core/client/app/init.js b/modules/core/client/app/init.js index e7d02960..3b9eb841 100644 --- a/modules/core/client/app/init.js +++ b/modules/core/client/app/init.js @@ -29,7 +29,7 @@ transConfig.$inject = ['$translateProvider']; function transConfig($translateProvider) { - $translateProvider.useSanitizeValueStrategy('escape'); + //$translateProvider.useSanitizeValueStrategy('escape'); $translateProvider.preferredLanguage('en'); //$translateProvider.fallbackLanguage('cn'); } diff --git a/modules/core/client/app/trans-string-cn.js b/modules/core/client/app/trans-string-cn.js index b712696e..983fcd20 100644 --- a/modules/core/client/app/trans-string-cn.js +++ b/modules/core/client/app/trans-string-cn.js @@ -46,13 +46,22 @@ UPLOADS_RULES: '上传规则:', UPLOADS_RULES_COUNT: '6', UPLOADS_RULES_CONTENT: [ - '种子文件的Tracker地址必须为:{{url}}', - '种子文件的 TMDB_ID 必须是 The Movie DB 相对应的资源ID号,您可以从这里找到ID号', - '资源的详细信息,系统会自动载入,如无误可直接提交', - '请为资源选择匹配的一个或多个标签,它会在您的搜索结果中发挥重大作用', - '种子文件提交后,可能会由后台管理人员进行审批,不符合规则的种子会被直接删除', - '如需其它帮助,请与我们的管理员联系:{{admin}}' - ] + '种子文件的Tracker地址必须为:{{url}}.', + '种子文件的 TMDB_ID 必须是 The Movie DB 相对应的资源ID号,您可以从这里找到ID号.', + '资源的详细信息,系统会自动载入,如无误可直接提交.', + '请为资源选择匹配的一个或多个标签,它会在您的搜索结果中发挥重大作用.', + '种子文件提交后,可能会由后台管理人员进行审批,不符合规则的种子会被直接删除.', + '如需其它帮助,请与我们的管理员联系:{{admin}}.' + ], + + //TorrentsUploadsController + TORRENTS_UPLOAD_SUCCESSFULLY: '文件上传成功', + TORRENTS_UPLOAD_FAILED: '文件上传失败', + TORRENTS_NO_FILE_SELECTED: '请选择种子文件后再做尝试', + + SELECT_TORRENT_FILE: '请选择种子文件', + SELECT_FILE: '选择文件', + DO_UPLOADS: '上传' }; // ************************************************** diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index ec610e04..c63bb39d 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -42,17 +42,26 @@ CHANGE_PASSWORD: 'Change Password', MANAGE_SOCIAL_ACCOUNTS: 'Manage Social Accounts', - //发种规则 + //Uploads rules UPLOADS_RULES: 'Uploads Rules:', UPLOADS_RULES_COUNT: '6', UPLOADS_RULES_CONTENT: [ - 'The torrent file`s Tracker URL must be: {{url}}', - 'The torrent file`s TMDB_ID must be TheMovieDB resources ID, you can find the ID from here', - 'The resources detail info can be autoload, if it`s fine, then you can submit it', - 'Select one or more tags that match the resources, which will play a significant role in your search results', - 'After the submission of documents, may be approved by the management, the rules do not meet the seeds will be deleted directly', - 'For additional assistance, please contact our administrator: {{admin}}' - ] + 'The torrent file`s Tracker URL must be: {{url}}.', + 'The torrent file`s TMDB_ID must be TheMovieDB resources ID, you can find the ID from here.', + 'The resources detail info can be autoload, if it`s fine, then you can submit it.', + 'Select one or more tags that match the resources, which will play a significant role in your search results.', + 'After the submission of documents, may be approved by the management, the rules do not meet the seeds will be deleted directly.', + 'For additional assistance, please contact our administrator: {{admin}}.' + ], + + //TorrentsUploadsController & views + TORRENTS_UPLOAD_SUCCESSFULLY: 'Successfully uploads file', + TORRENTS_UPLOAD_FAILED: 'Failed to uploads file', + TORRENTS_NO_FILE_SELECTED: 'No file selected', + + SELECT_TORRENT_FILE: 'Please select the torrent file', + SELECT_FILE: 'Select file', + DO_UPLOADS: 'Uploads' }; // ************************************************** diff --git a/modules/core/client/css/core.css b/modules/core/client/css/core.css index dab2b41a..edc5127f 100644 --- a/modules/core/client/css/core.css +++ b/modules/core/client/css/core.css @@ -41,3 +41,7 @@ a:hover .header-profile-image { .has-error .help-inline.error-text { display: inline; } + +.small-legend{ + font-size: 18px; +} diff --git a/modules/torrents/client/controllers/uploads.client.controller.js b/modules/torrents/client/controllers/uploads.client.controller.js index b34dd841..328f2bf2 100644 --- a/modules/torrents/client/controllers/uploads.client.controller.js +++ b/modules/torrents/client/controllers/uploads.client.controller.js @@ -5,12 +5,15 @@ .module('torrents') .controller('TorrentsUploadsController', TorrentsUploadsController); - TorrentsUploadsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'AnnounceConfig']; + TorrentsUploadsController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'AnnounceConfig', 'Upload', 'Notification']; - function TorrentsUploadsController($scope, $state, $translate, Authentication, AnnounceConfig) { + function TorrentsUploadsController($scope, $state, $translate, $timeout, Authentication, AnnounceConfig, Upload, Notification) { var vm = this; vm.announce = AnnounceConfig.announce; vm.rule_items = []; + vm.user = Authentication.user; + vm.progress = 0; + vm.successfully = undefined; for (var i = 0; i < $translate.instant('UPLOADS_RULES_COUNT'); i++) { vm.rule_items[i] = i; @@ -21,5 +24,56 @@ $state.go('authentication.signin'); } + //begin upload + vm.upload = function (dataUrl) { + console.log(dataUrl); + + if(dataUrl===null){ + vm.fileSelected = false; + // Show success message + Notification.success({ + message: ' ' + $translate.instant('TORRENTS_NO_FILE_SELECTED') + }); + return; + } + + Upload.upload({ + url: '/api/torrents/upload', + data: { + newTorrentFile: dataUrl + } + }).then(function (response) { + $timeout(function () { + onSuccessItem(response); + }); + }, function (response) { + console.log(response); + if (response.status > 0) onErrorItem(response); + }, function (evt) { + vm.progress = parseInt(100.0 * evt.loaded / evt.total, 10); + }); + }; + + // Called after the user has successfully uploaded a new picture + function onSuccessItem(response) { + vm.fileSelected = false; + vm.successfully = true; + // Show success message + Notification.success({ + message: ' ' + $translate.instant('TORRENTS_UPLOAD_SUCCESSFULLY') + }); + } + + // Called after the user has failed to upload a new picture + function onErrorItem(response) { + vm.fileSelected = false; + vm.successfully = false; + vm.tFile = undefined; + // Show error message + Notification.error({ + message: response.data, + title: ' ' + $translate.instant('TORRENTS_UPLOAD_FAILED') + }); + } } }()); diff --git a/modules/torrents/client/services/torrents.client.service.js b/modules/torrents/client/services/torrents.client.service.js new file mode 100644 index 00000000..fd0c0f1d --- /dev/null +++ b/modules/torrents/client/services/torrents.client.service.js @@ -0,0 +1,20 @@ +(function () { + 'use strict'; + + // Users service used for communicating with the users REST endpoint + angular + .module('torrents.services') + .factory('TorrentsService', TorrentsService); + + TorrentsService.$inject = ['$resource']; + + function TorrentsService($resource) { + var Torrents = $resource('/api/torrents', {}, { + update: { + method: 'POST' + } + }); + + return Torrents; + } +}()); diff --git a/modules/torrents/client/views/uploads-torrents.client.view.html b/modules/torrents/client/views/uploads-torrents.client.view.html index 5620721b..ca2bdafd 100644 --- a/modules/torrents/client/views/uploads-torrents.client.view.html +++ b/modules/torrents/client/views/uploads-torrents.client.view.html @@ -10,4 +10,35 @@ + +
+
+ +
+
+ + +
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + \ No newline at end of file