From b27a8cff8624ea2cb13c9e9337fe724ceb3f8ad9 Mon Sep 17 00:00:00 2001 From: cubedro Date: Fri, 24 Apr 2015 13:33:50 +0300 Subject: [PATCH 1/2] fixed inactive state bug --- public/js/controllers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/controllers.js b/public/js/controllers.js index 45b1e42..892b870 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -142,7 +142,8 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { break; case "inactive": - $scope.nodes[findIndex({id: data.id})].stats = data.stats; + if(typeof data.stats !== 'undefined') + $scope.nodes[findIndex({id: data.id})].stats = data.stats; toastr['error']("Node "+ $scope.nodes[findIndex({id: data.id})].info.name +" went away!", "Node connection was lost!"); break; From c2cbb295ad04c9f8ed0e2f11ccd1c0d836d048d4 Mon Sep 17 00:00:00 2001 From: cubedro Date: Fri, 24 Apr 2015 13:39:26 +0300 Subject: [PATCH 2/2] fixed hashrate sorting --- public/js/controllers.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/public/js/controllers.js b/public/js/controllers.js index 892b870..951b141 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -99,6 +99,8 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { $scope.$apply(); _.forEach($scope.nodes, function(node, index) { + if(typeof node.stats.hashrate === 'undefined') + $scope.nodes[index].stats.hashrate = 0; makePeerPropagationChart($scope.nodes[index]); }); @@ -116,6 +118,9 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { break; case "update": + if(typeof data.stats.hashrate === 'undefined') + data.stats.hashrate = 0; + var index = findIndex({id: data.id}); $scope.nodes[index].stats = data.stats; $scope.nodes[index].history = data.history; @@ -144,6 +149,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { case "inactive": if(typeof data.stats !== 'undefined') $scope.nodes[findIndex({id: data.id})].stats = data.stats; + toastr['error']("Node "+ $scope.nodes[findIndex({id: data.id})].info.name +" went away!", "Node connection was lost!"); break; @@ -193,6 +199,9 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { var index = findIndex({id: data.id}); if(index < 0) { + if(typeof data.stats !== 'undefined' && typeof data.stats.hashrate === 'undefined') + data.stats.hashrate = 0; + $scope.nodes.push(data); return true; @@ -240,21 +249,11 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { if(value.name !== false) return; - console.error(key, value); - var name = _.result(_.find(_.pluck($scope.nodes, 'info'), 'coinbase', value.miner), 'name'); + if(typeof name !== 'undefined') $scope.miners[key].name = name; - - console.warn("Name: ", name); }); - - var addresses = _.pluck(_.filter($scope.miners, 'name', false), 'miner'); - console.info('Addresses', addresses); - - var coinbases = _.pluck($scope.nodes, 'info'); - console.info('Coinbases', coinbases); - console.info('Nodes', $scope.nodes); } jQuery('.spark-blocktimes').sparkline($scope.lastBlocksTime.reverse(), {type: 'bar', tooltipSuffix: ' s'});