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

View File

@@ -36,19 +36,31 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
$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.prefixPredicate = ['-pinned', '-stats.active'];
$scope.originalPredicate = ['-stats.block.number', 'stats.block.propagation'];
$scope.orderTable = function(predicate, reverse)
{
if(!_.isEqual(predicate, $scope.predicate))
if(!_.isEqual(predicate, $scope.originalPredicate))
{
$scope.reverse = reverse;
$scope.predicate = predicate;
$scope.originalPredicate = predicate;
$scope.predicate = _.union($scope.prefixPredicate, predicate);
}
else
{
$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) {
case "init":
$scope.nodes = data;
$scope.$apply();
_.forEach($scope.nodes, function(node, index) {
if(typeof node.stats.hashrate === 'undefined')
$scope.nodes[index].stats.hashrate = 0;
// Init pin
$scope.nodes[index].pinned = false;
makePeerPropagationChart($scope.nodes[index]);
});
$scope.$apply();
if($scope.nodes.length > 0)
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')
data.stats.hashrate = 0;
data.pinned = false;
$scope.nodes.push(data);
return true;

View File

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