Browse Source

meshstats: show number of new and lost nodes

Nils Schneider 9 years ago
parent
commit
3c77af5ced
1 changed files with 11 additions and 2 deletions
  1. 11 2
      lib/meshstats.js

+ 11 - 2
lib/meshstats.js

@@ -6,6 +6,8 @@ define(function () {
     self.setData = function (d) {
       var totalNodes = sum(d.nodes.all.map(one))
       var totalOnlineNodes = sum(d.nodes.all.filter(online).map(one))
+      var totalNewNodes = sum(d.nodes.new.map(one))
+      var totalLostNodes = sum(d.nodes.lost.map(one))
       var totalClients = sum(d.nodes.all.filter(online).map( function (d) {
         return d.statistics.clients
       }))
@@ -13,8 +15,15 @@ define(function () {
         return d.flags.gateway
       }).map(one))
 
-      stats.textContent = "Insgesamt " + totalNodes + " Knoten, " +
-                          "davon " + totalOnlineNodes + " online, " +
+      var nodetext = [{ count: totalOnlineNodes, label: "online" },
+                      { count: totalNewNodes, label: "neu" },
+                      { count: totalLostNodes, label: "verschwunden" }
+                     ].filter( function (d) { return d.count > 0 } )
+                      .map( function (d) { return [d.count, d.label].join(" ") } )
+                      .join(", ")
+
+      stats.textContent = totalNodes + " Knoten " +
+                          "(" + nodetext + ") " +
                           totalClients + " Clients, " +
                           totalGateways + " Gateways"