This repository has been archived on 2022-01-02. You can view files and clone it, but cannot push or open issues/pull-requests.
AriaNg/app/scripts/controllers/main.js

34 lines
1.1 KiB
JavaScript

(function () {
'use strict';
angular.module('ariaNg').controller('MainController', ['$scope', '$interval', 'aria2RpcService', 'ariaNgSettingService', function ($scope, $interval, aria2RpcService, ariaNgSettingService) {
var processStatResult = function (stat) {
var activeCount = parseInt(stat.numActive);
var waitingCount = parseInt(stat.numWaiting);
var totalRunningCount = activeCount + waitingCount;
stat.totalRunningCount = totalRunningCount;
};
$scope.changeDisplayOrder = function (type) {
ariaNgSettingService.setDisplayOrder(type);
};
$scope.isSetDisplayOrder = function (type) {
return ariaNgSettingService.getDisplayOrder() === type;
};
$interval(function () {
aria2RpcService.getGlobalStat({
callback: function (result) {
if (result) {
processStatResult(result);
}
$scope.globalStat = result;
}
});
}, ariaNgSettingService.getGlobalStatRefreshInterval());
}]);
})();