From a3968373c0d2c173981f8a15ce88b3335ecb36fb Mon Sep 17 00:00:00 2001 From: Marian Oancea Date: Fri, 30 Jan 2015 23:37:38 +0200 Subject: [PATCH] more filters --- public/js/filters.js | 11 +++++++++++ views/index.jade | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/public/js/filters.js b/public/js/filters.js index b429c4e..7d0c2a0 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -3,6 +3,17 @@ /* Filters */ angular.module('netStatsApp.filters', []) +.filter('mainClass', function() { + return function(node, bestBlock) { + if( ! node.active) + return 'text-danger'; + + if( node.peers === 0) + return 'text-danger'; + + return (node.peers <= 1 ? 'text-danger' : (node.peers > 1 && node.peers < 4 ? 'text-warning' : 'text-success')); + } +}) .filter('peerClass', function() { return function(peers) { return (peers <= 1 ? 'text-danger' : (peers > 1 && peers < 4 ? 'text-warning' : 'text-success')); diff --git a/views/index.jade b/views/index.jade index 27ec756..a0866f2 100644 --- a/views/index.jade +++ b/views/index.jade @@ -73,7 +73,7 @@ block content th i.icon-clock tbody - tr(ng-repeat='node in nodes', class="{{ node.stats.active ? 'text-success' : 'text-danger' }}") + tr(ng-repeat='node in nodes', class="{{ node.stats | mainClass : bestBlock }}") td(rel="{{node.id}}") {{node.name}} td {{node.type}} td(class="{{ node.stats.peers | peerClass }}") {{node.stats.peers}}