forcegraph: show links with unknown nodes

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

View file

@ -1,10 +1,13 @@
define(function () {
return function (config, el, router, d) {
var unknown = !(d.source.node)
var h2 = document.createElement("h2")
var a1 = document.createElement("a")
a1.href = "#"
a1.onclick = router.node(d.source.node)
a1.textContent = d.source.node.nodeinfo.hostname
if (!unknown) {
a1.href = "#"
a1.onclick = router.node(d.source.node)
}
a1.textContent = unknown ? d.source.id : d.source.node.nodeinfo.hostname
h2.appendChild(a1)
h2.appendChild(document.createTextNode(" → "))
var a2 = document.createElement("a")
@ -20,7 +23,7 @@ define(function () {
attributeEntry(attributes, "TQ", showTq(d))
attributeEntry(attributes, "Entfernung", showDistance(d))
attributeEntry(attributes, "Typ", d.type)
var hw1 = dictGet(d.source.node.nodeinfo, ["hardware", "model"])
var hw1 = unknown ? null : dictGet(d.source.node.nodeinfo, ["hardware", "model"])
var hw2 = dictGet(d.target.node.nodeinfo, ["hardware", "model"])
attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " " + (hw2 != null ? hw2 : "unbekannt"))

View file

@ -326,6 +326,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
var tbody = document.createElement("tbody")
d.neighbours.forEach( function (d) {
var unknown = !(d.node)
var tr = document.createElement("tr")
var td1 = document.createElement("td")
@ -335,12 +336,13 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
var td2 = document.createElement("td")
var a1 = document.createElement("a")
a1.classList.add("hostname")
a1.textContent = d.node.nodeinfo.hostname
a1.href = "#"
a1.onclick = router.node(d.node)
a1.textContent = unknown ? d.id : d.node.nodeinfo.hostname
if (!unknown)
a1.href = "#"
a1.onclick = router.node(d.node)
td2.appendChild(a1)
if (has_location(d.node)) {
if (!unknown && has_location(d.node)) {
var span = document.createElement("span")
span.classList.add("icon")
span.classList.add("ion-location")