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 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,