create meshstats in javascript

This commit is contained in:
Nils Schneider 2015-03-23 12:58:16 +01:00
parent 635d40e331
commit 8fcbf0ae53
2 changed files with 14 additions and 17 deletions

View File

@ -303,13 +303,6 @@
<div id="sidebardata"> <div id="sidebardata">
<div id="infobox" class="hidden"> <div id="infobox" class="hidden">
</div> </div>
<h2>Meshdaten</h2>
<p id="meshstats">
</p>
<p id="timestamp">
</p>
</div> </div>
</div> </div>
</body> </body>

View File

@ -163,15 +163,11 @@ function handle_data(config, map) {
gotoAnything.addMarkers(markers) gotoAnything.addMarkers(markers)
showMeshstats(document.getElementById("sidebardata"), nodes)
mkNodesList(document.getElementById("sidebardata"), config.showContact, "firstseen", gotoAnything.node, "Neue Knoten", newnodes) mkNodesList(document.getElementById("sidebardata"), config.showContact, "firstseen", gotoAnything.node, "Neue Knoten", newnodes)
mkNodesList(document.getElementById("sidebardata"), config.showContact, "lastseen", gotoAnything.node, "Verschwundene Knoten", lostnodes) mkNodesList(document.getElementById("sidebardata"), config.showContact, "lastseen", gotoAnything.node, "Verschwundene Knoten", lostnodes)
mkLinkList(document.getElementById("sidebardata"), gotoAnything.link, links) mkLinkList(document.getElementById("sidebardata"), gotoAnything.link, links)
showMeshstats(document.getElementById("meshstats"), nodes)
var timestamp = document.getElementById("timestamp")
timestamp.textContent = "Diese Daten sind " + moment.utc(nodes.timestamp).fromNow(true) + " alt."
var historyDict = { nodes: {}, links: {} } var historyDict = { nodes: {}, links: {} }
nodes.forEach( function (d) { nodes.forEach( function (d) {
@ -465,19 +461,27 @@ function one() {
} }
function showMeshstats(el, nodes) { function showMeshstats(el, nodes) {
var totalNodes = sum(nodes.filter(online).map(one)) var h2 = document.createElement("h2")
h2.textContent = "Übersicht"
el.appendChild(h2)
var p = document.createElement("p")
var totalNodes = sum(nodes.filter(online).map(one))
var totalClients = sum(nodes.filter(online).map( function (d) { var totalClients = sum(nodes.filter(online).map( function (d) {
return d.statistics.clients return d.statistics.clients
})) }))
var totalGateways = sum(nodes.filter(online).filter( function (d) { var totalGateways = sum(nodes.filter(online).filter( function (d) {
return d.flags.gateway return d.flags.gateway
}).map(one)) }).map(one))
el.textContent = totalNodes + " Knoten (online), " + p.textContent = totalNodes + " Knoten (online), " +
totalClients + " Clients, " + totalClients + " Clients, " +
totalGateways + " Gateways" totalGateways + " Gateways"
p.appendChild(document.createElement("br"))
p.appendChild(document.createTextNode("Diese Daten sind " + moment.utc(nodes.timestamp).fromNow(true) + " alt."))
el.appendChild(p)
} }
function infobox() { function infobox() {