diff --git a/lib/proportions.js b/lib/proportions.js index a0040c6..7a2e5b0 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -6,7 +6,7 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], var fwTable, hwTable, autoTable, gwTable var scale = Chroma.scale("YlGnBu").mode("lab") - function count(nodes, key, def, f) { + function count(nodes, key, f) { var dict = {} nodes.forEach( function (d) { @@ -16,7 +16,7 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], v = f(v) if (v === null) - v = def + return dict[v] = 1 + (v in dict ? dict[v] : 0) }) @@ -63,16 +63,18 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], nodeDict[d.nodeinfo.node_id] = d }) - var fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"], "n/a") - var hwDict = count(nodes, ["nodeinfo", "hardware", "model"], "n/a") - var autoDict = count(nodes, ["nodeinfo", "software", "autoupdater"], "deaktiviert", function (d) { - if (d === null || !d.enabled) + var fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"]) + var hwDict = count(nodes, ["nodeinfo", "hardware", "model"]) + var autoDict = count(nodes, ["nodeinfo", "software", "autoupdater"], function (d) { + if (d === null) return null - else + else if (d.enabled) return d.branch + else + return "(deaktiviert)" }) - var gwDict = count(onlineNodes, ["statistics", "gateway"], "n/a", function (d) { + var gwDict = count(onlineNodes, ["statistics", "gateway"], function (d) { if (d === null) return null