fixes to filters

This commit is contained in:
Marian Oancea 2015-02-05 06:32:42 +02:00
parent 7d4ebe6cf1
commit 297240b591
2 changed files with 44 additions and 33 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.apply();
}
}

View File

@ -27,12 +27,12 @@ angular.module('netStatsApp.filters', [])
if(node.peers === 0)
return 'text-danger';
return (node.peers <= 1 ? 'text-danger' : (node.peers > 1 && node.peers < 4 ? 'text-warning' : 'text-success'));
return timeClass(node.block.timestamp);
};
})
.filter('peerClass', function() {
return function(peers) {
return (peers <= 1 ? 'text-danger' : (peers > 1 && peers < 4 ? 'text-warning' : 'text-success'));
return peerClass(peers);
};
})
.filter('miningClass', function() {
@ -52,6 +52,17 @@ angular.module('netStatsApp.filters', [])
})
.filter('timeClass', function() {
return function(timestamp) {
return timeClass(timestamp);
};
});
function peerClass(peers)
{
return (peers <= 1 ? 'text-danger' : (peers > 1 && peers < 4 ? 'text-warning' : 'text-success'));
}
function timeClass(timestamp)
{
var time = Math.floor((new Date()).getTime() / 1000);
var diff = time - timestamp;
@ -65,5 +76,4 @@ angular.module('netStatsApp.filters', [])
return 'text-warning';
return 'text-danger';
};
});
}