support add task by url
This commit is contained in:
parent
c26034f7ab
commit
8abdc4c75e
|
@ -281,6 +281,7 @@
|
|||
<script src="scripts/config/defaultLanguage.js"></script>
|
||||
<script src="scripts/config/aria2Options.js"></script>
|
||||
<script src="scripts/config/aria2RpcConstants.js"></script>
|
||||
<script src="scripts/controllers/command.js"></script>
|
||||
<script src="scripts/controllers/main.js"></script>
|
||||
<script src="scripts/controllers/new.js"></script>
|
||||
<script src="scripts/controllers/list.js"></script>
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
"Disabled": "禁用",
|
||||
"Changes to the settings take effect after refreshing page.": "设置将在页面刷新后生效.",
|
||||
"Type is illegal!": "类型错误!",
|
||||
"Parameter is invalid!": "请求参数无效",
|
||||
"format": {
|
||||
"longdate": "YYYY年MM月DD日 HH:mm:ss",
|
||||
"time.millisecond": "{{value}} 毫秒",
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
'Disabled': 'Disabled',
|
||||
'Changes to the settings take effect after refreshing page.': 'Changes to the settings take effect after refreshing page.',
|
||||
'Type is illegal!': 'Type is illegal!',
|
||||
'Parameter is invalid!': 'Parameter is invalid!',
|
||||
'format': {
|
||||
'longdate': 'MM/DD/YYYY HH:mm:ss',
|
||||
'time.millisecond': '{{value}} Millisecond',
|
||||
|
|
28
src/scripts/controllers/command.js
Normal file
28
src/scripts/controllers/command.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').controller('CommandController', ['$rootScope', '$location', '$routeParams', 'base64', 'ariaNgCommonService', 'aria2TaskService', function ($rootScope, $location, $routeParams, base64, ariaNgCommonService, aria2TaskService) {
|
||||
var path = $location.path();
|
||||
|
||||
var newUrlDownload = function (url) {
|
||||
return aria2TaskService.newUriTask({
|
||||
urls: [url],
|
||||
options: {}
|
||||
}, false, function (response) {
|
||||
if (!response.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
$location.path('/downloading');
|
||||
});
|
||||
};
|
||||
|
||||
if (path.indexOf('/new/') == 0) {
|
||||
var base64Url = $routeParams.url;
|
||||
var url = base64.urldecode(base64Url);
|
||||
$rootScope.loadPromise = newUrlDownload(url);
|
||||
} else {
|
||||
ariaNgCommonService.error('Parameter is invalid!');
|
||||
}
|
||||
}]);
|
||||
})();
|
|
@ -19,6 +19,10 @@
|
|||
templateUrl: 'views/new.html',
|
||||
controller: 'NewTaskController'
|
||||
})
|
||||
.when('/new/:url', {
|
||||
template: '',
|
||||
controller: 'CommandController'
|
||||
})
|
||||
.when('/task/detail/:gid', {
|
||||
templateUrl: 'views/task-detail.html',
|
||||
controller: 'TaskDetailController'
|
||||
|
|
|
@ -164,23 +164,25 @@
|
|||
return requestParams;
|
||||
},
|
||||
addUri: function (context) {
|
||||
return invoke(buildRequestContext('addUri', context, context.urls, context.options));
|
||||
var urls = context.task.urls;
|
||||
var options = angular.copy(context.task.options);
|
||||
|
||||
if (context.pauseOnAdded) {
|
||||
options.pause = 'true';
|
||||
}
|
||||
|
||||
return invoke(buildRequestContext('addUri', context, urls, options));
|
||||
},
|
||||
addUriMulti: function (context) {
|
||||
var contexts = [];
|
||||
|
||||
for (var i = 0; i < context.tasks.length; i++) {
|
||||
var task = context.tasks[i];
|
||||
var options = angular.copy(task.options);
|
||||
|
||||
if (context.pauseOnAdded) {
|
||||
options.pause = 'true';
|
||||
}
|
||||
|
||||
contexts.push({
|
||||
silent: !!context.silent,
|
||||
urls: task.urls,
|
||||
options: options
|
||||
task: task,
|
||||
pauseOnAdded: context.pauseOnAdded
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -258,6 +258,14 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
newUriTask: function (task, pauseOnAdded, callback, silent) {
|
||||
return aria2RpcService.addUri({
|
||||
task: task,
|
||||
pauseOnAdded: !!pauseOnAdded,
|
||||
silent: !!silent,
|
||||
callback: callback
|
||||
});
|
||||
},
|
||||
newUriTasks: function (tasks, pauseOnAdded, callback, silent) {
|
||||
return aria2RpcService.addUriMulti({
|
||||
tasks: tasks,
|
||||
|
|
Reference in a new issue