diff --git a/lib/infobox/node.js b/lib/infobox/node.js index 0304d5f..4310548 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -133,14 +133,70 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], if (!d.flags.online) return undefined + var meshclients = getMeshClients(d) + resetMeshClients(d) + var before = " (" + var after = " in der lokalen Wolke)" return function (el) { el.appendChild(document.createTextNode(d.statistics.clients > 0 ? d.statistics.clients : "keine")) + el.appendChild(document.createTextNode(before)) + el.appendChild(document.createTextNode(meshclients > 0 ? meshclients : "keine")) + el.appendChild(document.createTextNode(after)) el.appendChild(document.createElement("br")) var span = document.createElement("span") span.classList.add("clients") span.textContent = " ".repeat(d.statistics.clients) el.appendChild(span) + + var spanmesh = document.createElement("span") + spanmesh.classList.add("clientsMesh") + spanmesh.textContent = " ".repeat(meshclients - d.statistics.clients) + el.appendChild(spanmesh) + } + } + + function getMeshClients(node) { + var meshclients = node.statistics.clients + + if (!node) + return 0 + + if (node.parsed) + return 0 + + node.parsed = 1 + node.neighbours.forEach(function (neighbour) { + if (!neighbour.link.isVPN && neighbour.node) + meshclients += getMeshClients(neighbour.node) + }) + + return meshclients + } + + function resetMeshClients(node) { + if (!node.parsed) + return + + node.parsed = 0 + + node.neighbours.forEach(function (neighbour) { + if (!neighbour.link.isVPN && neighbour.node) + resetMeshClients(neighbour.node) + }) + + return + } + + function showMeshClients(d) { + if (!d.flags.online) + return undefined + + var meshclients = getMeshClients(d) + resetMeshClients(d) + return function (el) { + el.appendChild(document.createTextNode(meshclients > 0 ? meshclients : "keine")) + el.appendChild(document.createElement("br")) } } @@ -351,7 +407,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], attributeEntry(attributes, "Webseite", showPages(d)) attributeEntry(attributes, "Gewähltes Gateway", showGateway(d, router)) attributeEntry(attributes, "Autom. Updates", showAutoupdate(d)) - attributeEntry(attributes, "Clients", showClients(d)) + attributeEntry(attributes, "Clients", showClients(d), showMeshClients(d)) el.appendChild(attributes) diff --git a/scss/main.scss b/scss/main.scss index e290144..4a7170e 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -143,6 +143,13 @@ table.attributes td { white-space: normal; } +.infobox .clientsMesh { + font-family: "ionicons"; + color: #dbdbdb; + word-spacing: -0.2em; + white-space: normal; +} + .infobox { position: relative; padding: 0.25em 0;