From 146ac437b8b3fbd13415aacebc22508bc18b78b6 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 24 Feb 2015 23:38:14 +0200 Subject: [PATCH] added more filters --- public/js/filters.js | 28 ++++++++++++++++++++++++++++ views/index.jade | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index 0c78e01..8f60b3b 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -78,6 +78,34 @@ angular.module('netStatsApp.filters', []) return timeClass(timestamp); }; }) +.filter('propagationTimeClass', function() { + return function(propagation) { + if(propagation <= 2000) + return 'text-success'; + + if(propagation <= 4000) + return 'text-info'; + + if(propagation <= 5000) + return 'text-warning'; + + return 'text-danger' + }; +}) +.filter('latencyClass', function() { + return function(time) { + if(time <= 1000) + return 'text-success'; + + if(time <= 2000) + return 'text-info'; + + if(time <= 3000) + return 'text-warning'; + + return 'text-danger' + }; +}) .filter('blockTimeFilter', function() { return function(timestamp) { if(timestamp === 0) diff --git a/views/index.jade b/views/index.jade index 54e999a..95a9f7d 100644 --- a/views/index.jade +++ b/views/index.jade @@ -104,7 +104,7 @@ block content td div.small(ng-bind-html="node.info.node | nodeVersion") //- div.small {{node.info.os}}, {{node.info.os_v}} - td.small(class="{{ node.stats | mainClass : bestBlock }}") {{node.stats | latencyFilter}} + td.small(class="{{ node.stats.latency | latencyClass }}") {{node.stats | latencyFilter}} td(class="{{ node.stats.mining | miningClass }}") i.small(class="{{ node.stats.mining | miningIconClass }}") td(class="{{ node.stats.peers | peerClass }}", style="padding-left: 18px;") {{node.stats.peers}} @@ -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.timestamp | timeClass }}") {{node.stats.block.propagation}} ms + td(class="{{ node.stats.block.propagation | propagationTimeClass }}") {{node.stats.block.propagation}} ms td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }}