diff --git a/app/index.html b/app/index.html index 192becb..4a4b546 100644 --- a/app/index.html +++ b/app/index.html @@ -37,8 +37,8 @@ - - + + New @@ -280,6 +280,7 @@ + diff --git a/app/langs/zh_CN.json b/app/langs/zh_CN.json index 953f81c..31273c4 100644 --- a/app/langs/zh_CN.json +++ b/app/langs/zh_CN.json @@ -74,6 +74,11 @@ "Failed to remove some task(s).": "删除一些任务时失败.", "Confirm Clear": "确认清除", "Are you sure you want to clear stopped tasks?": "您是否要清除已结束的任务?", + "Download Links:": "下载链接:", + "Start Download": "立即下载", + "Open Torrent File": "打开种子文件", + "Open Metalink File": "打开 Metalink 文件", + "Support multiple URLs, one URL per line.": "支持多个 URL 地址, 每个地址占一行.", "Language": "语言", "Aria2 RPC Host": "Aria2 RPC 主机", "Aria2 RPC Port": "Aria2 RPC 端口", diff --git a/app/scripts/config/defaultLanguage.js b/app/scripts/config/defaultLanguage.js index abb69d8..f3af1c1 100644 --- a/app/scripts/config/defaultLanguage.js +++ b/app/scripts/config/defaultLanguage.js @@ -78,6 +78,11 @@ 'Failed to remove some task(s).': 'Failed to remove some task(s).', 'Confirm Clear': 'Confirm Clear', 'Are you sure you want to clear stopped tasks?': 'Are you sure you want to clear stopped tasks?', + 'Download Links:': 'Download Links:', + 'Open Torrent File': 'Open Torrent File', + 'Open Metalink File': 'Open Metalink File', + 'Start Download': 'Start Download', + 'Support multiple URLs, one URL per line.': 'Support multiple URLs, one URL per line.', '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 new file mode 100644 index 0000000..d96e8a1 --- /dev/null +++ b/app/scripts/controllers/new.js @@ -0,0 +1,28 @@ +(function () { + 'use strict'; + + angular.module('ariaNg').controller('NewTaskController', ['$rootScope', '$scope', '$location', 'ariaNgCommonService', 'aria2TaskService', function ($rootScope, $scope, $location, ariaNgCommonService, aria2TaskService) { + $scope.urls = ''; + $scope.options = {}; + + $scope.startDownload = function () { + var urls = $scope.urls.split('\n'); + var tasks = []; + + for (var i = 0; i < urls.length; i++) { + tasks.push({ + urls: [urls[i].trim()], + options: $scope.options + }); + } + + $rootScope.loadPromise = aria2TaskService.newUriTasks(tasks, function (response) { + if (!response.hasSuccess) { + return; + } + + $location.path('/downloading'); + }); + }; + }]); +})(); diff --git a/app/scripts/core/router.js b/app/scripts/core/router.js index 7726715..42691ea 100644 --- a/app/scripts/core/router.js +++ b/app/scripts/core/router.js @@ -15,6 +15,10 @@ templateUrl: 'views/list.html', controller: 'DownloadListController' }) + .when('/new', { + templateUrl: 'views/new.html', + controller: 'NewTaskController' + }) .when('/task/detail/:gid', { templateUrl: 'views/task-detail.html', controller: 'TaskDetailController' diff --git a/app/scripts/services/aria2RpcService.js b/app/scripts/services/aria2RpcService.js index 62e4fcd..3fd098e 100644 --- a/app/scripts/services/aria2RpcService.js +++ b/app/scripts/services/aria2RpcService.js @@ -161,9 +161,22 @@ return requestParams; }, - // addUri: function (context) { - // return invoke('addUri', context); - // }, + addUri: function (context) { + return invoke(buildRequestContext('addUri', context, context.urls, context.options)); + }, + addUriMulti: function (context) { + var contexts = []; + + for (var i = 0; i < context.tasks.length; i++) { + contexts.push({ + silent: !!context.silent, + urls: context.tasks[i].urls, + options: context.tasks[i].options + }); + } + + return invokeMulti(this.addUri, contexts, context.callback); + }, // addTorrent: function (context) { // return invoke('addTorrent', context); // }, diff --git a/app/scripts/services/aria2TaskService.js b/app/scripts/services/aria2TaskService.js index 5583c16..d533355 100644 --- a/app/scripts/services/aria2TaskService.js +++ b/app/scripts/services/aria2TaskService.js @@ -248,6 +248,13 @@ } }); }, + newUriTasks: function (tasks, callback, silent) { + return aria2RpcService.addUriMulti({ + tasks: tasks, + silent: !!silent, + callback: callback + }); + }, startTasks: function (gids, callback, silent) { return aria2RpcService.unpauseMulti({ gids: gids, diff --git a/app/styles/aria-ng.css b/app/styles/aria-ng.css index bed2d1a..5f9b564 100644 --- a/app/styles/aria-ng.css +++ b/app/styles/aria-ng.css @@ -876,4 +876,38 @@ td { } } +/* new-task-table */ +.new-task-table { + margin-left: 15px; + margin-right: 15px; +} + +.skin-aria-ng .new-task-table { + background-color: #fff; +} + +.new-task-table > div.row { + padding-top: 8px; + padding-bottom: 8px; +} + +.new-task-table > div.row:first-child { + border-top: inherit; +} + +.new-task-table .new-task-toollink > a { + 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; + } +} + /* miscellaneous */ diff --git a/app/views/new.html b/app/views/new.html new file mode 100644 index 0000000..68ae590 --- /dev/null +++ b/app/views/new.html @@ -0,0 +1,26 @@ + + + + + + Download Links: + Support multiple URLs, one URL per line. + + + + + + + + Open Torrent File + Open Metalink File + + + + + Start Download + + + + +
+ Download Links: + Support multiple URLs, one URL per line. +