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/status.js

41 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-05-22 05:47:47 +02:00
(function () {
'use strict';
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 = {
2017-03-19 16:36:14 +01:00
host: ariaNgSettingService.getCurrentRpcUrl(),
status: 'Connecting',
serverStatus: null
2016-06-20 18:20:30 +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') {
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') {
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) {
$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
}());