angular improvements
This commit is contained in:
parent
d9ae085890
commit
4b5bdf3e3e
2
dist/index.html
vendored
2
dist/index.html
vendored
File diff suppressed because one or more lines are too long
2
dist/js/netstats.min.js
vendored
2
dist/js/netstats.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/netstats.min.js.map
vendored
2
dist/js/netstats.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -71,24 +71,22 @@ History.prototype.add = function(block, id)
|
|||||||
|
|
||||||
if(historyBlock.hash !== block.hash || historyBlock.totalDifficulty !== block.totalDifficulty || historyBlock.transactions.length !== block.transactions.length)
|
if(historyBlock.hash !== block.hash || historyBlock.totalDifficulty !== block.totalDifficulty || historyBlock.transactions.length !== block.transactions.length)
|
||||||
{
|
{
|
||||||
index = _.findIndex( this._items, { height: block.number } );
|
historyBlock.hash = block.hash;
|
||||||
|
historyBlock.parentHash = block.parentHash;
|
||||||
this._items[index].hash = block.hash;
|
historyBlock.nonce = block.nonce;
|
||||||
this._items[index].parentHash = block.parentHash;
|
historyBlock.sha3Uncles = block.sha3Uncles;
|
||||||
this._items[index].nonce = block.nonce;
|
historyBlock.transactionsRoot = block.transactionsRoot;
|
||||||
this._items[index].sha3Uncles = block.sha3Uncles;
|
historyBlock.stateRoot = block.stateRoot;
|
||||||
this._items[index].transactionsRoot = block.transactionsRoot;
|
historyBlock.miner = block.miner;
|
||||||
this._items[index].stateRoot = block.stateRoot;
|
historyBlock.difficulty = block.difficulty;
|
||||||
this._items[index].miner = block.miner;
|
historyBlock.totalDifficulty = block.totalDifficulty;
|
||||||
this._items[index].difficulty = block.difficulty;
|
historyBlock.size = block.size;
|
||||||
this._items[index].totalDifficulty = block.totalDifficulty;
|
historyBlock.extraData = block.extraData;
|
||||||
this._items[index].size = block.size;
|
historyBlock.gasLimit = block.gasLimit;
|
||||||
this._items[index].extraData = block.extraData;
|
historyBlock.gasUsed = block.gasUsed;
|
||||||
this._items[index].gasLimit = block.gasLimit;
|
historyBlock.timestamp = block.timestamp;
|
||||||
this._items[index].gasUsed = block.gasUsed;
|
historyBlock.transactions = block.transactions;
|
||||||
this._items[index].timestamp = block.timestamp;
|
historyBlock.uncles = block.uncles;
|
||||||
this._items[index].transactions = block.transactions;
|
|
||||||
this._items[index].uncles = block.uncles;
|
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -116,12 +116,12 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
console.log('We are scheduling a reconnect operation', opts);
|
console.log('We are scheduling a reconnect operation', opts);
|
||||||
})
|
})
|
||||||
.on('data', function incoming(data) {
|
.on('data', function incoming(data) {
|
||||||
socketAction(data.action, data.data);
|
$scope.$apply(socketAction(data.action, data.data));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('init', function(data)
|
socket.on('init', function(data)
|
||||||
{
|
{
|
||||||
socketAction("init", data.nodes);
|
$scope.$apply(socketAction("init", data.nodes));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('client-latency', function(data)
|
socket.on('client-latency', function(data)
|
||||||
@ -142,7 +142,10 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
_.forEach($scope.nodes, function (node, index) {
|
_.forEach($scope.nodes, function (node, index) {
|
||||||
// Init hashrate
|
// Init hashrate
|
||||||
if( _.isUndefined(node.stats.hashrate) )
|
if( _.isUndefined(node.stats.hashrate) )
|
||||||
$scope.nodes[index].stats.hashrate = 0;
|
node.stats.hashrate = 0;
|
||||||
|
|
||||||
|
// Init latency
|
||||||
|
latencyFilter(node);
|
||||||
|
|
||||||
// Init history
|
// Init history
|
||||||
if( _.isUndefined(data.history) )
|
if( _.isUndefined(data.history) )
|
||||||
@ -152,7 +155,7 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init or recover pin
|
// Init or recover pin
|
||||||
$scope.nodes[index].pinned = ($scope.pinned.indexOf(node.id) >= 0 ? true : false);
|
node.pinned = ($scope.pinned.indexOf(node.id) >= 0 ? true : false);
|
||||||
});
|
});
|
||||||
|
|
||||||
if( $scope.nodes.length > 0 )
|
if( $scope.nodes.length > 0 )
|
||||||
@ -281,6 +284,9 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
if( _.isUndefined($scope.nodes[index].pinned) )
|
if( _.isUndefined($scope.nodes[index].pinned) )
|
||||||
$scope.nodes[index].pinned = false;
|
$scope.nodes[index].pinned = false;
|
||||||
|
|
||||||
|
// Init latency
|
||||||
|
latencyFilter($scope.nodes[index]);
|
||||||
|
|
||||||
updateActiveNodes();
|
updateActiveNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,15 +359,19 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "latency":
|
case "latency":
|
||||||
var index = findIndex({id: data.id});
|
if( !_.isUndefined(data.id) && !_.isUndefined(data.latency) )
|
||||||
|
|
||||||
if( !_.isUndefined(data.id) && index >= 0 )
|
|
||||||
{
|
{
|
||||||
var node = $scope.nodes[index];
|
var index = findIndex({id: data.id});
|
||||||
|
|
||||||
if( !_.isUndefined(node) && !_.isUndefined(node.stats) && !_.isUndefined(node.stats.latency) )
|
if( index >= 0 )
|
||||||
{
|
{
|
||||||
$scope.nodes[index].stats.latency = data.latency;
|
var node = $scope.nodes[index];
|
||||||
|
|
||||||
|
if( !_.isUndefined(node) && !_.isUndefined(node.stats) && !_.isUndefined(node.stats.latency) && node.stats.latency !== data.latency )
|
||||||
|
{
|
||||||
|
node.stats.latency = data.latency;
|
||||||
|
latencyFilter(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +386,7 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$apply();
|
// $scope.$apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
function findIndex(search)
|
function findIndex(search)
|
||||||
@ -497,4 +507,34 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function latencyFilter(node)
|
||||||
|
{
|
||||||
|
if( _.isUndefined(node.readable) )
|
||||||
|
node.readable = {};
|
||||||
|
|
||||||
|
if( _.isUndefined(node.stats) ) {
|
||||||
|
node.readable.latencyClass = 'text-danger';
|
||||||
|
node.readable.latency = 'offline';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.stats.active === false)
|
||||||
|
{
|
||||||
|
node.readable.latencyClass = 'text-danger';
|
||||||
|
node.readable.latency = 'offline';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (node.stats.latency <= 100)
|
||||||
|
node.readable.latencyClass = 'text-success';
|
||||||
|
|
||||||
|
if (node.stats.latency > 100 && node.stats.latency <= 1000)
|
||||||
|
node.readable.latencyClass = 'text-warning';
|
||||||
|
|
||||||
|
if (node.stats.latency > 1000)
|
||||||
|
node.readable.latencyClass = 'text-danger';
|
||||||
|
|
||||||
|
node.readable.latency = node.stats.latency + ' ms';
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
@ -184,7 +184,7 @@ block content
|
|||||||
th
|
th
|
||||||
i.icon-bulb(data-toggle="tooltip", data-placement="top", title="Up-time", ng-click="orderTable(['-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 track by node.id', class="{{ node.stats | mainClass : bestBlock }}")
|
tr(ng-repeat='node in nodes | orderBy:predicate track by node.id', class="{{ node.stats | mainClass : bestBlock }}", id="node_{{node.id}}")
|
||||||
td.td-nodecheck
|
td.td-nodecheck
|
||||||
i(ng-click="pinNode(node.id)", class="{{ node.pinned | nodePinClass }}", data-toggle="tooltip", data-placement="right", data-original-title="Click to {{ node.pinned ? 'un' : '' }}pin")
|
i(ng-click="pinNode(node.id)", 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}}")
|
||||||
@ -194,8 +194,8 @@ block content
|
|||||||
i.icon-warning-o
|
i.icon-warning-o
|
||||||
td
|
td
|
||||||
div.small(ng-bind-html="node.info.node | nodeVersion")
|
div.small(ng-bind-html="node.info.node | nodeVersion")
|
||||||
td(class="{{ node.stats | latencyClass }}")
|
td(class="{{ node.readable.latencyClass }}")
|
||||||
span.small {{node.stats | latencyFilter}}
|
span.small {{ node.readable.latency }}
|
||||||
td(class="{{ node.stats.mining | hashrateClass : node.stats.active }}", ng-bind-html="node.stats.hashrate | hashrateFilter : node.stats.mining")
|
td(class="{{ node.stats.mining | hashrateClass : node.stats.active }}", ng-bind-html="node.stats.hashrate | hashrateFilter : node.stats.mining")
|
||||||
td(class="{{ node.stats.peers | peerClass : node.stats.active }}", style="padding-left: 11px;") {{node.stats.peers}}
|
td(class="{{ node.stats.peers | peerClass : node.stats.active }}", style="padding-left: 11px;") {{node.stats.peers}}
|
||||||
td(style="padding-left: 15px;") {{node.stats.pending}}
|
td(style="padding-left: 15px;") {{node.stats.pending}}
|
||||||
|
Loading…
Reference in New Issue
Block a user