2015-03-29 19:10:24 +02:00
|
|
|
define(function () {
|
2015-03-25 15:33:36 +01:00
|
|
|
return function () {
|
|
|
|
var self = this
|
2015-04-02 19:59:07 +02:00
|
|
|
var stats, timestamp
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2015-03-29 17:48:25 +02: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 15:33:36 +01:00
|
|
|
return d.statistics.clients
|
|
|
|
}))
|
2015-03-29 17:48:25 +02:00
|
|
|
var totalGateways = sum(d.nodes.all.filter(online).filter( function (d) {
|
2015-03-25 15:33:36 +01:00
|
|
|
return d.flags.gateway
|
|
|
|
}).map(one))
|
|
|
|
|
2015-04-02 19:59:07 +02:00
|
|
|
stats.textContent = totalNodes + " Knoten (online), " +
|
|
|
|
totalClients + " Clients, " +
|
|
|
|
totalGateways + " Gateways"
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2015-04-02 19:59:07 +02:00
|
|
|
timestamp.textContent = "Diese Daten sind von " + d.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)
|
|
|
|
|
2015-04-02 19:59:07 +02:00
|
|
|
var p = document.createElement("p")
|
2015-03-25 15:33:36 +01:00
|
|
|
el.appendChild(p)
|
2015-04-02 19:59:07 +02:00
|
|
|
stats = document.createTextNode("")
|
|
|
|
p.appendChild(stats)
|
|
|
|
p.appendChild(document.createElement("br"))
|
|
|
|
timestamp = document.createTextNode("")
|
|
|
|
p.appendChild(timestamp)
|
2015-03-25 15:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
})
|