Network as a regular resources cell next to Disk, with two stacked bar-sized graphs

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
neil 2026-10-26 10:41:58 -07:00
parent 3ae03160e8
commit a963dc1bf4
No known key found for this signature in database
3 changed files with 12 additions and 11 deletions

View file

@ -89,8 +89,8 @@ function renderHost() {
setBar('#b-swap', h.swap_total ? (100 * h.swap_used) / h.swap_total : 0); setBar('#b-swap', h.swap_total ? (100 * h.swap_used) / h.swap_total : 0);
$('#m-disk').textContent = `${fmtBytes(h.disk_used)} / ${fmtBytes(h.disk_total)}`; $('#m-disk').textContent = `${fmtBytes(h.disk_used)} / ${fmtBytes(h.disk_total)}`;
setBar('#b-disk', (100 * h.disk_used) / h.disk_total); setBar('#b-disk', (100 * h.disk_used) / h.disk_total);
$('#m-rx').textContent = fmtRate(h.net_rx_rate); $('#m-rx').textContent = `↓ ${fmtRate(h.net_rx_rate)}`;
$('#m-tx').textContent = fmtRate(h.net_tx_rate); $('#m-tx').textContent = `↑ ${fmtRate(h.net_tx_rate)}`;
const hist = h.net_history || []; const hist = h.net_history || [];
drawGraph('#g-rx', hist.map((x) => x[0])); drawGraph('#g-rx', hist.map((x) => x[0]));
drawGraph('#g-tx', hist.map((x) => x[1])); drawGraph('#g-tx', hist.map((x) => x[1]));
@ -110,7 +110,7 @@ function drawGraph(id, vals) {
svg.querySelector('.area').setAttribute('d', line && `${line}L100,24L${x0.toFixed(2)},24Z`); svg.querySelector('.area').setAttribute('d', line && `${line}L100,24L${x0.toFixed(2)},24Z`);
let title = svg.querySelector('title'); let title = svg.querySelector('title');
if (!title) title = svg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'title')); if (!title) title = svg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'title'));
title.textContent = `Peak ${fmtRate(peak)} in the last ${(GRAPH_POINTS * 3) / 60} minutes`; title.textContent = `${id === '#g-rx' ? 'Download' : 'Upload'}: peak ${fmtRate(peak)} in the last ${(GRAPH_POINTS * 3) / 60} minutes`;
} }
function fmtDuration(sec) { function fmtDuration(sec) {

View file

@ -42,10 +42,9 @@
<div class="meter"><div class="meter-label"><span>Memory</span><span id="m-mem">–</span></div><div class="bar"><div id="b-mem"></div></div></div> <div class="meter"><div class="meter-label"><span>Memory</span><span id="m-mem">–</span></div><div class="bar"><div id="b-mem"></div></div></div>
<div class="meter"><div class="meter-label"><span>Swap</span><span id="m-swap">–</span></div><div class="bar"><div id="b-swap"></div></div></div> <div class="meter"><div class="meter-label"><span>Swap</span><span id="m-swap">–</span></div><div class="bar"><div id="b-swap"></div></div></div>
<div class="meter"><div class="meter-label"><span>Disk</span><span id="m-disk">–</span></div><div class="bar"><div id="b-disk"></div></div></div> <div class="meter"><div class="meter-label"><span>Disk</span><span id="m-disk">–</span></div><div class="bar"><div id="b-disk"></div></div></div>
<div class="meter net-meter"> <div class="meter">
<div class="meter-label"><span>Download</span><span id="m-rx">–</span></div> <div class="meter-label"><span>Network</span><span><span class="rx" id="m-rx">–</span> <span class="tx" id="m-tx">–</span></span></div>
<svg class="graph rx" id="g-rx" viewBox="0 0 100 24" preserveAspectRatio="none"><path class="area"/><path class="line"/></svg> <svg class="graph rx" id="g-rx" viewBox="0 0 100 24" preserveAspectRatio="none"><path class="area"/><path class="line"/></svg>
<div class="meter-label graph-gap"><span>Upload</span><span id="m-tx">–</span></div>
<svg class="graph tx" id="g-tx" viewBox="0 0 100 24" preserveAspectRatio="none"><path class="area"/><path class="line"/></svg> <svg class="graph tx" id="g-tx" viewBox="0 0 100 24" preserveAspectRatio="none"><path class="area"/><path class="line"/></svg>
</div> </div>
</div> </div>

View file

@ -75,20 +75,22 @@ header { display: flex; justify-content: space-between; align-items: center; gap
a { color: var(--accent); } a { color: var(--accent); }
/* resources */ /* resources */
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; } .meters { display: grid; grid-template-columns: repeat(4, 1fr) 1.4fr; gap: 14px; }
.meter-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; } @media (max-width: 900px) { .meters { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }
.meter-label { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; font-size: 13px; margin-bottom: 4px; }
.meter-label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; } .meter-label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--bar); border-radius: 4px; overflow: hidden; } .bar { height: 8px; background: var(--bar); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--ok); transition: width .5s, background .5s; } .bar > div { height: 100%; width: 0; background: var(--ok); transition: width .5s, background .5s; }
.net-meter { grid-column: 1 / -1; } .graph { display: block; width: 100%; height: 12px; background: var(--bar); border-radius: 4px; }
.graph { display: block; width: 100%; height: 24px; background: var(--bar); border-radius: 4px; } .graph + .graph { margin-top: 3px; }
.graph .line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; } .graph .line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.graph .area { stroke: none; opacity: .25; } .graph .area { stroke: none; opacity: .25; }
.graph.rx .line { stroke: var(--ok); } .graph.rx .line { stroke: var(--ok); }
.graph.rx .area { fill: var(--ok); } .graph.rx .area { fill: var(--ok); }
.graph.tx .line { stroke: #79c0ff; } .graph.tx .line { stroke: #79c0ff; }
.graph.tx .area { fill: #79c0ff; } .graph.tx .area { fill: #79c0ff; }
.graph-gap { margin-top: 8px; } .meter-label .rx { color: var(--ok); }
.meter-label .tx { color: #79c0ff; }
.section-title { margin: 24px 0 12px; } .section-title { margin: 24px 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 24px; } .empty { color: var(--muted); text-align: center; padding: 24px; }