added underscore + fixes

This commit is contained in:
Marian Oancea
2015-01-29 00:38:54 +02:00
parent be62d895b1
commit 8427f59ca7
8 changed files with 26 additions and 34 deletions

View File

@@ -1,3 +1,3 @@
'use strict';
var app = angular.module('netStatsApp', ['netStatsApp.filters', 'netStatsApp.directives']);
var app = angular.module('netStatsApp', ['underscore', 'netStatsApp.filters', 'netStatsApp.directives']);

View File

@@ -2,7 +2,7 @@
/* Controllers */
function StatsCtrl($scope, socket) {
function StatsCtrl($scope, socket, _) {
// Socket listeners
// ----------------
@@ -10,6 +10,7 @@ function StatsCtrl($scope, socket) {
socket.on('init', function(data){
$scope.nodes = data.nodes;
$scope.nodesTotal = $scope.nodes.length;
$scope.nodesActive = $scope.nodes.length;
$scope.nodesActive = _.filter($scope.nodes, function(node){ return node.stats.active == true; }).length;
$scope.bestBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.height); }).stats.block.height;
});
}

6
public/js/lib/underscore.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -24,4 +24,9 @@ app.factory('socket', function ($rootScope) {
})
}
};
});
var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
return window._;
});