infobox/node: resolve nexthop and gateway from data

not perfect yet: the mac address doesn't always match
This commit is contained in:
Milan Paessler 2016-11-19 02:17:08 +01:00
commit 9e7049c9e3
4 changed files with 30 additions and 8 deletions

View file

@ -311,7 +311,18 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
return link
}
function showGateway(d, router) {
function lookupNode(d, nodeDict) {
if (!d)
return null
var node = nodeDict[d.substr(9)]
if (!node)
return d
return {node: node}
}
function showGateway(d, router, nodeDict) {
var nh
if (dictGet(d.statistics, ["nexthop"]))
nh = dictGet(d.statistics, ["nexthop"])
@ -322,12 +333,12 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
if (!gw) return null
return function (el) {
if (nh) {
el.appendChild(createLink(nh, router))
if (gw !== nh)
el.appendChild(createLink(lookupNode(nh, nodeDict), router))
if (nh.substr(9) !== gw.substr(9))
el.appendChild(document.createTextNode(" -> ... -> "))
}
if (gw !== nh)
el.appendChild(createLink(gw, router))
if (!nh || nh.substr(9) !== gw.substr(9))
el.appendChild(createLink(lookupNode(gw, nodeDict), router))
}
}
@ -408,7 +419,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
return showStat(o, subst)
}
return function(config, el, router, d) {
return function(config, el, router, d, nodeDict) {
var attributes = document.createElement("table")
attributes.classList.add("attributes")
@ -455,7 +466,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
attributeEntry(attributes, "Arbeitsspeicher", showRAM(d))
attributeEntry(attributes, "IP Adressen", showIPs(d))
attributeEntry(attributes, "Webseite", showPages(d))
attributeEntry(attributes, "Gewähltes Gateway", showGateway(d, router))
attributeEntry(attributes, "Gewähltes Gateway", showGateway(d, router, nodeDict))
attributeEntry(attributes, "Autom. Updates", showAutoupdate(d))
attributeEntry(attributes, "Clients", showClients(d), showMeshClients(d))