Skip to content

Commit

Permalink
command api supports parsing parameters from query string
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Oct 14, 2017
1 parent 6ea534e commit 1874017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/scripts/controllers/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,19 @@
};

var doCommand = function (path, params) {
if (path.indexOf('/new/') === 0) {
if (path.indexOf('/new') === 0) {
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);
} else {
ariaNgCommonService.showError('Parameter is invalid!');
return false;
}
};

if (!doCommand(path, $routeParams)) {
var allParameters = angular.extend({}, $routeParams, $location.search());

if (!doCommand(path, allParameters)) {
$location.path('/downloading');
}
}]);
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/core/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
templateUrl: 'views/settings-aria2.html',
controller: 'Aria2SettingsController'
})
.when('/settings/rpc/set', {
template: '',
controller: 'CommandController'
})
.when('/settings/rpc/set/:protocol/:host/:port/:interface/:secret?', {
template: '',
controller: 'CommandController'
Expand Down

0 comments on commit 1874017

Please sign in to comment.