command api supports parsing parameters from query string

This commit is contained in:
MaysWind 2017-10-14 20:08:07 +08:00
parent 6ea534e6d6
commit 1874017765
2 changed files with 9 additions and 3 deletions

View file

@ -80,9 +80,9 @@
}; };
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);
} 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 {
ariaNgCommonService.showError('Parameter is invalid!'); ariaNgCommonService.showError('Parameter is invalid!');
@ -90,7 +90,9 @@
} }
}; };
if (!doCommand(path, $routeParams)) { var allParameters = angular.extend({}, $routeParams, $location.search());
if (!doCommand(path, allParameters)) {
$location.path('/downloading'); $location.path('/downloading');
} }
}]); }]);

View file

@ -67,6 +67,10 @@
templateUrl: 'views/settings-aria2.html', templateUrl: 'views/settings-aria2.html',
controller: 'Aria2SettingsController' controller: 'Aria2SettingsController'
}) })
.when('/settings/rpc/set', {
template: '',
controller: 'CommandController'
})
.when('/settings/rpc/set/:protocol/:host/:port/:interface/:secret?', { .when('/settings/rpc/set/:protocol/:host/:port/:interface/:secret?', {
template: '', template: '',
controller: 'CommandController' controller: 'CommandController'