From b173cbbcac9f8a92c33842a91e50fa9a63370801 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 17:56:48 +0300 Subject: [PATCH 1/3] improved peer propagation chart --- models/node.js | 2 +- public/css/style.css | 3 +-- public/js/controllers.js | 44 ++++++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/models/node.js b/models/node.js index b6fcfd1..2e33464 100644 --- a/models/node.js +++ b/models/node.js @@ -31,7 +31,7 @@ var Node = function Node(data) uptime: 0, lastUpdate: 0 }; - this.blockHistory = []; + this.blockHistory = Array(MAX_HISTORY); this.uptime = { started: null, history: [] diff --git a/public/css/style.css b/public/css/style.css index 985f117..4b1144d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -240,8 +240,7 @@ table td { } .th-peerPropagationChart { - text-align: center; - width: 125px; + width: 140px; } @media only screen and (max-width: 639px) { diff --git a/public/js/controllers.js b/public/js/controllers.js index 5cbe6a0..ea4898c 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -106,23 +106,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { var index = findIndex({id: data.id}); $scope.nodes[index].stats = data.stats; $scope.nodes[index].history = data.history; - $scope.nodes[index].propagation = _.map(data.history, function(block) { - return block.propagation; - }); - jQuery('.' + data.id).sparkline($scope.nodes[index].propagation, { - type: 'bar', - height: 18, - barWidth : 2, - barSpacing : 1, - tooltipSuffix: 'ms', - colorMap: jQuery.range_map({ - '0:1': '#10a0de', - '1:5000': '#7bcc3a', - '5001:12000': '#FFD162', - '12001:20000': '#ff8a00', - '20001:': '#F74B4B' - }) - }); + makePeerPropagationChart(index); break; case "info": @@ -151,6 +135,28 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { return _.findIndex($scope.nodes, search); } + function makePeerPropagationChart(index) + { + $scope.nodes[index].propagation = _.map($scope.nodes[index].history, function(block) { + return block.propagation; + }); + + jQuery('.' + $scope.nodes[index].id).sparkline($scope.nodes[index].propagation, { + type: 'bar', + height: 18, + barWidth : 2, + barSpacing : 1, + tooltipSuffix: 'ms', + colorMap: jQuery.range_map({ + '0:1': '#10a0de', + '1:5000': '#7bcc3a', + '5001:12000': '#FFD162', + '12001:20000': '#ff8a00', + '20001:': '#F74B4B' + }) + }); + } + function addNewNode(data) { var index = findIndex({id: data.id}); @@ -163,9 +169,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { $scope.nodes[index] = data; $scope.nodes[index].history = data.history; - $scope.nodes[index].propagation = _.map(data.history, function(block) { - return block.propagation; - }); + makePeerPropagationChart(index); return false; } From 7bf616f6b8375dc8afd409c027b862a558e1489c Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 21:02:18 +0300 Subject: [PATCH 2/3] fixed chart colors --- models/node.js | 2 +- public/js/controllers.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/models/node.js b/models/node.js index 2e33464..b6fcfd1 100644 --- a/models/node.js +++ b/models/node.js @@ -31,7 +31,7 @@ var Node = function Node(data) uptime: 0, lastUpdate: 0 }; - this.blockHistory = Array(MAX_HISTORY); + this.blockHistory = []; this.uptime = { started: null, history: [] diff --git a/public/js/controllers.js b/public/js/controllers.js index ea4898c..c7f86fa 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -149,10 +149,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { tooltipSuffix: 'ms', colorMap: jQuery.range_map({ '0:1': '#10a0de', - '1:5000': '#7bcc3a', - '5001:12000': '#FFD162', - '12001:20000': '#ff8a00', - '20001:': '#F74B4B' + '1:1000': '#7bcc3a', + '1001:3000': '#FFD162', + '3001:7000': '#ff8a00', + '7001:': '#F74B4B' }) }); } From 11008d51ee7286353918499cc5a4949c5c9bf245 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 21:10:27 +0300 Subject: [PATCH 3/3] added miner name --- public/js/filters.js | 7 +++++-- views/index.jade | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index 92788ae..971705c 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -201,8 +201,11 @@ angular.module('netStatsApp.filters', []) }; }) .filter('minerNameFilter', function() { - return function(name) { - return name.replace('0x', ''); + return function(address, name) { + if(typeof name !== 'undefined' && name !== false && name.length > 0) + return name; + + return address.replace('0x', ''); }; }) .filter('minerBlocksClass', function() { diff --git a/views/index.jade b/views/index.jade index 8f3c493..9bba26d 100644 --- a/views/index.jade +++ b/views/index.jade @@ -87,7 +87,7 @@ block content span.small-title last blocks miners div.blocks-holder(ng-repeat='miner in miners', data-toggle="tooltip", data-placement="right", title="{{miner.blocks}}") div.block-count ({{miner.blocks}}) - div.small-title-miner {{miner.miner | minerNameFilter}} + div.small-title-miner {{miner.miner | minerNameFilter : miner.name}} div.block(ng-repeat="i in getNumber(miner.blocks) track by $index", class="{{miner.blocks | minerBlocksClass}}") div.clearfix