forcegraph: show links with unknown nodes

This commit is contained in:
Milan Pässler 2016-02-27 14:43:27 +01:00
commit 97a00b6925
7 changed files with 36 additions and 24 deletions

View file

@ -66,10 +66,7 @@ function (moment, Router, L, GUI, numeral) {
})
graph.links.forEach( function (d) {
if (graph.nodes[d.source].node)
d.source = graph.nodes[d.source]
else
d.source = undefined
d.source = graph.nodes[d.source]
if (graph.nodes[d.target].node)
d.target = graph.nodes[d.target]
@ -78,14 +75,19 @@ function (moment, Router, L, GUI, numeral) {
})
var links = graph.links.filter( function (d) {
return d.source !== undefined && d.target !== undefined
return d.target !== undefined
})
links.forEach( function (d) {
var ids = [d.source.node.nodeinfo.node_id, d.target.node.nodeinfo.node_id]
d.id = ids.sort().join("-")
var unknown = (d.source.node === undefined)
var ids
if (unknown)
ids = [d.source.id.replace(/:/g, ""), d.target.node.nodeinfo.node_id]
else
ids = [d.source.node.nodeinfo.node_id, d.target.node.nodeinfo.node_id]
d.id = ids.join("-")
if (!("location" in d.source.node.nodeinfo && "location" in d.target.node.nodeinfo))
if (unknown || !("location" in d.source.node.nodeinfo && "location" in d.target.node.nodeinfo))
return
d.latlngs = []
@ -100,10 +102,6 @@ function (moment, Router, L, GUI, numeral) {
})
links.forEach( function (d) {
d.source.node.neighbours.push({ node: d.target.node, link: d, incoming: false })
d.target.node.neighbours.push({ node: d.source.node, link: d, incoming: true })
if (d.type !== "tunnel")
d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1
if (d.type === "tunnel")
d.type = "VPN"
else if (d.type === "wireless")
@ -112,6 +110,15 @@ function (moment, Router, L, GUI, numeral) {
d.type = "Kabel"
else
d.type = "N/A"
var unknown = (d.source.node === undefined)
if (unknown) {
d.target.node.neighbours.push({ id: d.source.id, link: d, incoming: true })
return
}
d.source.node.neighbours.push({ node: d.target.node, link: d, incoming: false })
d.target.node.neighbours.push({ node: d.source.node, link: d, incoming: true })
if (d.type !== "VPN")
d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1
})
links.sort( function (a, b) {