diff --git a/lib/main.js b/lib/main.js index c517768..4f2aab4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -5,14 +5,12 @@ function (moment, Router, L, GUI, numeral) { var dataNodes = data[0] var dataGraph = data[1] - if (dataNodes.version !== 1 || dataGraph.version !== 1) { + if (dataNodes.version !== 2 || dataGraph.version !== 1) { var err = "Unsupported nodes or graph version: " + dataNodes.version + " " + dataGraph.version throw err } - var nodes = Object.keys(dataNodes.nodes).map(function (key) { return dataNodes.nodes[key] }) - - nodes = nodes.filter( function (d) { + var nodes = dataNodes.nodes.filter( function (d) { return "firstseen" in d && "lastseen" in d }) @@ -27,7 +25,12 @@ function (moment, Router, L, GUI, numeral) { var newnodes = limit("firstseen", age, sortByKey("firstseen", nodes).filter(online)) var lostnodes = limit("lastseen", age, sortByKey("lastseen", nodes).filter(offline)) - var graphnodes = dataNodes.nodes + var graphnodes = {} + + dataNodes.nodes.forEach( function (d) { + graphnodes[d.nodeinfo.node_id] = d + }) + var graph = dataGraph.batadv graph.nodes.forEach( function (d) { @@ -75,7 +78,7 @@ function (moment, Router, L, GUI, numeral) { }) return { now: now, - timestamp: moment.utc(data[0].timestamp).local(), + timestamp: moment.utc(dataNodes.timestamp).local(), nodes: { all: nodes, new: newnodes,