Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Jul 27, 2024
1 parent 440fbf8 commit 7246491
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Binary file modified data/resolver.2.bin
Binary file not shown.
4 changes: 3 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
font-size: 16px;
font-family: "Menlo", "Consolas", "Andale Mono", monospace;
}
.menu {
.menu, .status {
break-after: always;
margin-bottom: 16px;
}
Expand Down Expand Up @@ -59,6 +59,8 @@
</tr>
</table>
</div>
<div class="status"><table><tr><td id="status"></td></tr></table></div>

{% endif %}
</body>
</html>
23 changes: 22 additions & 1 deletion templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = `<td>${sid}:${uid}</td><td>${service}</td><td>${version}</td><td>${fqdn}</td><td>${protocol}</td><td>${encoding}</td><td>${network}</td><td>${status}</td>`;
if (status != "offline") {
el.innerHTML += `<td class='wide right'>${connections}/${capacity}</td><td class='wide right'>${load}%</td>`;
el.innerHTML += `<td class='wide right'>${connections_}/${capacity_}</td><td class='wide right'>${load}%</td>`;
}
});

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() {
Expand Down

0 comments on commit 7246491

Please sign in to comment.