added reconnect functionality
This commit is contained in:
parent
9f93f7059b
commit
b347f825a4
@ -51,14 +51,21 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
switch(action) {
|
||||
case "init":
|
||||
$scope.nodes = data;
|
||||
if($scope.nodes.length > 0){
|
||||
|
||||
if($scope.nodes.length > 0)
|
||||
{
|
||||
toastr['success']("Got nodes list", "Got nodes!");
|
||||
}
|
||||
break;
|
||||
|
||||
case "add":
|
||||
$scope.nodes.push(data);
|
||||
toastr['success']("New node connected!", "New node!");
|
||||
if(addNewNode(data))
|
||||
{
|
||||
toastr['success']("New node connected!", "New node!");
|
||||
} else {
|
||||
toastr['info']("Node reconnected!", "Node is back!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "update":
|
||||
@ -78,6 +85,21 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
return _.findIndex($scope.nodes, search);
|
||||
}
|
||||
|
||||
function addNewNode(data)
|
||||
{
|
||||
var index = findIndex({id: data.id});
|
||||
if(index < 0)
|
||||
{
|
||||
$scope.nodes.push(data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope.nodes[index] = data;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateStats()
|
||||
{
|
||||
if($scope.nodes.length)
|
||||
|
Loading…
Reference in New Issue
Block a user