added uptime functionality

This commit is contained in:
Marian Oancea
2015-02-05 13:05:21 +02:00
parent 281a5d7f5b
commit 71ae336715
4 changed files with 31 additions and 4 deletions

View File

@@ -25,5 +25,6 @@ function StatsCtrl($scope, socket, _) {
$scope.nodesActive = _.filter($scope.nodes, function(node){ return node.stats.active == true; }).length;
$scope.bestBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.height); }).stats.block.height;
$scope.lastBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.timestamp); }).stats.block.timestamp;
$scope.upTimeTotal = _.reduce($scope.nodes, function(total, node){ return total + node.stats.uptime.total; }, 0) / $scope.nodes.length;
}
}

View File

@@ -54,7 +54,24 @@ angular.module('netStatsApp.filters', [])
return function(timestamp) {
return timeClass(timestamp);
};
}).filter('geoTooltip', function() {
})
.filter('upTimeFilter', function() {
return function(uptime) {
return Math.round(uptime) + '%';
};
})
.filter('upTimeClass', function() {
return function(uptime) {
if(uptime >= 90)
return 'text-success';
if(uptime >= 75)
return 'text-warning';
return 'text-danger';
};
})
.filter('geoTooltip', function() {
return function(geo) {
return geo.city + ", " + geo.country;
};