From 94662cb3dc9b82b5fd809ae812accd228bcd7b87 Mon Sep 17 00:00:00 2001 From: Milan Pssler Date: Sat, 19 Nov 2016 10:57:30 +0100 Subject: [PATCH] proportions: lookup gateway name --- lib/proportions.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/proportions.js b/lib/proportions.js index f5b0b26..3d18103 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -23,7 +23,7 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc var uplinkTable = document.createElement("table") uplinkTable.classList.add("proportion") - var gwNodesTable = document.createElement("table") + var gwNodesTable = document.createElement("table") gwNodesTable.classList.add("proportion") var gwClientsTable = document.createElement("table") @@ -119,9 +119,8 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc var onlineNodes = data.nodes.all.filter(online) var nodes = onlineNodes.concat(data.nodes.lost) var nodeDict = {} - - data.nodes.all.forEach(function (d) { - nodeDict[d.nodeinfo.node_id] = d + data.graph.nodes.forEach(function (d) { + nodeDict[d.id.substr(0, 8)] = d }) var statusDict = count(nodes, ["flags", "online"], function (d) { @@ -156,11 +155,12 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc if (d === null) return null - if (d.node) - return d.node.nodeinfo.hostname - - if (d.id) - return d.id + var n = nodeDict[d.substr(0, 8)] + if (!n) + return d + var name = dictGet(n, ["node", "nodeinfo", "hostname"]) + if (name) + return name return d }) @@ -169,11 +169,12 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc if (d === null) return null - if (d.node) - return d.node.nodeinfo.hostname - - if (d.id) - return d.id + var n = nodeDict[d.substr(0, 8)] + if (!n) + return d + var name = dictGet(n, ["node", "nodeinfo", "hostname"]) + if (name) + return name return d })