fixed blocktime and blocktimeAvg

This commit is contained in:
cubedro 2015-02-18 10:57:45 +02:00
parent ddd31a5354
commit e6e87fc216
4 changed files with 29 additions and 14 deletions

View File

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

View File

@ -44,7 +44,9 @@ angular.module('netStatsApp.filters', [])
version = version.replace('eth version ', 'v') version = version.replace('eth version ', 'v')
.replace("\n" + 'Network protocol version: ', ' (') .replace("\n" + 'Network protocol version: ', ' (')
.replace("\n" + 'Client database version: ', ',') .replace("\n" + 'Client database version: ', ',')
.replace("\n" + 'Build: ', ') - '); .replace("\n" + 'Build: ', ') - ')
.replace('/Debug', '')
.replace('/.', '');
return $sce.trustAsHtml(version); return $sce.trustAsHtml(version);
}; };
}) })
@ -63,9 +65,16 @@ angular.module('netStatsApp.filters', [])
return timeClass(timestamp); return timeClass(timestamp);
}; };
}) })
.filter('avgTimeFilter', function() { .filter('blockTimeFilter', function() {
return function(time) { return function(time) {
return Math.round(time) + 's'; if(time === 0)
return '∞';
return moment.duration(Math.round(time), 's').humanize() + ' ago';
};
}).filter('avgTimeFilter', function() {
return function(time) {
return moment.duration(Math.round(time), 's').humanize();
}; };
}) })
.filter('avgTimeClass', function() { .filter('avgTimeClass', function() {

View File

@ -3,5 +3,11 @@
$(this).tooltip('show'); $(this).tooltip('show');
}).on('mouseleave', '[data-toggle="tooltip"]', function( event ) { }).on('mouseleave', '[data-toggle="tooltip"]', function( event ) {
$(this).tooltip('hide'); $(this).tooltip('hide');
}) });
moment.relativeTimeTreshold('s', 60);
moment.relativeTimeTreshold('m', 60);
moment.relativeTimeTreshold('h', 24);
moment.relativeTimeTreshold('d', 28);
moment.relativeTimeTreshold('M', 12);
})(); })();

View File

@ -3,7 +3,7 @@ extends layout
block content block content
div.container-fluid(ng-controller='StatsCtrl') div.container-fluid(ng-controller='StatsCtrl')
div.row div.row
div.col-lg-8(ng-cloak) div.col-lg-7(ng-cloak)
div.col-sm-12 div.col-sm-12
h1= title h1= title
//- p Welcome to #{title} //- p Welcome to #{title}
@ -48,7 +48,7 @@ block content
i.icon-time i.icon-time
div.pull-left div.pull-left
span.small-title last block span.small-title last block
span.big-details(am-time-ago="lastBlock", am-preprocess="unix") ∞ span.big-details {{ lastBlock | blockTimeFilter }}
div.clearfix div.clearfix
div.col-xs-4.stat-holder div.col-xs-4.stat-holder
div.row.big-info.avgblocktime(class="{{ avgBlockTime | timeClass }}") div.row.big-info.avgblocktime(class="{{ avgBlockTime | timeClass }}")
@ -61,7 +61,7 @@ block content
div.clearfix div.clearfix
div.col-lg-4 div.col-lg-5
div.col-xs-12 div.col-xs-12
nodemap#mapHolder(data="map") nodemap#mapHolder(data="map")
@ -77,10 +77,10 @@ block content
i.icon-node(data-toggle="tooltip", data-placement="top", title="Node") i.icon-node(data-toggle="tooltip", data-placement="top", title="Node")
th th
i.icon-laptop(data-toggle="tooltip", data-placement="top", title="Node type") i.icon-laptop(data-toggle="tooltip", data-placement="top", title="Node type")
th
i.icon-group(data-toggle="tooltip", data-placement="top", title="Peers")
th th
i.icon-mining(data-toggle="tooltip", data-placement="top", title="Is mining") i.icon-mining(data-toggle="tooltip", data-placement="top", title="Is mining")
th
i.icon-group(data-toggle="tooltip", data-placement="top", title="Peers")
th th
i.icon-block(data-toggle="tooltip", data-placement="top", title="Last node block") i.icon-block(data-toggle="tooltip", data-placement="top", title="Last node block")
th.hidden-sm.hidden-xs   th.hidden-sm.hidden-xs  
@ -91,18 +91,18 @@ block content
tbody tbody
tr(ng-repeat='node in nodes', class="{{ node.stats | mainClass : bestBlock }}") tr(ng-repeat='node in nodes', class="{{ node.stats | mainClass : bestBlock }}")
td(rel="{{node.id}}") td(rel="{{node.id}}")
span.small(data-toggle="tooltip", data-placement="top", data-original-title="{{node.geo | geoTooltip}}") {{node.info.name}} span(data-toggle="tooltip", data-placement="top", data-original-title="{{node.geo | geoTooltip}}") {{node.info.name}}
  -   span.small &nbsp({{node.info.ip}})
span.small {{node.info.ip}}
td td
div.small(ng-bind-html="node.info.node | nodeVersion") div.small(ng-bind-html="node.info.node | nodeVersion")
//- div.small {{node.info.os}}, {{node.info.os_v}} //- div.small {{node.info.os}}, {{node.info.os_v}}
td(class="{{ node.stats.peers | peerClass }}") {{node.stats.peers}}
td(class="{{ node.stats.mining | miningClass }}") td(class="{{ node.stats.mining | miningClass }}")
i(class="{{ node.stats.mining | miningIconClass }}") i(class="{{ node.stats.mining | miningIconClass }}")
td(class="{{ node.stats.peers | peerClass }}") {{node.stats.peers}}
td(class="{{ node.stats.block.number | blockClass : bestBlock }}") {{'#' + node.stats.block.number}} td(class="{{ node.stats.block.number | blockClass : bestBlock }}") {{'#' + node.stats.block.number}}
td(class="{{ node.stats.block.number | blockClass : bestBlock }}").hidden-sm.hidden-xs td(class="{{ node.stats.block.number | blockClass : bestBlock }}").hidden-sm.hidden-xs
span.small {{node.stats.block.hash}} 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}} //- 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(am-time-ago="node.stats.block.timestamp", am-preprocess="unix", class="{{ node.stats.block.timestamp | timeClass }}") ∞ td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix", class="{{ node.stats.block.timestamp | timeClass }}") ∞
//- td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.blocktime | blockTimeFilter }}
td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }} td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }}