update to nodes.json version 2

This commit is contained in:
Nils Schneider 2015-07-30 19:20:16 +02:00
parent 83b2a67cf4
commit 9a0b5ac672

View file

@ -5,14 +5,12 @@ function (moment, Router, L, GUI, numeral) {
var dataNodes = data[0] var dataNodes = data[0]
var dataGraph = data[1] 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 var err = "Unsupported nodes or graph version: " + dataNodes.version + " " + dataGraph.version
throw err throw err
} }
var nodes = Object.keys(dataNodes.nodes).map(function (key) { return dataNodes.nodes[key] }) var nodes = dataNodes.nodes.filter( function (d) {
nodes = nodes.filter( function (d) {
return "firstseen" in d && "lastseen" in 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 newnodes = limit("firstseen", age, sortByKey("firstseen", nodes).filter(online))
var lostnodes = limit("lastseen", age, sortByKey("lastseen", nodes).filter(offline)) 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 var graph = dataGraph.batadv
graph.nodes.forEach( function (d) { graph.nodes.forEach( function (d) {
@ -75,7 +78,7 @@ function (moment, Router, L, GUI, numeral) {
}) })
return { now: now, return { now: now,
timestamp: moment.utc(data[0].timestamp).local(), timestamp: moment.utc(dataNodes.timestamp).local(),
nodes: { nodes: {
all: nodes, all: nodes,
new: newnodes, new: newnodes,