history: add simple mesh statistics

This commit is contained in:
Nils Schneider 2015-03-21 10:40:58 +01:00
parent c27653a0e2
commit 50c5955564
2 changed files with 36 additions and 0 deletions

View file

@ -176,6 +176,10 @@
Funktioniert nur in wirklich modernen Browsern.
</p>
<h2>Meshdaten</h2>
<p id="meshstats">
</p>
<h2>Neue Knoten</h2>
<table>
<tbody id="newnodes">

View file

@ -158,6 +158,8 @@ function handle_data(config, map) {
addToList(document.getElementById("newnodes"), config.showContact, "firstseen", markers, newnodes)
addToList(document.getElementById("lostnodes"), config.showContact, "lastseen", markers, lostnodes)
addToLongLinksList(document.getElementById("longlinks"), markers, longlinks)
showMeshstats(document.getElementById("meshstats"), nodes)
}
}
@ -336,3 +338,33 @@ function addToList(el, showContact, tf, markers, list) {
el.appendChild(row)
})
}
function sum(a) {
return a.reduce( function (a, b) {
return a + b
}, 0)
}
function one() {
return 1
}
function showMeshstats(el, 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))
el.textContent = totalNodes + " Knoten (online), " +
totalClients + " Clients, " +
totalGateways + " Gateways"
}
function showNodeinfo(d) {
var object = document.getElementById("nodeinfo")
}