adding task via command api supports settings options
This commit is contained in:
parent
684dea1b79
commit
2ef2aa3cf5
|
@ -1,10 +1,10 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').controller('CommandController', ['$rootScope', '$window', '$location', '$routeParams', 'base64', 'ariaNgDefaultOptions', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2TaskService', 'ariaNgLogService', function ($rootScope, $window, $location, $routeParams, base64, ariaNgDefaultOptions, ariaNgCommonService, ariaNgSettingService, aria2TaskService, ariaNgLogService) {
|
angular.module('ariaNg').controller('CommandController', ['$rootScope', '$window', '$location', '$routeParams', 'base64', 'ariaNgDefaultOptions', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2SettingService', 'aria2TaskService', 'ariaNgLogService', function ($rootScope, $window, $location, $routeParams, base64, ariaNgDefaultOptions, ariaNgCommonService, ariaNgSettingService, aria2SettingService, aria2TaskService, ariaNgLogService) {
|
||||||
var path = $location.path();
|
var path = $location.path();
|
||||||
|
|
||||||
var doNewTaskCommand = function (url) {
|
var doNewTaskCommand = function (url, params) {
|
||||||
try {
|
try {
|
||||||
url = base64.urldecode(url);
|
url = base64.urldecode(url);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -12,9 +12,23 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var options = {};
|
||||||
|
|
||||||
|
if (params) {
|
||||||
|
for (var key in params) {
|
||||||
|
if (!params.hasOwnProperty(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aria2SettingService.isOptionKeyValid(key)) {
|
||||||
|
options[key] = params[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rootScope.loadPromise = aria2TaskService.newUriTask({
|
$rootScope.loadPromise = aria2TaskService.newUriTask({
|
||||||
urls: [url],
|
urls: [url],
|
||||||
options: {}
|
options: options
|
||||||
}, false, function (response) {
|
}, false, function (response) {
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -81,7 +95,7 @@
|
||||||
|
|
||||||
var doCommand = function (path, params) {
|
var doCommand = function (path, params) {
|
||||||
if (path.indexOf('/new') === 0) {
|
if (path.indexOf('/new') === 0) {
|
||||||
return doNewTaskCommand(params.url);
|
return doNewTaskCommand(params.url, params);
|
||||||
} else if (path.indexOf('/settings/rpc/set') === 0) {
|
} else if (path.indexOf('/settings/rpc/set') === 0) {
|
||||||
return doSetRpcCommand(params.protocol, params.host, params.port, params.interface, params.secret);
|
return doSetRpcCommand(params.protocol, params.host, params.port, params.interface, params.secret);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isOptionKeyValid: function (key) {
|
||||||
|
var option = aria2AllOptions[key];
|
||||||
|
|
||||||
|
return !!option;
|
||||||
|
},
|
||||||
getAvailableGlobalOptionsKeys: function (type) {
|
getAvailableGlobalOptionsKeys: function (type) {
|
||||||
if (type === 'basic') {
|
if (type === 'basic') {
|
||||||
return aria2GlobalAvailableOptions.basicOptions;
|
return aria2GlobalAvailableOptions.basicOptions;
|
||||||
|
|
Reference in a new issue