From c0ab7afa15e63852809c45690c1f62c69a027404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20P=C3=A4ssler?= Date: Mon, 28 Dec 2015 17:53:10 +0100 Subject: [PATCH] nodelist: show number of neighbours --- lib/main.js | 4 ++++ lib/nodelist.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index a363537..e06f000 100644 --- a/lib/main.js +++ b/lib/main.js @@ -102,6 +102,10 @@ function (moment, Router, L, GUI, numeral) { links.forEach( function (d) { d.source.node.neighbours.push({ node: d.target.node, link: d }) d.target.node.neighbours.push({ node: d.source.node, link: d }) + if (!d.vpn) { + d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1 + d.target.node.meshlinks = d.target.node.meshlinks ? d.target.node.meshlinks + 1 : 1 + } }) return { now: now, diff --git a/lib/nodelist.js b/lib/nodelist.js index 8edb3be..cf952a0 100644 --- a/lib/nodelist.js +++ b/lib/nodelist.js @@ -31,6 +31,12 @@ define(["sorttable", "virtual-dom", "numeral"], function (SortTable, V, numeral) }, reverse: true }, + { name: "Neighbours", + sort: function (a, b) { + return a.meshlinks - b.meshlinks + }, + reverse: true + }, { name: "Clients", sort: function (a, b) { return ("clients" in a.statistics ? a.statistics.clients : -1) - @@ -54,9 +60,10 @@ define(["sorttable", "virtual-dom", "numeral"], function (SortTable, V, numeral) var td1 = V.h("td", td1Content) var td2 = V.h("td", showUptime(d.uptime)) - var td3 = V.h("td", numeral("clients" in d.statistics ? d.statistics.clients : "").format("0,0")) + var td3 = V.h("td", d.meshlinks.toString()) + var td4 = V.h("td", numeral("clients" in d.statistics ? d.statistics.clients : "").format("0,0")) - return V.h("tr", [td1, td2, td3]) + return V.h("tr", [td1, td2, td3, td4]) } var table = new SortTable(headings, 0, renderRow) @@ -76,6 +83,7 @@ define(["sorttable", "virtual-dom", "numeral"], function (SortTable, V, numeral) var data = d.nodes.all.map(function (e) { var n = Object.create(e) n.uptime = getUptime(d.now, e) || 0 + n.meshlinks = e.meshlinks || 0 return n })