Status | Added defaulting "Auto Refresh" option for status module (#61)

* auto refreshing option for status

* destroying refresh
pull/37/merge
trashbo4t 2019-07-29 13:48:52 -04:00 committed by Marc
parent 5f662c28c9
commit cb24b654da
3 changed files with 135 additions and 31 deletions

View File

@ -2,6 +2,10 @@ registerController('Status_Controller', ['$api', '$scope', '$rootScope', '$inter
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.autoRefresh = true;
$rootScope.autoRefresh = true;
$rootScope.version = "Loading...";
$scope.refreshInfo = (function() {
$api.request({
module: 'Status',
@ -14,9 +18,13 @@ registerController('Status_Controller', ['$api', '$scope', '$rootScope', '$inter
$scope.refreshInfo();
$scope.toggleAutoRefresh = function() {
$rootScope.autoRefresh = $scope.autoRefresh;
};
}]);
registerController('Status_SystemController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
registerController('Status_SystemController', ['$api', '$scope', '$rootScope', '$interval', '$filter', function($api, $scope, $rootScope, $interval, $filter) {
$scope.info = {
machine: "Loading...",
currentTime: "Loading...",
@ -34,10 +42,19 @@ registerController('Status_SystemController', ['$api', '$scope', '$rootScope', '
};
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 1000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_CPUController', ['$api', '$scope', '$rootScope', '$filter', '$sce', function($api, $scope, $rootScope, $filter, $sce) {
registerController('Status_CPUController', ['$api', '$scope', '$rootScope', '$interval', '$filter', '$sce', function($api, $scope, $rootScope, $interval, $filter, $sce) {
$scope.info = {
cpuModel: "Loading...",
bogoMIPS: "Loading...",
@ -55,7 +72,7 @@ registerController('Status_CPUController', ['$api', '$scope', '$rootScope', '$fi
});
};
$scope.getSrc = (function() {
$scope.getSrc = (function() {
$scope.src = $sce.trustAsResourceUrl('/modules/Status/svg/graph_cpu.svg');
});
@ -64,11 +81,21 @@ registerController('Status_CPUController', ['$api', '$scope', '$rootScope', '$fi
});
$scope.setSrc();
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 2000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$interval', '$filter', function($api, $scope, $rootScope, $interval, $filter) {
$scope.info = {
clientsList: []
};
@ -76,11 +103,9 @@ registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$f
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.loading = false;
$scope.loading = true;
$scope.getInfo = function() {
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getDHCP'
@ -119,10 +144,20 @@ registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$f
};
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 5000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_MemoryController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
registerController('Status_MemoryController', ['$api', '$scope', '$rootScope', '$interval', '$filter', function($api, $scope, $rootScope, $interval, $filter) {
$scope.info = {
memoryTotal: "Loading...",
memoryFree: "Loading...",
@ -141,20 +176,28 @@ registerController('Status_MemoryController', ['$api', '$scope', '$rootScope', '
};
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 2000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_WiFiController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
registerController('Status_WiFiController', ['$api', '$scope', '$rootScope', '$interval', '$filter', function($api, $scope, $rootScope, $interval, $filter) {
$scope.info = {
wifiClientsList: []
};
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.loading = false;
$scope.loading = true;
$scope.getInfo = function() {
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getWiFi'
@ -193,10 +236,20 @@ registerController('Status_WiFiController', ['$api', '$scope', '$rootScope', '$f
};
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 5000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_SwapController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
registerController('Status_SwapController', ['$api', '$scope', '$rootScope', '$interval', '$filter', function($api, $scope, $rootScope, $interval, $filter) {
$scope.info = {
swapAvailable: false,
swapTotal: "Loading...",
@ -216,19 +269,27 @@ registerController('Status_SwapController', ['$api', '$scope', '$rootScope', '$f
};
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 2000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_StorageController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
registerController('Status_StorageController', ['$api', '$scope', '$rootScope', '$interval', '$filter', function($api, $scope, $rootScope, $interval, $filter) {
$scope.info = {
storagesList: []
};
$scope.loading = false;
$scope.loading = true;
$scope.getInfo = function() {
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getStorage'
@ -239,10 +300,20 @@ registerController('Status_StorageController', ['$api', '$scope', '$rootScope',
};
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 10000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);
registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope', '$filter', '$sce', function($api, $scope, $rootScope, $filter, $sce) {
registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope', '$interval', '$filter', '$sce', function($api, $scope, $rootScope, $interval, $filter, $sce) {
$scope.info = {
wanIpAddress: "Loading...",
wanGateway: "Loading...",
@ -253,7 +324,7 @@ registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope'
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.loading = false;
$scope.loading = true;
$scope.getMACInfo = function(param) {
$scope.title = "Loading...";
@ -284,8 +355,6 @@ registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope'
};
$scope.getInfo = function() {
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getInterfaces'
@ -306,5 +375,15 @@ registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope'
$scope.setSrc();
$scope.getInfo();
$scope.statusRefreshInterval = $interval(function() {
if ($rootScope.autoRefresh)
{
$scope.getInfo();
}
}, 10000);
$scope.$on('$destroy', function() {
$interval.cancel($scope.statusRefreshInterval);
});
}]);

View File

@ -1,11 +1,36 @@
<div class="panel panel-default" ng-controller="Status_Controller"><div class="panel-heading"><h4 class="panel-title pull-left">{{title}}</h4><span class="pull-right">{{version}}</span><div class="clearfix"></div></div></div>
<div class="panel panel-default" ng-controller="Status_Controller">
<div class="panel-heading">
<h4 class="panel-title pull-left">{{title}}</h4>
<span class="pull-right">{{version}}</span>
<div class="clearfix">
</div>
<table style="width:10%">
<tr>
<td>
Auto Refresh
</td>
<td>
<label class="switch" >
<input type="checkbox" class="btn btn-info pull-right btn-xs" ng-model="autoRefresh" ng-click="toggleAutoRefresh()" Auto Refresh />
<span class="slider round">
</span>
</label>
</td>
</tr>
<tr>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-md-6" ng-controller="Status_SystemController">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">System</h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">
@ -42,7 +67,7 @@
<h4 class="panel-title pull-left">CPU</h4>
<div class="btn-group pull-right">
<button type="button" class="btn btn-default btn-xs" ng-click="getSrc()" data-toggle="modal" data-target="#CPUModal">Graph</button>
<button type="button" class="btn btn-info btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
</div>
<div class="clearfix"></div>
</div>
@ -106,7 +131,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">Memory</h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">
@ -148,7 +173,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">Swap</h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">
@ -200,7 +225,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">WiFi Clients <span class="badge">{{info.wifiClientsList.length}}</span></h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">
@ -246,7 +271,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">DHCP Clients <span class="badge">{{info.clientsList.length}}</span></h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">
@ -295,7 +320,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">Storage</h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">
@ -325,7 +350,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title pull-left">Interfaces</h4>
<button type="button" class="btn btn-info pull-right btn-xs" ng-click="getInfo()">Refresh</button>
<button type="button" class="btn btn-info pull-right btn-xs" ng-disabled="autoRefresh" ng-click="getInfo()">Refresh</button>
<div class="clearfix"></div>
</div>
<div class="panel-body">

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Status",
"version": "1.3"
"version": "1.4"
}