added node pin functionality

This commit is contained in:
cubedro 2015-05-19 02:41:14 +03:00
parent b411653cbd
commit d649d4daa0
6 changed files with 52 additions and 21 deletions

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -36,19 +36,31 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
$scope.currentApiVersion = "0.0.8"; $scope.currentApiVersion = "0.0.8";
$scope.predicate = ['-stats.active', '-stats.block.number', 'stats.block.propagation']; $scope.predicate = ['-pinned', '-stats.active', '-stats.block.number', 'stats.block.propagation'];
$scope.reverse = false; $scope.reverse = false;
$scope.prefixPredicate = ['-pinned', '-stats.active'];
$scope.originalPredicate = ['-stats.block.number', 'stats.block.propagation'];
$scope.orderTable = function(predicate, reverse) $scope.orderTable = function(predicate, reverse)
{ {
if(!_.isEqual(predicate, $scope.predicate)) if(!_.isEqual(predicate, $scope.originalPredicate))
{ {
$scope.reverse = reverse; $scope.reverse = reverse;
$scope.predicate = predicate; $scope.originalPredicate = predicate;
$scope.predicate = _.union($scope.prefixPredicate, predicate);
} }
else else
{ {
$scope.reverse = !$scope.reverse; $scope.reverse = !$scope.reverse;
if($scope.reverse === true){
_.forEach(predicate, function (value, key) {
predicate[key] = (value[0] === '-' ? value.replace('-', '') : '-' + value);
});
}
$scope.predicate = _.union($scope.prefixPredicate, predicate);
} }
} }
@ -99,14 +111,19 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
switch(action) { switch(action) {
case "init": case "init":
$scope.nodes = data; $scope.nodes = data;
$scope.$apply();
_.forEach($scope.nodes, function(node, index) { _.forEach($scope.nodes, function(node, index) {
if(typeof node.stats.hashrate === 'undefined') if(typeof node.stats.hashrate === 'undefined')
$scope.nodes[index].stats.hashrate = 0; $scope.nodes[index].stats.hashrate = 0;
// Init pin
$scope.nodes[index].pinned = false;
makePeerPropagationChart($scope.nodes[index]); makePeerPropagationChart($scope.nodes[index]);
}); });
$scope.$apply();
if($scope.nodes.length > 0) if($scope.nodes.length > 0)
toastr['success']("Got nodes list", "Got nodes!"); toastr['success']("Got nodes list", "Got nodes!");
@ -270,6 +287,8 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
if(typeof data.stats !== 'undefined' && typeof data.stats.hashrate === 'undefined') if(typeof data.stats !== 'undefined' && typeof data.stats.hashrate === 'undefined')
data.stats.hashrate = 0; data.stats.hashrate = 0;
data.pinned = false;
$scope.nodes.push(data); $scope.nodes.push(data);
return true; return true;

View File

@ -19,6 +19,14 @@ angular.module('netStatsApp.filters', [])
return 'text-danger'; return 'text-danger';
}; };
}) })
.filter('nodePinClass', function() {
return function(pinned) {
if(pinned)
return 'icon-check-o';
return 'icon-loader';
};
})
.filter('mainClass', function() { .filter('mainClass', function() {
return function(node, bestBlock) { return function(node, bestBlock) {
return mainClass(node, bestBlock); return mainClass(node, bestBlock);

View File

@ -149,36 +149,40 @@ block content
table.table.table-striped table.table.table-striped
thead thead
tr.text-info tr.text-info
th.th-nodecheck
i.icon-check-o(data-toggle="tooltip", data-placement="top", title="Pin nodes to display first", ng-click="orderTable(['-stats.block.number', 'stats.block.propagation'], false)")
th.th-nodename th.th-nodename
i.icon-node(data-toggle="tooltip", data-placement="top", title="Node name", ng-click="orderTable(['-stats.active', 'info.name'], false)") i.icon-node(data-toggle="tooltip", data-placement="top", title="Node name", ng-click="orderTable(['info.name'], false)")
th.th-nodetype th.th-nodetype
i.icon-laptop(data-toggle="tooltip", data-placement="top", title="Node type", ng-click="orderTable(['-stats.active', 'info.node'], false)") i.icon-laptop(data-toggle="tooltip", data-placement="top", title="Node type", ng-click="orderTable(['info.node'], false)")
th.th-latency th.th-latency
i.icon-clock(data-toggle="tooltip", data-placement="top", title="Node latency", ng-click="orderTable(['-stats.active', 'stats.latency'], false)") i.icon-clock(data-toggle="tooltip", data-placement="top", title="Node latency", ng-click="orderTable(['stats.latency'], false)")
th th
i.icon-mining(data-toggle="tooltip", data-placement="top", title="Is mining", ng-click="orderTable(['-stats.active', '-stats.mining'], false)") i.icon-mining(data-toggle="tooltip", data-placement="top", title="Is mining", ng-click="orderTable(['-stats.mining'], false)")
th th
i.icon-group(data-toggle="tooltip", data-placement="top", title="Peers", ng-click="orderTable(['-stats.active', '-stats.peers'], false)") i.icon-group(data-toggle="tooltip", data-placement="top", title="Peers", ng-click="orderTable(['-stats.peers'], false)")
th th
i.icon-network(data-toggle="tooltip", data-placement="top", title="Pending transactions", ng-click="orderTable(['-stats.active', '-stats.pending'], false)") i.icon-network(data-toggle="tooltip", data-placement="top", title="Pending transactions", ng-click="orderTable(['-stats.pending'], false)")
th th
i.icon-block(data-toggle="tooltip", data-placement="top", title="Last block", ng-click="orderTable(['-stats.active', '-stats.block.number', 'stats.block.propagation'], false)") i.icon-block(data-toggle="tooltip", data-placement="top", title="Last block", ng-click="orderTable(['-stats.block.number', 'stats.block.propagation'], false)")
th.th-blockhash #[ ] th.th-blockhash #[ ]
th th
i.icon-check-o(data-toggle="tooltip", data-placement="top", title="Block transactions", ng-click="orderTable(['-stats.active', '-stats.block.transactions.length'], false)") i.icon-check-o(data-toggle="tooltip", data-placement="top", title="Block transactions", ng-click="orderTable(['-stats.block.transactions.length'], false)")
th th
i.icon-uncle(data-toggle="tooltip", data-placement="top", title="Uncles", ng-click="orderTable(['-stats.active', '-stats.block.uncles.length'], false)") i.icon-uncle(data-toggle="tooltip", data-placement="top", title="Uncles", ng-click="orderTable(['-stats.block.uncles.length'], false)")
th.th-blocktime th.th-blocktime
i.icon-time(data-toggle="tooltip", data-placement="top", title="Last block time", ng-click="orderTable(['-stats.active', '-stats.block.received'], false)") i.icon-time(data-toggle="tooltip", data-placement="top", title="Last block time", ng-click="orderTable(['-stats.block.received'], false)")
th.th-peerPropagationTime th.th-peerPropagationTime
i.icon-gas(data-toggle="tooltip", data-placement="top", title="Propagation time", ng-click="orderTable(['-stats.active', '-stats.block.number', 'stats.block.propagation'], false)") i.icon-gas(data-toggle="tooltip", data-placement="top", title="Propagation time", ng-click="orderTable(['-stats.block.number', 'stats.block.propagation'], false)")
th.th-peerPropagationChart th.th-peerPropagationChart
th.th-peerPropagationAvg th.th-peerPropagationAvg
i.icon-gas(data-toggle="tooltip", data-placement="top", title="Average propagation time", ng-click="orderTable(['-stats.active', 'stats.propagationAvg'], false)") i.icon-gas(data-toggle="tooltip", data-placement="top", title="Average propagation time", ng-click="orderTable(['stats.propagationAvg'], false)")
th th
i.icon-bulb(data-toggle="tooltip", data-placement="top", title="Up-time", ng-click="orderTable(['-stats.active', '-stats.uptime'], false)") i.icon-bulb(data-toggle="tooltip", data-placement="top", title="Up-time", ng-click="orderTable(['-stats.uptime'], false)")
tbody(ng-cloak) tbody(ng-cloak)
tr(ng-repeat='node in nodes | orderBy:predicate:reverse', class="{{ node.stats | mainClass : bestBlock }}") tr(ng-repeat='node in nodes | orderBy:predicate', class="{{ node.stats | mainClass : bestBlock }}")
td
i(ng-click="node.pinned = !node.pinned", class="{{ node.pinned | nodePinClass }}", data-toggle="tooltip", data-placement="right", data-original-title="Click to {{ node.pinned ? 'un' : '' }}pin")
td.nodeInfo(rel="{{node.id}}") td.nodeInfo(rel="{{node.id}}")
span.small(data-toggle="tooltip", data-placement="top", data-html="true", data-original-title="{{node | geoTooltip}}") {{node.info.name}} span.small(data-toggle="tooltip", data-placement="top", data-html="true", data-original-title="{{node | geoTooltip}}") {{node.info.name}}
span.small #[ ]({{node.info.ip}}) span.small #[ ]({{node.info.ip}})