diff --git a/lib/datadistributor.js b/lib/datadistributor.js index 67cf7eb..72d1f15 100644 --- a/lib/datadistributor.js +++ b/lib/datadistributor.js @@ -34,6 +34,11 @@ define(["filters/nodefilter"], function (NodeFilter) { filteredData = new NodeFilter(filter)(data) + filteredData.nodeDict = {} + filteredData.nodes.all.forEach(function (d) { + filteredData.nodeDict[dictGet(d, ["nodeinfo", "network", "mac"]).substr(9)] = d + }) + targets.forEach( function (t) { t.setData(filteredData) }) diff --git a/lib/gui.js b/lib/gui.js index 4ce989d..2e85f8d 100644 --- a/lib/gui.js +++ b/lib/gui.js @@ -85,6 +85,7 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Legend, Linklist, fanoutUnfiltered.add(meshstats) fanoutUnfiltered.add(newnodeslist) fanoutUnfiltered.add(lostnodeslist) + fanoutUnfiltered.add(infobox) fanout.add(nodelist) fanout.add(linklist) fanout.add(statistics) diff --git a/lib/infobox/main.js b/lib/infobox/main.js index deebc03..d6e0195 100644 --- a/lib/infobox/main.js +++ b/lib/infobox/main.js @@ -2,6 +2,7 @@ define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Nod return function (config, sidebar, router) { var self = this var el + var nodeDict function destroy() { if (el && el.parentNode) { @@ -33,7 +34,7 @@ define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Nod self.gotoNode = function (d) { create() - new Node(config, el, router, d) + new Node(config, el, router, d, nodeDict) } self.gotoLink = function (d) { @@ -46,6 +47,10 @@ define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Nod new Location(config, el, router, d) } + self.setData = function (d) { + nodeDict = d.nodeDict + } + return self } }) diff --git a/lib/infobox/node.js b/lib/infobox/node.js index f8e0228..4ce939e 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -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))