added pin history for init refresh

This commit is contained in:
cubedro 2015-05-19 08:08:52 +03:00
parent 64e7ca085e
commit 17c80be29d
3 changed files with 11 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -110,11 +110,17 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
switch(action) {
case "init":
var oldNodes = [];
if( $scope.nodes.length > 0 ){
oldNodes = $scope.nodes;
}
$scope.nodes = data;
_.forEach($scope.nodes, function(node, index) {
// Init hashrate
if(typeof node.stats.hashrate === 'undefined')
if( _.isUndefined(node.stats.hashrate) )
$scope.nodes[index].stats.hashrate = 0;
// Init history
@ -124,8 +130,8 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
_.fill(data.history, -1);
}
// Init pin
$scope.nodes[index].pinned = false;
// Init or recover pin
$scope.nodes[index].pinned = _.result(_.find(oldNodes, 'id', node.id), 'pinned', false);
$scope.$apply();