From d8f8c209277380dfd75acdd307f5677df9efbdf8 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Thu, 14 Mar 2019 08:13:44 -0400 Subject: [PATCH] make the graph work with edges to nodes that are not reporting Signed-off-by: Mikolaj Pawlikowski --- static/index.html | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index 73cc6e6..279ee15 100644 --- a/static/index.html +++ b/static/index.html @@ -229,6 +229,7 @@ var main = function(timeout){ // prepare nodes var nodes = []; + var podIPs = []; var resp = data.responses; for (let podIP in resp) { let value = resp[podIP]; @@ -239,8 +240,8 @@ var main = function(timeout){ "y": 0, _data: value, }); + podIPs.push(podIP); }; - //console.log(nodes); // prepare the edges var edges = []; @@ -257,7 +258,26 @@ var main = function(timeout){ }; } }; - //console.log(edges); + console.log(edges); + console.log(nodes); + + // if running goldpinger with PING_NUMBER, then we need to add nodes for the edges + // that are not reporting but are reported to + edges.forEach(function(edge) { + [edge.source, edge.target].forEach(function(value) { + if (podIPs.indexOf(value) == -1){ + nodes.push({ + "label": value, + "id": value, + "x": 0, + "y": 0, + _data: {}, + }); + podIPs.push(value); + } + }) + }) + console.log(nodes); // build the actual graph