This repository has been archived on 2022-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
AriaNg/src/scripts/controllers/command.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-06-25 13:47:02 +02:00
(function () {
'use strict';
2016-12-10 18:01:28 +01:00
angular.module('ariaNg').controller('CommandController', ['$rootScope', '$location', '$routeParams', 'base64', 'ariaNgCommonService', 'aria2TaskService', 'ariaNgLogService', function ($rootScope, $location, $routeParams, base64, ariaNgCommonService, aria2TaskService, ariaNgLogService) {
2016-06-25 13:47:02 +02:00
var path = $location.path();
var newUrlDownload = function (url) {
return aria2TaskService.newUriTask({
urls: [url],
options: {}
}, false, function (response) {
if (!response.success) {
return;
}
$location.path('/downloading');
});
};
2016-08-01 16:49:16 +02:00
if (path.indexOf('/new/') === 0) {
2016-06-25 13:47:02 +02:00
var base64Url = $routeParams.url;
var url = base64.urldecode(base64Url);
$rootScope.loadPromise = newUrlDownload(url);
2016-12-10 18:50:25 +01:00
ariaNgLogService.info('[CommandController] new download: ' + url);
2016-06-25 13:47:02 +02:00
} else {
ariaNgCommonService.error('Parameter is invalid!');
}
}]);
2016-08-01 16:49:16 +02:00
}());