added propagation time filter

This commit is contained in:
cubedro 2015-03-05 00:11:51 +02:00
parent 8c49a9dd24
commit 41b9002863
2 changed files with 29 additions and 2 deletions

View File

@ -113,7 +113,34 @@ angular.module('netStatsApp.filters', [])
return moment.duration(Math.round(diff), 's').humanize() + ' ago'; return moment.duration(Math.round(diff), 's').humanize() + ' ago';
}; };
}).filter('avgTimeFilter', function() { })
.filter('blockPropagationFilter', function() {
return function(miliseconds) {
if(miliseconds < 1000)
return miliseconds + " ms";
var result = 0;
if(miliseconds < 1000*60){
result = miliseconds/1000;
return result.format(1) + " s";
}
if(miliseconds < 1000*60*60){
result = miliseconds/1000/60;
return result.format(1) + " min";
}
if(miliseconds < 1000*60*60*24){
result = miliseconds/1000/60/60;
return result.format(1) + " h";
}
result = miliseconds/1000/60/60/24;
return result.format(1) + " days";
};
})
.filter('avgTimeFilter', function() {
return function(time) { return function(time) {
if(time < 60) if(time < 60)
return Math.round(time) + ' s'; return Math.round(time) + ' s';

View File

@ -115,5 +115,5 @@ block content
//- 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(style="padding-left: 18px;") {{node.stats.block.txCount}} td(style="padding-left: 18px;") {{node.stats.block.txCount}}
td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.timestamp | blockTimeFilter }} td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.timestamp | blockTimeFilter }}
td(class="{{ node.stats.block.propagation | propagationTimeClass }}") {{node.stats.block.propagation}} ms td(class="{{ node.stats.block.propagation | propagationTimeClass }}") {{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 }}