From 80afc7d162d929c2d6aed5ebebc87730db67b22d Mon Sep 17 00:00:00 2001 From: PetaByteBoy Date: Fri, 6 Nov 2015 21:10:43 +0100 Subject: [PATCH] statistics: re-add "Gateway-Feature" revert commit c13e648cc6ae3c6a7179652722680dcab018a1d3. --- lib/infobox/node.js | 1 + lib/meshstats.js | 8 ++++++-- lib/proportions.js | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/infobox/node.js b/lib/infobox/node.js index cde1c8d..54dd801 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -182,6 +182,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], attributes.classList.add("attributes") attributeEntry(attributes, "Status", showStatus(d)) + attributeEntry(attributes, "Gateway", d.flags.gateway ? "ja" : null) attributeEntry(attributes, "Koordinaten", showGeoURI(d)) if (config.showContact) diff --git a/lib/meshstats.js b/lib/meshstats.js index f3d7a29..f0ce186 100644 --- a/lib/meshstats.js +++ b/lib/meshstats.js @@ -11,6 +11,9 @@ define(function () { var totalClients = sum(d.nodes.all.filter(online).map( function (d) { return d.statistics.clients })) + var totalGateways = sum(d.nodes.all.filter(online).filter( function (d) { + return d.flags.gateway + }).map(one)) var nodetext = [{ count: totalOnlineNodes, label: "online" }, { count: totalNewNodes, label: "neu" }, @@ -20,8 +23,9 @@ define(function () { .join(", ") stats.textContent = totalNodes + " Knoten " + - "(" + nodetext + ") mit " + - totalClients + " Client" + ( totalClients === 1 ? "" : "s" ) + "(" + nodetext + "), " + + totalClients + " Client" + ( totalClients === 1 ? ", " : "s, " ) + + totalGateways + " Gateways" timestamp.textContent = "Diese Daten sind von " + d.timestamp.format("LLLL") + "." } diff --git a/lib/proportions.js b/lib/proportions.js index 322438b..805b30c 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -23,6 +23,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc var uplinkTable = document.createElement("table") uplinkTable.classList.add("proportion") + var gwTable = document.createElement("table") + gwTable.classList.add("proportion") + function showStatGlobal(o) { var content, caption @@ -145,12 +148,23 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc return d ? "ja" : "nein" }) + var gwDict = count(nodes, ["statistics", "gateway"], function (d) { + if (d === null) + return null + + if (d in nodeDict) + return nodeDict[d].nodeinfo.hostname + + return d + }) + fillTable("Status", statusTable, statusDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Firmware", fwTable, fwDict.sort(function (a, b) { return vercomp(b[0], a[0]) })) fillTable("Hardware", hwTable, hwDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Koordinaten", geoTable, geoDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Autom. Updates", autoTable, autoDict.sort(function (a, b) { return b[1] - a[1] })) fillTable("Uplink", uplinkTable, uplinkDict.sort(function (a, b) { return b[1] - a[1] })) + fillTable("Gewähltes Gateway", gwTable, gwDict.sort(function (a, b) { return b[1] - a[1] })) } self.render = function (el) { @@ -185,6 +199,11 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc el.appendChild(h2) el.appendChild(uplinkTable) + h2 = document.createElement("h2") + h2.textContent = "Gewählter Gateway" + el.appendChild(h2) + el.appendChild(gwTable) + if (config.globalInfos) config.globalInfos.forEach( function (globalInfo) { h2 = document.createElement("h2")