added hashrate filter

This commit is contained in:
cubedro 2015-04-29 13:14:18 +03:00
parent 3a81372329
commit df87857692
4 changed files with 31 additions and 18 deletions

View File

@ -133,6 +133,10 @@ span.small-title span.small {
word-spacing: nowrap !important;
}
.big-info .big-details .small-hash {
font-size: 87%;
}
.big-info .big-details-holder {
position: absolute;
top: 15px;

View File

@ -178,7 +178,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
break;
case "inactive":
if(typeof data.stats !== 'undefined')
if( !_.isUndefined(data.stats) )
$scope.nodes[findIndex({id: data.id})].stats = data.stats;
toastr['error']("Node "+ $scope.nodes[findIndex({id: data.id})].info.name +" went away!", "Node connection was lost!");
@ -186,9 +186,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
break;
case "latency":
if( !_.isUndefined(data.id) )
var node = $scope.nodes[findIndex({id: data.id})];
if(typeof node.stats !== 'undefined' && typeof node.stats.latency !== 'undefined')
if( !_.isUndefined(node) && !_.isUndefined(node.stats) && !_.isUndefined(node.stats.latency))
$scope.nodes[findIndex({id: data.id})].stats.latency = data.latency;
break;

View File

@ -231,35 +231,42 @@ angular.module('netStatsApp.filters', [])
return moment.duration(Math.round(diff), 's').humanize() + ' ago';
};
})
.filter('networkHashrateFilter', function($sce) {
return function(hashes) {
.filter('networkHashrateFilter', ['$sce', '$filter', function($sce, filter) {
return function(hashes, isMining) {
var result = 0;
var unit = 'K';
if(hashes < 1000) {
return $sce.trustAsHtml(result.toFixed(1) + ' <span class="small">H/s</span>');
if(hashes !== 0 && hashes < 1000) {
result = hashes;
unit = '';
}
if(hashes < Math.pow(1000, 2)) {
if(hashes >= 1000 && hashes < Math.pow(1000, 2)) {
result = hashes / 1000;
return $sce.trustAsHtml(result.toFixed(1) + ' <span class="small">KH/s</span>');
unit = 'K';
}
if(hashes < Math.pow(1000, 3)) {
if(hashes >= Math.pow(1000, 2) && hashes < Math.pow(1000, 3)) {
result = hashes / Math.pow(1000, 2);
return $sce.trustAsHtml(result.toFixed(1) + ' <span class="small">MH/s</span>');
unit = 'M';
}
if(hashes < Math.pow(1000, 4)) {
if(hashes >= Math.pow(1000, 3) && hashes < Math.pow(1000, 4)) {
result = hashes / Math.pow(1000, 3);
return $sce.trustAsHtml(result.toFixed(1) + ' <span class="small">GH/s</span>');
unit = 'G';
}
if(hashes < Math.pow(1000, 5)) {
if(hashes >= Math.pow(1000, 4) && hashes < Math.pow(1000, 5)) {
result = hashes / Math.pow(1000, 4);
return $sce.trustAsHtml(result.toFixed(1) + ' <span class="small">TH/s</span>');
unit = 'T';
}
if( !isMining )
return $sce.trustAsHtml(filter('number')(result.toFixed(1)) + ' <span class="small-hash">' + unit + 'H/s</span>');
return $sce.trustAsHtml('? <span class="small-hash">' + unit + 'KH/s</span>');
};
})
}])
.filter('blockPropagationFilter', function() {
return function(ms, prefix) {
if(typeof prefix === 'undefined')

View File

@ -104,7 +104,7 @@ block content
div.big-info.chart.xdouble-chart(class="{{ blockPropagationAvg | propagationAvgTimeClass : true }}")
//- i.icon-gas
span.small-title block propagation
span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }}
//- span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }}
histogram.big-details.d3-blockpropagation(data="blockPropagationChart")
div.col-xs-3.stat-holder.pull-right
@ -192,7 +192,8 @@ block content
td(class="{{ node.stats.mining | miningClass : node.stats.active }}")
i(class="{{ node.stats.mining | miningIconClass }}")
td(class="{{ node.stats.mining | hashrateClass : node.stats.active }}")
span.small {{node.stats.hashrate | hashrateFilter}} kH/s
span.small(ng-bind-html="node.stats.hashrate | networkHashrateFilter")
//- {{node.stats.hashrate | hashrateFilter}} kH/s
td(class="{{ node.stats.peers | peerClass : node.stats.active }}", style="padding-left: 11px;") {{node.stats.peers}}
td(style="padding-left: 15px;") {{node.stats.pending}}
td(class="{{ node.stats | blockClass : bestBlock }}") {{'#'}}{{ node.stats.block.number | number }}