nodelist: show number of neighbours

This commit is contained in:
Milan Pässler 2015-12-28 17:53:10 +01:00
parent 80afc7d162
commit c0ab7afa15
2 changed files with 14 additions and 2 deletions

View file

@ -102,6 +102,10 @@ function (moment, Router, L, GUI, numeral) {
links.forEach( function (d) { links.forEach( function (d) {
d.source.node.neighbours.push({ node: d.target.node, link: d }) d.source.node.neighbours.push({ node: d.target.node, link: d })
d.target.node.neighbours.push({ node: d.source.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, return { now: now,

View file

@ -31,6 +31,12 @@ define(["sorttable", "virtual-dom", "numeral"], function (SortTable, V, numeral)
}, },
reverse: true reverse: true
}, },
{ name: "Neighbours",
sort: function (a, b) {
return a.meshlinks - b.meshlinks
},
reverse: true
},
{ name: "Clients", { name: "Clients",
sort: function (a, b) { sort: function (a, b) {
return ("clients" in a.statistics ? a.statistics.clients : -1) - 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 td1 = V.h("td", td1Content)
var td2 = V.h("td", showUptime(d.uptime)) 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) 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 data = d.nodes.all.map(function (e) {
var n = Object.create(e) var n = Object.create(e)
n.uptime = getUptime(d.now, e) || 0 n.uptime = getUptime(d.now, e) || 0
n.meshlinks = e.meshlinks || 0
return n return n
}) })