Bläddra i källkod

proportions: add online/offline statistics

Nils Schneider 9 år sedan
förälder
incheckning
848b5b7384
1 ändrade filer med 12 tillägg och 0 borttagningar
  1. 12 0
      lib/proportions.js

+ 12 - 0
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)