diff --git a/app/langs/zh_CN.json b/app/langs/zh_CN.json index 31273c4..e3d3223 100644 --- a/app/langs/zh_CN.json +++ b/app/langs/zh_CN.json @@ -4,6 +4,7 @@ "Error": "错误", "OK": "确定", "Cancel": "取消", + "Options": "选项", "New": "新建", "Start": "开始下载任务", "Pause": "暂停下载任务", @@ -76,9 +77,11 @@ "Are you sure you want to clear stopped tasks?": "您是否要清除已结束的任务?", "Download Links:": "下载链接:", "Start Download": "立即下载", + "Manual Download": "手动下载", "Open Torrent File": "打开种子文件", "Open Metalink File": "打开 Metalink 文件", "Support multiple URLs, one URL per line.": "支持多个 URL 地址, 每个地址占一行.", + "More Options": "更多选项", "Language": "语言", "Aria2 RPC Host": "Aria2 RPC 主机", "Aria2 RPC Port": "Aria2 RPC 端口", diff --git a/app/scripts/config/aria2Options.js b/app/scripts/config/aria2Options.js index 835b3e7..84b3e7e 100644 --- a/app/scripts/config/aria2Options.js +++ b/app/scripts/config/aria2Options.js @@ -563,6 +563,7 @@ activeBtTaskOptions: ['max-download-limit', 'max-upload-limit', 'bt-max-peers', 'bt-request-peer-speed-limit', 'bt-remove-unselected-file', 'force-save'], inactiveNormalTaskOptions: ['max-download-limit', 'max-upload-limit', 'split', 'min-split-size', 'max-connection-per-server', 'force-save'], inactiveBtTaskOptions: ['max-download-limit', 'max-upload-limit', 'split', 'min-split-size', 'max-connection-per-server', 'bt-max-peers', 'bt-request-peer-speed-limit', 'bt-remove-unselected-file', 'force-save'], - activeTaskReadonlyOptions: ['split', 'min-split-size', 'max-connection-per-server'] + activeTaskReadonlyOptions: ['split', 'min-split-size', 'max-connection-per-server'], + newTaskOptions: ['dir', 'max-download-limit', 'max-upload-limit'] }); })(); diff --git a/app/scripts/config/defaultLanguage.js b/app/scripts/config/defaultLanguage.js index f3af1c1..1017375 100644 --- a/app/scripts/config/defaultLanguage.js +++ b/app/scripts/config/defaultLanguage.js @@ -8,6 +8,7 @@ 'Error': 'Error', 'OK': 'OK', 'Cancel': 'Cancel', + 'Options': 'Options', 'New': 'New', 'Start': 'Start', 'Pause': 'Pause', @@ -82,7 +83,9 @@ 'Open Torrent File': 'Open Torrent File', 'Open Metalink File': 'Open Metalink File', 'Start Download': 'Start Download', + 'Manual Download': 'Manual Download', 'Support multiple URLs, one URL per line.': 'Support multiple URLs, one URL per line.', + 'More Options': 'More Options', 'Language': 'Language', 'Aria2 RPC Host': 'Aria2 RPC Host', 'Aria2 RPC Port': 'Aria2 RPC Port', diff --git a/app/scripts/controllers/new.js b/app/scripts/controllers/new.js index d96e8a1..5b99dca 100644 --- a/app/scripts/controllers/new.js +++ b/app/scripts/controllers/new.js @@ -1,18 +1,70 @@ (function () { 'use strict'; - angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', 'ariaNgCommonService', 'aria2TaskService', function ($rootScope, $scope, $location, ariaNgCommonService, aria2TaskService) { - $scope.urls = ''; - $scope.options = {}; + angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', 'aria2SettingService', 'aria2TaskService', function ($rootScope, $scope, $location, aria2SettingService, aria2TaskService) { + var tabOrders = ['download', 'options']; - $scope.startDownload = function () { - var urls = $scope.urls.split('\n'); + $scope.context = { + currentTab: 'download', + urls: '', + globalOptions: null, + availableOptions: [], + options: {} + }; + + $scope.context.availableOptions = (function () { + var keys = aria2SettingService.getNewTaskOptionKeys(); + + return aria2SettingService.getSpecifiedOptions(keys); + })(); + + $rootScope.swipeActions.extentLeftSwipe = function () { + var tabIndex = tabOrders.indexOf($scope.context.currentTab); + + if (tabIndex < tabOrders.length - 1) { + $scope.context.currentTab = tabOrders[tabIndex + 1]; + return true; + } else { + return false; + } + }; + + $rootScope.swipeActions.extentRightSwipe = function () { + var tabIndex = tabOrders.indexOf($scope.context.currentTab); + + if (tabIndex > 0) { + $scope.context.currentTab = tabOrders[tabIndex - 1]; + return true; + } else { + return false; + } + }; + + $scope.loadDefaultOption = function () { + if ($scope.context.globalOptions) { + return; + } + + $rootScope.loadPromise = aria2SettingService.getGlobalOption(function (response) { + if (response.success) { + $scope.context.globalOptions = response.data; + } + }); + }; + + $scope.startDownload = function (pauseOnAdded) { + var urls = $scope.context.urls.split('\n'); + var options = angular.copy($scope.context.options); var tasks = []; + if (pauseOnAdded) { + options.pause = 'true'; + } + for (var i = 0; i < urls.length; i++) { tasks.push({ urls: [urls[i].trim()], - options: $scope.options + options: options }); } @@ -21,8 +73,22 @@ return; } - $location.path('/downloading'); + if (pauseOnAdded) { + $location.path('/waiting'); + } else { + $location.path('/downloading'); + } }); }; + + $scope.setOption = function (key, value, optionStatus) { + if (value != '') { + $scope.context.options[key] = value; + } else { + delete $scope.context.options[key]; + } + + optionStatus.setReady(); + }; }]); })(); diff --git a/app/scripts/directives/setting.js b/app/scripts/directives/setting.js index 1a0a9d8..da13dfa 100644 --- a/app/scripts/directives/setting.js +++ b/app/scripts/directives/setting.js @@ -10,6 +10,7 @@ scope: { option: '=', ngModel: '=', + placeholder: '=?', onChangeValue: '&' }, link: function (scope, element, attrs, ngModel) { @@ -121,11 +122,13 @@ } }; - scope.$watch(function () { - return ngModel.$viewValue; - }, function (value) { - scope.optionValue = value; - }); + if (!angular.isUndefined(ngModel)) { + scope.$watch(function () { + return ngModel.$viewValue; + }, function (value) { + scope.optionValue = value; + }); + } scope.$watch('option', function () { element.find('[data-toggle="popover"]').popover(); diff --git a/app/scripts/services/aria2SettingService.js b/app/scripts/services/aria2SettingService.js index 6fdbf63..d6ca20c 100644 --- a/app/scripts/services/aria2SettingService.js +++ b/app/scripts/services/aria2SettingService.js @@ -63,6 +63,9 @@ return false; } }, + getNewTaskOptionKeys: function (isBittorrent) { + return aria2TaskAvailableOptions.newTaskOptions; + }, getSpecifiedOptions: function (keys, readonly) { var options = []; diff --git a/app/styles/aria-ng.css b/app/styles/aria-ng.css index b867312..012a260 100644 --- a/app/styles/aria-ng.css +++ b/app/styles/aria-ng.css @@ -25,6 +25,11 @@ td { overflow-y: scroll; } +.dropdown-menu.right-align { + left: inherit; + right: 0; +} + .default-cursor { cursor: default !important; } @@ -909,11 +914,6 @@ td { margin-right: 20px; } -.new-task-table .description { - color: #a8a8a8; - margin-left: 5px; -} - @media (max-width: 767px) { .new-task-table .new-task-toollink > a { display: block; diff --git a/app/views/new.html b/app/views/new.html index 68ae590..984b878 100644 --- a/app/views/new.html +++ b/app/views/new.html @@ -1,24 +1,60 @@
-
-
-
-

- Download Links: - Support multiple URLs, one URL per line. -

- +