From 41b90028630f7a167a6cff553b745f92a8e81486 Mon Sep 17 00:00:00 2001 From: cubedro Date: Thu, 5 Mar 2015 00:11:51 +0200 Subject: [PATCH] added propagation time filter --- public/js/filters.js | 29 ++++++++++++++++++++++++++++- views/index.jade | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index 796ca43..b117211 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -113,7 +113,34 @@ angular.module('netStatsApp.filters', []) 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) { if(time < 60) return Math.round(time) + ' s'; diff --git a/views/index.jade b/views/index.jade index 95a9f7d..07d9d5b 100644 --- a/views/index.jade +++ b/views/index.jade @@ -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}} 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.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 }}