2016-05-22 05:47:47 +02:00
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
2016-08-28 15:47:29 +02:00
|
|
|
angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2SettingService', function ($rootScope, $scope, ariaNgCommonService, ariaNgSettingService, aria2SettingService) {
|
2016-06-20 18:20:30 +02:00
|
|
|
$scope.context = {
|
2016-08-28 15:47:29 +02:00
|
|
|
host: ariaNgSettingService.getJsonRpcUrl(),
|
|
|
|
status: 'Connecting',
|
|
|
|
serverStatus: null
|
2016-06-20 18:20:30 +02:00
|
|
|
};
|
|
|
|
|
2016-06-05 18:01:11 +02:00
|
|
|
$scope.saveSession = function () {
|
2016-06-10 13:23:16 +02:00
|
|
|
return aria2SettingService.saveSession(function (response) {
|
2016-08-01 16:49:16 +02:00
|
|
|
if (response.success && response.data === 'OK') {
|
2016-06-05 18:01:11 +02:00
|
|
|
ariaNgCommonService.showOperationSucceeded('Session has been saved successfully.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.shutdown = function () {
|
|
|
|
ariaNgCommonService.confirm('Confirm Shutdown', 'Are you sure you want to shutdown aria2?', 'warning', function (status) {
|
2016-06-10 13:23:16 +02:00
|
|
|
return aria2SettingService.shutdown(function (response) {
|
2016-08-01 16:49:16 +02:00
|
|
|
if (response.success && response.data === 'OK') {
|
2016-06-05 18:01:11 +02:00
|
|
|
ariaNgCommonService.showOperationSucceeded('Aria2 has been shutdown successfully.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, true);
|
|
|
|
};
|
2016-06-10 13:23:16 +02:00
|
|
|
|
|
|
|
$rootScope.loadPromise = (function () {
|
|
|
|
return aria2SettingService.getAria2Status(function (response) {
|
|
|
|
if (response.success) {
|
2016-08-28 15:47:29 +02:00
|
|
|
$scope.context.status = 'Connected';
|
|
|
|
$scope.context.serverStatus = response.data;
|
|
|
|
} else {
|
|
|
|
$scope.context.status = 'Not Connected';
|
2016-06-10 13:23:16 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
2016-05-22 05:47:47 +02:00
|
|
|
}]);
|
2016-08-01 16:49:16 +02:00
|
|
|
}());
|