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/app/scripts/controllers/settings-aria2.js

37 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-05-17 17:13:47 +02:00
(function () {
'use strict';
2016-06-01 17:31:48 +02:00
angular.module('ariaNg').controller('Aria2SettingsController', ['$rootScope', '$scope', '$location', 'ariaNgConstants', 'ariaNgCommonService', 'aria2SettingService', function ($rootScope, $scope, $location, ariaNgConstants, ariaNgCommonService, aria2SettingService) {
var location = $location.path().substring($location.path().lastIndexOf('/') + 1);
2016-05-31 16:51:12 +02:00
var getAvailableOptions = function (type) {
2016-06-01 18:02:10 +02:00
var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type);
if (!keys) {
2016-05-31 16:51:12 +02:00
ariaNgCommonService.alert('Type is illegal!');
return;
}
2016-05-31 16:51:12 +02:00
return aria2SettingService.getSpecifiedOptions(keys);
};
$scope.availableOptions = getAvailableOptions(location);
2016-05-31 16:51:12 +02:00
2016-06-02 18:16:27 +02:00
$scope.setGlobalOption = function (key, value, optionStatus) {
2016-06-01 17:31:48 +02:00
return aria2SettingService.setGlobalOption(key, value, function (result) {
2016-06-02 18:16:27 +02:00
if (result == 'OK') {
optionStatus.setSuccess();
} else {
optionStatus.setFailed();
}
2016-06-01 17:31:48 +02:00
});
};
2016-05-30 19:26:41 +02:00
$rootScope.loadPromise = (function () {
2016-05-31 16:51:12 +02:00
return aria2SettingService.getGlobalOption(function (result) {
$scope.globalOptions = result;
2016-05-29 07:25:12 +02:00
});
})();
2016-05-17 17:13:47 +02:00
}]);
})();