2015-03-29 01:35:10 +00:00
|
|
|
define(["moment"], function (moment) {
|
2015-03-25 14:33:36 +00:00
|
|
|
return function () {
|
|
|
|
var self = this
|
|
|
|
var p
|
|
|
|
|
2015-03-29 15:48:25 +00:00
|
|
|
self.setData = function (d) {
|
|
|
|
var totalNodes = sum(d.nodes.all.filter(online).map(one))
|
|
|
|
var totalClients = sum(d.nodes.all.filter(online).map( function (d) {
|
2015-03-25 14:33:36 +00:00
|
|
|
return d.statistics.clients
|
|
|
|
}))
|
2015-03-29 15:48:25 +00:00
|
|
|
var totalGateways = sum(d.nodes.all.filter(online).filter( function (d) {
|
2015-03-25 14:33:36 +00:00
|
|
|
return d.flags.gateway
|
|
|
|
}).map(one))
|
|
|
|
|
|
|
|
p.textContent = totalNodes + " Knoten (online), " +
|
|
|
|
totalClients + " Clients, " +
|
|
|
|
totalGateways + " Gateways"
|
|
|
|
|
|
|
|
p.appendChild(document.createElement("br"))
|
2015-03-29 15:48:25 +00:00
|
|
|
p.appendChild(document.createTextNode("Diese Daten sind von " + moment(d.timestamp).format("LLLL") + "."))
|
2015-03-25 14:33:36 +00: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
|
|
|
|
}
|
|
|
|
})
|