2016-05-17 17:13:47 +02:00
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
2018-08-12 14:26:26 +02:00
|
|
|
angular.module('ariaNg').controller('Aria2SettingsController', ['$rootScope', '$scope', '$location', 'ariaNgConstants', 'ariaNgLocalizationService', 'aria2SettingService', function ($rootScope, $scope, $location, ariaNgConstants, ariaNgLocalizationService, aria2SettingService) {
|
2016-05-22 19:17:13 +02:00
|
|
|
var location = $location.path().substring($location.path().lastIndexOf('/') + 1);
|
|
|
|
|
2016-06-20 18:20:30 +02:00
|
|
|
$scope.context = {
|
|
|
|
availableOptions: (function (type) {
|
|
|
|
var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type);
|
2016-05-29 11:37:14 +02:00
|
|
|
|
2016-06-20 18:20:30 +02:00
|
|
|
if (!keys) {
|
2018-08-12 14:26:26 +02:00
|
|
|
ariaNgLocalizationService.showError('Type is illegal!');
|
2016-06-20 18:20:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-05-29 11:37:14 +02:00
|
|
|
|
2016-06-20 18:20:30 +02:00
|
|
|
return aria2SettingService.getSpecifiedOptions(keys);
|
|
|
|
})(location),
|
|
|
|
globalOptions: []
|
|
|
|
};
|
2016-05-31 16:51:12 +02:00
|
|
|
|
2016-06-02 18:16:27 +02:00
|
|
|
$scope.setGlobalOption = function (key, value, optionStatus) {
|
2016-06-10 13:23:16 +02:00
|
|
|
return aria2SettingService.setGlobalOption(key, value, function (response) {
|
2016-08-01 16:49:16 +02:00
|
|
|
if (response.success && response.data === 'OK') {
|
2016-06-02 18:16:27 +02:00
|
|
|
optionStatus.setSuccess();
|
|
|
|
} else {
|
2016-06-25 15:48:06 +02:00
|
|
|
optionStatus.setFailed(response.data.message);
|
2016-06-02 18:16:27 +02:00
|
|
|
}
|
2016-06-10 13:23:16 +02:00
|
|
|
}, true);
|
2016-05-22 19:17:13 +02:00
|
|
|
};
|
|
|
|
|
2016-05-30 19:26:41 +02:00
|
|
|
$rootScope.loadPromise = (function () {
|
2016-06-10 13:23:16 +02:00
|
|
|
return aria2SettingService.getGlobalOption(function (response) {
|
|
|
|
if (response.success) {
|
2016-06-20 18:20:30 +02:00
|
|
|
$scope.context.globalOptions = response.data;
|
2016-06-10 13:23:16 +02:00
|
|
|
}
|
2016-05-29 07:25:12 +02:00
|
|
|
});
|
2016-05-22 19:17:13 +02:00
|
|
|
})();
|
2016-05-17 17:13:47 +02:00
|
|
|
}]);
|
2016-08-01 16:49:16 +02:00
|
|
|
}());
|