added time filter

This commit is contained in:
Marian Oancea 2015-02-05 03:33:58 +02:00
parent f36a5dda1a
commit ad42e1c389
3 changed files with 25 additions and 3 deletions

View File

@ -1,5 +1,10 @@
var nodes = [ var nodes = [
// { //
// Duplicate this file and rename it to "nodes.js".
// It will be loaded as the main config file and
// will be ignored by git. Add nodes like the one below
//
// {
// name: 'Readable name of the node', // name: 'Readable name of the node',
// type: 'C++/Go...', // type: 'C++/Go...',
// rpcHost: 'your node IP here', // rpcHost: 'your node IP here',

View File

@ -49,4 +49,21 @@ angular.module('netStatsApp.filters', [])
return function(current, best) { return function(current, best) {
return (best - current <= 1 ? '' : (best - current > 1 && best - current < 4 ? 'text-warning' : 'text-danger')); return (best - current <= 1 ? '' : (best - current > 1 && best - current < 4 ? 'text-warning' : 'text-danger'));
}; };
})
.filter('timeClass', function() {
return function(timestamp) {
var time = Math.floor((new Date()).getTime() / 1000);
var diff = time - timestamp;
if(diff <= 12)
return 'text-success';
if(diff <= 20)
return 'text-info';
if(diff <= 30)
return 'text-warning';
return 'text-danger';
};
}); });

View File

@ -27,7 +27,7 @@ block content
span.big-details {{"#" + bestBlock}} span.big-details {{"#" + bestBlock}}
div.clearfix div.clearfix
div.col-xs-6.stat-holder div.col-xs-6.stat-holder
div.row.big-info.blocktime.text-success div.row.big-info.blocktime(class="{{ lastBlock | timeClass }}")
div.pull-left.icon-full-width div.pull-left.icon-full-width
i.icon-time i.icon-time
div.pull-left div.pull-left
@ -82,5 +82,5 @@ block content
td(class="{{ node.stats.block.height | blockClass : bestBlock }}") {{'#' + node.stats.block.height}} td(class="{{ node.stats.block.height | blockClass : bestBlock }}") {{'#' + node.stats.block.height}}
td(class="{{ node.stats.block.height | blockClass : bestBlock }}").hidden-sm.hidden-xs td(class="{{ node.stats.block.height | blockClass : bestBlock }}").hidden-sm.hidden-xs
span.small {{node.stats.block.hash}} span.small {{node.stats.block.hash}}
td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix") td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix", class="{{ node.stats.block.timestamp | timeClass }}")
td {{ node.stats.active ? '100%' : '0%' }} td {{ node.stats.active ? '100%' : '0%' }}