proportions: add online/offline statistics

This commit is contained in:
Nils Schneider 2015-07-08 00:30:29 +02:00
parent ec49c9d59b
commit 848b5b7384

View file

@ -5,6 +5,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl"],
var self = this var self = this
var scale = Chroma.scale("YlGnBu").mode("lab") var scale = Chroma.scale("YlGnBu").mode("lab")
var statusTable = document.createElement("table")
statusTable.classList.add("proportion")
var fwTable = document.createElement("table") var fwTable = document.createElement("table")
fwTable.classList.add("proportion") fwTable.classList.add("proportion")
@ -110,6 +113,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl"],
nodeDict[d.nodeinfo.node_id] = d 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 fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"])
var hwDict = count(nodes, ["nodeinfo", "hardware", "model"]) var hwDict = count(nodes, ["nodeinfo", "hardware", "model"])
var geoDict = count(nodes, ["nodeinfo", "location"], function (d) { var geoDict = count(nodes, ["nodeinfo", "location"], function (d) {
@ -137,6 +143,7 @@ define(["chroma-js", "virtual-dom", "numeral-intl"],
return d 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(fwTable, fwDict.sort(function (a, b) { return b[1] - a[1] }))
fillTable(hwTable, hwDict.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] })) 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) { self.render = function (el) {
var h2 var h2
h2 = document.createElement("h2")
h2.textContent = "Status"
el.appendChild(h2)
el.appendChild(statusTable)
h2 = document.createElement("h2") h2 = document.createElement("h2")
h2.textContent = "Firmwareversionen" h2.textContent = "Firmwareversionen"
el.appendChild(h2) el.appendChild(h2)