fixed times

This commit is contained in:
cubedro 2015-02-18 11:10:33 +02:00
parent 21a598bd7a
commit 469adc33b2
3 changed files with 14 additions and 5 deletions

View File

@ -117,7 +117,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
$scope.lastBlock = _.max($scope.nodes, function(node) {
return parseInt(node.stats.block.timestamp);
}).stats.block.blocktime;
}).stats.block.timestamp;
$scope.lastDifficulty = _.max($scope.nodes, function(node) {
return parseInt(node.stats.block.timestamp);

View File

@ -66,14 +66,23 @@ angular.module('netStatsApp.filters', [])
};
})
.filter('blockTimeFilter', function() {
return function(time) {
if(time === 0)
return function(timestamp) {
var time = Math.floor((new Date()).getTime() / 1000);
var diff = time - timestamp;
if(diff === 0)
return '∞';
return moment.duration(Math.round(time), 's').humanize() + ' ago';
if(diff < 60)
return Math.round(diff) + ' s';
return moment.duration(Math.round(diff), 's').humanize() + ' ago';
};
}).filter('avgTimeFilter', function() {
return function(time) {
if(time < 60)
return Math.round(time) + ' s';
return moment.duration(Math.round(time), 's').humanize();
};
})

View File

@ -103,5 +103,5 @@ block content
td(class="{{ node.stats.block.number | blockClass : bestBlock }}").hidden-sm.hidden-xs
span.small {{node.stats.block.hash}}
//- div.small Difficulty: {{node.stats.block.difficulty | gasFilter}} | Gas used: {{node.stats.block.gasUsed | gasFilter}} | Min gas price: {{node.stats.block.minGasPrice | gasFilter}} | Gas limit: {{node.stats.block.gasLimit | gasFilter}}
td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.blocktime | blockTimeFilter }}
td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.timestamp | blockTimeFilter }}
td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }}