2015-01-20 19:29:31 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* Filters */
|
|
|
|
|
2015-01-29 17:50:16 +01:00
|
|
|
angular.module('netStatsApp.filters', [])
|
2015-02-05 00:30:16 +01:00
|
|
|
.filter('nodesActiveClass', function() {
|
|
|
|
return function(active, total) {
|
|
|
|
var ratio = active/total;
|
|
|
|
|
|
|
|
if(ratio >= 0.9)
|
|
|
|
return 'text-success';
|
|
|
|
|
|
|
|
if(ratio >= 0.75)
|
|
|
|
return 'text-info';
|
|
|
|
|
|
|
|
if(ratio >= 0.5)
|
|
|
|
return 'text-warning';
|
|
|
|
|
|
|
|
return 'text-danger';
|
|
|
|
};
|
|
|
|
})
|
2015-01-30 22:37:38 +01:00
|
|
|
.filter('mainClass', function() {
|
|
|
|
return function(node, bestBlock) {
|
|
|
|
if( ! node.active)
|
|
|
|
return 'text-danger';
|
|
|
|
|
2015-02-05 00:30:16 +01:00
|
|
|
if(node.peers === 0)
|
2015-01-30 22:37:38 +01:00
|
|
|
return 'text-danger';
|
|
|
|
|
|
|
|
return (node.peers <= 1 ? 'text-danger' : (node.peers > 1 && node.peers < 4 ? 'text-warning' : 'text-success'));
|
2015-02-05 00:30:16 +01:00
|
|
|
};
|
2015-01-30 22:37:38 +01:00
|
|
|
})
|
2015-01-29 17:50:16 +01:00
|
|
|
.filter('peerClass', function() {
|
|
|
|
return function(peers) {
|
|
|
|
return (peers <= 1 ? 'text-danger' : (peers > 1 && peers < 4 ? 'text-warning' : 'text-success'));
|
2015-02-05 00:30:16 +01:00
|
|
|
};
|
2015-01-29 17:50:16 +01:00
|
|
|
})
|
|
|
|
.filter('miningClass', function() {
|
|
|
|
return function(mining) {
|
|
|
|
return (! mining ? 'text-danger' : '');
|
2015-02-05 00:30:16 +01:00
|
|
|
};
|
2015-01-29 17:50:16 +01:00
|
|
|
})
|
|
|
|
.filter('miningIconClass', function() {
|
|
|
|
return function(mining) {
|
|
|
|
return (! mining ? 'icon-cancel' : 'icon-check');
|
2015-02-05 00:30:16 +01:00
|
|
|
};
|
2015-01-29 17:50:16 +01:00
|
|
|
})
|
|
|
|
.filter('blockClass', function() {
|
|
|
|
return function(current, best) {
|
|
|
|
return (best - current <= 1 ? '' : (best - current > 1 && best - current < 4 ? 'text-warning' : 'text-danger'));
|
2015-02-05 00:30:16 +01:00
|
|
|
};
|
2015-01-29 17:50:16 +01:00
|
|
|
});
|