Count Clients in a Mesh (#61)
This functions count all clients in a meshcloud. It count over wireless and cable links not over VPN links via l2tp or fastd.
This commit is contained in:
parent
00a8e5117d
commit
808b8c1986
|
@ -133,14 +133,70 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
|
||||||
if (!d.flags.online)
|
if (!d.flags.online)
|
||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
|
var meshclients = getMeshClients(d)
|
||||||
|
resetMeshClients(d)
|
||||||
|
var before = " ("
|
||||||
|
var after = " in der lokalen Wolke)"
|
||||||
return function (el) {
|
return function (el) {
|
||||||
el.appendChild(document.createTextNode(d.statistics.clients > 0 ? d.statistics.clients : "keine"))
|
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"))
|
el.appendChild(document.createElement("br"))
|
||||||
|
|
||||||
var span = document.createElement("span")
|
var span = document.createElement("span")
|
||||||
span.classList.add("clients")
|
span.classList.add("clients")
|
||||||
span.textContent = " ".repeat(d.statistics.clients)
|
span.textContent = " ".repeat(d.statistics.clients)
|
||||||
el.appendChild(span)
|
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, "Webseite", showPages(d))
|
||||||
attributeEntry(attributes, "Gewähltes Gateway", showGateway(d, router))
|
attributeEntry(attributes, "Gewähltes Gateway", showGateway(d, router))
|
||||||
attributeEntry(attributes, "Autom. Updates", showAutoupdate(d))
|
attributeEntry(attributes, "Autom. Updates", showAutoupdate(d))
|
||||||
attributeEntry(attributes, "Clients", showClients(d))
|
attributeEntry(attributes, "Clients", showClients(d), showMeshClients(d))
|
||||||
|
|
||||||
el.appendChild(attributes)
|
el.appendChild(attributes)
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,13 @@ table.attributes td {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.infobox .clientsMesh {
|
||||||
|
font-family: "ionicons";
|
||||||
|
color: #dbdbdb;
|
||||||
|
word-spacing: -0.2em;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
.infobox {
|
.infobox {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0.25em 0;
|
padding: 0.25em 0;
|
||||||
|
|
Loading…
Reference in a new issue