support start new download by link

This commit is contained in:
MaysWind 2016-06-19 00:11:19 +08:00
parent a80546cc00
commit 12b52d74f5
9 changed files with 128 additions and 5 deletions

View file

@ -37,8 +37,8 @@
<nav class="navbar navbar-static-top" role="navigation"> <nav class="navbar navbar-static-top" role="navigation">
<div class="navbar-toolbar"> <div class="navbar-toolbar">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="disabled"> <li>
<a class="toolbar" title="{{'New' | translate}}"> <a class="toolbar" title="{{'New' | translate}}" ng-href="#/new">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
<span translate>New</span> <span translate>New</span>
</a> </a>
@ -280,6 +280,7 @@
<script src="scripts/config/aria2Options.js"></script> <script src="scripts/config/aria2Options.js"></script>
<script src="scripts/config/aria2RpcConstants.js"></script> <script src="scripts/config/aria2RpcConstants.js"></script>
<script src="scripts/controllers/main.js"></script> <script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/new.js"></script>
<script src="scripts/controllers/list.js"></script> <script src="scripts/controllers/list.js"></script>
<script src="scripts/controllers/task-detail.js"></script> <script src="scripts/controllers/task-detail.js"></script>
<script src="scripts/controllers/settings-ariang.js"></script> <script src="scripts/controllers/settings-ariang.js"></script>

View file

@ -74,6 +74,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:": "下载链接:",
"Start Download": "立即下载",
"Open Torrent File": "打开种子文件",
"Open Metalink File": "打开 Metalink 文件",
"Support multiple URLs, one URL per line.": "支持多个 URL 地址, 每个地址占一行.",
"Language": "语言", "Language": "语言",
"Aria2 RPC Host": "Aria2 RPC 主机", "Aria2 RPC Host": "Aria2 RPC 主机",
"Aria2 RPC Port": "Aria2 RPC 端口", "Aria2 RPC Port": "Aria2 RPC 端口",

View file

@ -78,6 +78,11 @@
'Failed to remove some task(s).': 'Failed to remove some task(s).', 'Failed to remove some task(s).': 'Failed to remove some task(s).',
'Confirm Clear': 'Confirm Clear', 'Confirm Clear': 'Confirm Clear',
'Are you sure you want to clear stopped tasks?': 'Are you sure you want to clear stopped tasks?', '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', 'Language': 'Language',
'Aria2 RPC Host': 'Aria2 RPC Host', 'Aria2 RPC Host': 'Aria2 RPC Host',
'Aria2 RPC Port': 'Aria2 RPC Port', 'Aria2 RPC Port': 'Aria2 RPC Port',

View file

@ -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');
});
};
}]);
})();

View file

@ -15,6 +15,10 @@
templateUrl: 'views/list.html', templateUrl: 'views/list.html',
controller: 'DownloadListController' controller: 'DownloadListController'
}) })
.when('/new', {
templateUrl: 'views/new.html',
controller: 'NewTaskController'
})
.when('/task/detail/:gid', { .when('/task/detail/:gid', {
templateUrl: 'views/task-detail.html', templateUrl: 'views/task-detail.html',
controller: 'TaskDetailController' controller: 'TaskDetailController'

View file

@ -161,9 +161,22 @@
return requestParams; return requestParams;
}, },
// addUri: function (context) { addUri: function (context) {
// return invoke('addUri', 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) { // addTorrent: function (context) {
// return invoke('addTorrent', context); // return invoke('addTorrent', context);
// }, // },

View file

@ -248,6 +248,13 @@
} }
}); });
}, },
newUriTasks: function (tasks, callback, silent) {
return aria2RpcService.addUriMulti({
tasks: tasks,
silent: !!silent,
callback: callback
});
},
startTasks: function (gids, callback, silent) { startTasks: function (gids, callback, silent) {
return aria2RpcService.unpauseMulti({ return aria2RpcService.unpauseMulti({
gids: gids, gids: gids,

View file

@ -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 */ /* miscellaneous */

26
app/views/new.html Normal file
View file

@ -0,0 +1,26 @@
<section class="content no-padding">
<div class="new-task-table">
<div class="row">
<div class="col-sm-12">
<p>
<span translate>Download Links:</span>
<small class="description inline" translate>Support multiple URLs, one URL per line.</small>
</p>
<textarea class="form-control" rows="8" ng-model="urls"></textarea>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="new-task-toollink hide">
<a class="pointer-cursor" translate>Open Torrent File</a>
<a class="pointer-cursor" translate>Open Metalink File</a>
</div>
</div>
<div class="col-xs-6">
<div class="pull-right">
<button class="btn btn-sm btn-default" ng-disabled="urls == ''" ng-click="startDownload()" translate>Start Download</button>
</div>
</div>
</div>
</div>
</section>