hopglass/lib/meshstats.js

35 lines
997 B
JavaScript
Raw Normal View History

define(["moment"], function (moment) {
2015-03-25 15:33:36 +01:00
return function () {
var self = this
var p
self.setData = function (nodes) {
var totalNodes = sum(nodes.filter(online).map(one))
var totalClients = sum(nodes.filter(online).map( function (d) {
return d.statistics.clients
}))
var totalGateways = sum(nodes.filter(online).filter( function (d) {
return d.flags.gateway
}).map(one))
p.textContent = totalNodes + " Knoten (online), " +
totalClients + " Clients, " +
totalGateways + " Gateways"
p.appendChild(document.createElement("br"))
2015-03-26 02:00:36 +01:00
p.appendChild(document.createTextNode("Diese Daten sind von " + moment(nodes.timestamp).format("LLLL") + "."))
2015-03-25 15:33:36 +01:00
}
self.render = function (el) {
var h2 = document.createElement("h2")
h2.textContent = "Übersicht"
el.appendChild(h2)
p = document.createElement("p")
el.appendChild(p)
}
return self
}
})