Merge pull request #49 from cubedro/develop

Fixed block time filters
This commit is contained in:
Marian OANCΞA 2015-04-06 13:50:30 +03:00
commit bb2b46aa1f
3 changed files with 17 additions and 8 deletions

View File

@ -26,6 +26,10 @@ body {
background: #F74B4B; background: #F74B4B;
} }
.text-gray {
color: #777 !important;
}
.container-fluid { .container-fluid {
padding-left: 30px; padding-left: 30px;
padding-right: 30px; padding-right: 30px;

View File

@ -71,15 +71,22 @@ angular.module('netStatsApp.filters', [])
}) })
.filter('timeClass', function() { .filter('timeClass', function() {
return function(timestamp) { return function(timestamp) {
console.log(timestamp);
return timeClass(timestamp); return timeClass(timestamp);
}; };
}) })
.filter('propagationTimeClass', function() { .filter('propagationTimeClass', function() {
return function(propagation) { return function(block, bestBlock) {
if(propagation <= 3000) if(block.number < bestBlock)
return 'text-gray';
if(block.propagation < 1000)
return 'text-success'; return 'text-success';
if(propagation <= 7000) if(block.propagation < 3000)
return 'text-info';
if(block.propagation < 7000)
return 'text-warning'; return 'text-warning';
return 'text-danger' return 'text-danger'
@ -230,9 +237,7 @@ function peerClass(peers)
function timeClass(timestamp) function timeClass(timestamp)
{ {
// var time = Math.floor((new Date()).getTime() / 1000); var diff = ((new Date()).getTime() - timestamp)/1000;
var time = (new Date()).getTime();
var diff = time - timestamp;
return blockTimeClass(diff); return blockTimeClass(diff);
} }

View File

@ -47,7 +47,7 @@ block content
span.big-details {{ lastBlock | blockTimeFilter }} span.big-details {{ lastBlock | blockTimeFilter }}
div.clearfix div.clearfix
div.col-xs-2.stat-holder div.col-xs-2.stat-holder
div.big-info.avgblocktime(class="{{ avgBlockTime | timeClass }}") div.big-info.avgblocktime(class="{{ avgBlockTime | avgTimeClass }}")
div.pull-left.icon-full-width div.pull-left.icon-full-width
i.icon-gas i.icon-gas
div.pull-left div.pull-left
@ -149,5 +149,5 @@ block content
span.small {{node.stats.block.hash}} span.small {{node.stats.block.hash}}
td(style="padding-left: 14px;") {{node.stats.block.transactions.length || 0}} td(style="padding-left: 14px;") {{node.stats.block.transactions.length || 0}}
td(class="{{ node.stats.block.received | timeClass }}") {{node.stats.block.received | blockTimeFilter }} td(class="{{ node.stats.block.received | timeClass }}") {{node.stats.block.received | blockTimeFilter }}
td(class="{{ node.stats.block.propagation | propagationTimeClass }}") {{node.stats.block.propagation | blockPropagationFilter}} td(class="{{ node.stats.block | propagationTimeClass : bestBlock }}") {{node.stats.block.propagation | blockPropagationFilter}}
td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }} td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }}