From 848b5b7384c424a308fc0badfa06e87f75e744b3 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Wed, 8 Jul 2015 00:30:29 +0200 Subject: [PATCH] proportions: add online/offline statistics --- lib/proportions.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/proportions.js b/lib/proportions.js index d595649..b30f206 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -5,6 +5,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], var self = this var scale = Chroma.scale("YlGnBu").mode("lab") + var statusTable = document.createElement("table") + statusTable.classList.add("proportion") + var fwTable = document.createElement("table") fwTable.classList.add("proportion") @@ -110,6 +113,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], nodeDict[d.nodeinfo.node_id] = d }) + var statusDict = count(nodes, ["flags", "online"], function (d) { + return d ? "online" : "offline" + }) var fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"]) var hwDict = count(nodes, ["nodeinfo", "hardware", "model"]) var geoDict = count(nodes, ["nodeinfo", "location"], function (d) { @@ -137,6 +143,7 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], return d }) + fillTable(statusTable, statusDict.sort(function (a, b) { return b[1] - a[1] })) fillTable(fwTable, fwDict.sort(function (a, b) { return b[1] - a[1] })) fillTable(hwTable, hwDict.sort(function (a, b) { return b[1] - a[1] })) fillTable(geoTable, geoDict.sort(function (a, b) { return b[1] - a[1] })) @@ -146,6 +153,11 @@ define(["chroma-js", "virtual-dom", "numeral-intl"], self.render = function (el) { var h2 + h2 = document.createElement("h2") + h2.textContent = "Status" + el.appendChild(h2) + el.appendChild(statusTable) + h2 = document.createElement("h2") h2.textContent = "Firmwareversionen" el.appendChild(h2)