check nodes and graph version

This commit is contained in:
Nils Schneider 2015-04-07 21:10:37 +02:00
parent c6605aded6
commit c734975a3b

View file

@ -2,7 +2,15 @@ define(["config", "moment", "router", "leaflet", "gui", "numeral"],
function (config, moment, Router, L, GUI, numeral) {
return function () {
function handleData(data) {
var nodes = Object.keys(data[0].nodes).map(function (key) { return data[0].nodes[key] })
var dataNodes = data[0]
var dataGraph = data[1]
if (dataNodes.version !== 1 || 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) {
return "firstseen" in d && "lastseen" in d
@ -19,8 +27,8 @@ function (config, 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 graph = data[1].batadv
var graphnodes = data[0].nodes
var graphnodes = dataNodes.nodes
var graph = dataGraph.batadv
graph.nodes.forEach( function (d) {
if (d.node_id in graphnodes)
@ -108,6 +116,7 @@ function (config, moment, Router, L, GUI, numeral) {
}, 60000)
})
.catch(function (e) {
document.body.textContent = e
console.log(e)
})
}