added update functionality (fixes #7)

This commit is contained in:
Marian Oancea
2015-02-05 01:30:16 +02:00
parent a3968373c0
commit 4cfe4948af
5 changed files with 36 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ function StatsCtrl($scope, socket, _) {
});
socket.on('update', function(data){
$scope.nodes[data.node.id] = data.node;
$scope.nodes[data.id] = data;
updateStats();
});

View File

@@ -3,34 +3,50 @@
/* Filters */
angular.module('netStatsApp.filters', [])
.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';
};
})
.filter('mainClass', function() {
return function(node, bestBlock) {
if( ! node.active)
return 'text-danger';
if( node.peers === 0)
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'));
}
};
})
.filter('miningClass', function() {
return function(mining) {
return (! mining ? 'text-danger' : '');
}
};
})
.filter('miningIconClass', function() {
return function(mining) {
return (! mining ? 'icon-cancel' : 'icon-check');
}
};
})
.filter('blockClass', function() {
return function(current, best) {
return (best - current <= 1 ? '' : (best - current > 1 && best - current < 4 ? 'text-warning' : 'text-danger'));
}
};
});