refactor setData
This commit is contained in:
parent
3e143435e6
commit
a031ac336d
7 changed files with 47 additions and 35 deletions
32
lib/main.js
32
lib/main.js
|
|
@ -18,8 +18,8 @@ function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshsta
|
|||
document.body.insertBefore(map.div, document.body.firstChild)
|
||||
|
||||
meshstats = new Meshstats()
|
||||
newnodeslist = new SimpleNodelist(config, "firstseen", router, "Neue Knoten")
|
||||
lostnodeslist = new SimpleNodelist(config, "lastseen", router, "Verschwundene Knoten")
|
||||
newnodeslist = new SimpleNodelist(config, "new", "firstseen", router, "Neue Knoten")
|
||||
lostnodeslist = new SimpleNodelist(config, "lost", "lastseen", router, "Verschwundene Knoten")
|
||||
nodelist = new Nodelist(router)
|
||||
linklist = new Linklist(linkScale, router)
|
||||
|
||||
|
|
@ -37,8 +37,7 @@ function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshsta
|
|||
}
|
||||
|
||||
function handleData(data) {
|
||||
var nodedict = data[0]
|
||||
var nodes = Object.keys(nodedict.nodes).map(function (key) { return nodedict.nodes[key] })
|
||||
var nodes = Object.keys(data[0].nodes).map(function (key) { return data[0].nodes[key] })
|
||||
|
||||
nodes = nodes.filter( function (d) {
|
||||
return "firstseen" in d && "lastseen" in d
|
||||
|
|
@ -99,13 +98,15 @@ function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshsta
|
|||
d.target.node.neighbours.push({ node: d.source.node, link: d })
|
||||
})
|
||||
|
||||
map.setData(now, nodes, links, newnodes, lostnodes)
|
||||
meshstats.setData(nodes)
|
||||
nodelist.setData(now, nodes)
|
||||
linklist.setData(links)
|
||||
newnodeslist.setData(newnodes)
|
||||
lostnodeslist.setData(lostnodes)
|
||||
router.setData(nodes, links)
|
||||
return { now: now,
|
||||
timestamp: data[0].timestamp,
|
||||
nodes: {
|
||||
all: nodes,
|
||||
new: newnodes,
|
||||
lost: lostnodes
|
||||
},
|
||||
links: links
|
||||
}
|
||||
}
|
||||
|
||||
var urls = [ config.dataPath + "nodes.json",
|
||||
|
|
@ -118,6 +119,15 @@ function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshsta
|
|||
return d
|
||||
})
|
||||
.then(handleData)
|
||||
.then(function (d) {
|
||||
map.setData(d)
|
||||
meshstats.setData(d)
|
||||
nodelist.setData(d)
|
||||
linklist.setData(d)
|
||||
newnodeslist.setData(d)
|
||||
lostnodeslist.setData(d)
|
||||
router.setData(d)
|
||||
})
|
||||
.then(function () { router.start() })
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue