diff --git a/src/js/filters.js b/src/js/filters.js index a0dc629..08e00b6 100644 --- a/src/js/filters.js +++ b/src/js/filters.js @@ -540,6 +540,39 @@ angular.module('netStatsApp.filters', []) return 'hidden'; }; +}) +.filter('consensusClass', function() { + return function(nodes, bestBlock) { + var status = 'success'; + var now = _.now(); + + for(var x = 0; x < nodes.length; x++) + { + if(nodes[x].stats.block.number === bestBlock.number && nodes[x].stats.block.hash !== bestBlock.hash) + return 'danger'; + + if((bestBlock.number - nodes[x].stats.block.number) > 1 && (now - bestBlock.received) >= 20*1000) + status = 'orange'; + + if((bestBlock.number - nodes[x].stats.block.number) === 1 && (now - bestBlock.received) >= 10*1000 && status !== 'orange') + status = 'warning'; + } + + return status; + }; +}) +.filter('consensusFilter', function() { + return function(nodes, bestBlock) { + var cnt = 0; + + for(var x = 0; x < nodes.length; x++) + { + if(nodes[x].stats.block.number === bestBlock.number && nodes[x].stats.block.hash === bestBlock.hash) + cnt++; + } + + return cnt + '/' + nodes.length; + }; }); function compareVersions(v1, comparator, v2) diff --git a/src/views/index-lite.jade b/src/views/index-lite.jade index abc3f84..0a801b7 100644 --- a/src/views/index-lite.jade +++ b/src/views/index-lite.jade @@ -66,10 +66,10 @@ block content span.small-title active nodes span.small-value {{nodesActive}}/{{nodesTotal}} div.col-xs-3.stat-holder.box - div.gasprice.text-info - i.icon-gasprice - span.small-title gas price - span.small-value {{ bestStats.gasPrice.toString() | gasPriceFilter }} + div.gasprice(class="{{ nodes | consensusClass : bestStats }}") + i.icon-check-o + span.small-title nodes status + span.small-value {{ nodes | consensusFilter : bestStats }} div.col-xs-3.stat-holder.box div.page-latency(class="{{ {active: true, latency: latency} | latencyClass }}") i.icon-clock @@ -122,7 +122,7 @@ block content span.small-title gas spending sparkchart.big-details.spark-gasspending(data="{{gasSpending.join(',')}}") - div.col-xs-4.stat-holder.map-holder + //- div.col-xs-4.stat-holder.map-holder nodemap#mapHolder(data="map") div.row(ng-cloak, style="padding-top: 10px")