added time filter

pull/5/head
Marian Oancea 10 years ago
parent f36a5dda1a
commit ad42e1c389
  1. 5
      config/nodes.default.js
  2. 17
      public/js/filters.js
  3. 4
      views/index.jade

@ -1,4 +1,9 @@
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',
// type: 'C++/Go...',

@ -49,4 +49,21 @@ angular.module('netStatsApp.filters', [])
return function(current, best) {
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';
};
});

@ -27,7 +27,7 @@ block content
span.big-details {{"#" + bestBlock}}
div.clearfix
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
i.icon-time
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 }}").hidden-sm.hidden-xs
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%' }}

Loading…
Cancel
Save