diff --git a/data/resolver.2.bin b/data/resolver.2.bin index e89d388..a3e76c2 100644 Binary files a/data/resolver.2.bin and b/data/resolver.2.bin differ diff --git a/templates/index.html b/templates/index.html index 91b62b3..023c86c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -25,7 +25,7 @@ font-size: 16px; font-family: "Menlo", "Consolas", "Andale Mono", monospace; } - .menu { + .menu, .status { break-after: always; margin-bottom: 16px; } @@ -59,6 +59,8 @@ +
+ {% endif %} diff --git a/templates/index.js b/templates/index.js index eb8df8e..4144f8d 100644 --- a/templates/index.js +++ b/templates/index.js @@ -53,6 +53,18 @@ function render() { let resort = false; let tbody = document.getElementById("nodes"); + const status = nodes + .filter((node) => node.status === 'online') + .reduce((acc, node) => { + const network = node.network; + if (!acc[network]) { + acc[network] = { connections: 0, capacity: 0 }; + } + acc[network].connections += node.connections; + acc[network].capacity += node.capacity; + return acc; + }, {}); + window.nodes.forEach((node) => { let { version, @@ -83,15 +95,24 @@ function render() { el.className = filter(node, ctx); let load = (connections / capacity * 100.0).toFixed(2); + let connections_ = connections.toLocaleString(); + let capacity_ = capacity.toLocaleString(); el.innerHTML = `${sid}:${uid}${service}${version}${fqdn}${protocol}${encoding}${network}${status}`; if (status != "offline") { - el.innerHTML += `${connections}/${capacity}${load}%`; + el.innerHTML += `${connections_}/${capacity_}${load}%`; } }); if (resort) { sort(); } + + document.getElementById('status').innerText = Object.entries(status).map(([network, status]) => { + let load = (status.connections / status.capacity * 100.0).toFixed(2); + let connections = status.connections.toLocaleString(); + let capacity = status.capacity.toLocaleString(); + return `${network}: ${connections}/${capacity} ${load}%`; + }).join(' '); } function sort() {