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
2016-06-03 00:16:27 +08:00

37 lines
1.3 KiB
JavaScript

(function () {
'use strict';
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);
var getAvailableOptions = function (type) {
var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type);
if (!keys) {
ariaNgCommonService.alert('Type is illegal!');
return;
}
return aria2SettingService.getSpecifiedOptions(keys);
};
$scope.availableOptions = getAvailableOptions(location);
$scope.setGlobalOption = function (key, value, optionStatus) {
return aria2SettingService.setGlobalOption(key, value, function (result) {
if (result == 'OK') {
optionStatus.setSuccess();
} else {
optionStatus.setFailed();
}
});
};
$rootScope.loadPromise = (function () {
return aria2SettingService.getGlobalOption(function (result) {
$scope.globalOptions = result;
});
})();
}]);
})();