Fully resolve gateway names in hopglass (#57)

Depends on hopglass/hopglass-server#56
This commit is contained in:
Marvin W 2016-08-05 19:47:25 +02:00 committed by PetaByteBoy // Milan Pässler
commit cb065d8d07
4 changed files with 48 additions and 23 deletions

View file

@ -240,7 +240,20 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
}
}
function showGateway(d) {
function createLink(target, router) {
var link = document.createElement("a")
if (!target) return link
var unknown = !(target.node)
link.classList.add("hostname")
link.textContent = unknown ? (target.id ? target.id : target) : target.node.nodeinfo.hostname
if (!unknown) {
link.href = "#"
link.onclick = router.node(target.node)
}
return link
}
function showGateway(d, router) {
var nh
if (dictGet(d.statistics, ["nexthop"]))
nh = dictGet(d.statistics, ["nexthop"])
@ -248,13 +261,16 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
nh = dictGet(d.statistics, ["gateway_nexthop"])
var gw = dictGet(d.statistics, ["gateway"])
if (gw && !nh)
return gw
if (gw && nh)
if (gw === nh)
return gw
else
return nh + " -> ... -> " + gw
if (!gw) return null
return function (el) {
if (nh) {
el.appendChild(createLink(nh, router))
if (gw !== nh)
el.appendChild(document.createTextNode(" -> ... -> "))
}
if (gw !== nh)
el.appendChild(createLink(gw, router))
}
}
function showPages(d) {
@ -333,7 +349,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))
attributeEntry(attributes, "Gewähltes Gateway", showGateway(d, router))
attributeEntry(attributes, "Autom. Updates", showAutoupdate(d))
attributeEntry(attributes, "Clients", showClients(d))
@ -392,13 +408,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
tr.appendChild(td1)
var td2 = document.createElement("td")
var a1 = document.createElement("a")
a1.classList.add("hostname")
a1.textContent = unknown ? d.id : d.node.nodeinfo.hostname
if (!unknown)
a1.href = "#"
a1.onclick = router.node(d.node)
td2.appendChild(a1)
td2.appendChild(createLink(d, router))
if (!unknown && has_location(d.node)) {
var span = document.createElement("span")