Server lines: add the fullest disk over a week, and lines in the admin table

Each server card shows its fullest disk over the last week under the load and
memory lines (a disk moves too slowly to show in a day), and the Manage
servers table has a Load and disk column with all three side by side.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-12 23:27:40 +01:00
1 parent 4f077d4f4a
commit 168d01dc7b
7 files changed
+103 -25

No files matched your search

+1 -1
View File
@@ -915,7 +915,7 @@ exists; it can be hidden, and brought back from the search box.
**Proxmox snapshots.** Click a guest on Infrastructure → Proxmox and its drawer has a **Snapshots** section: what there is (oldest first, a branch indented, *with memory* marked), **Take a snapshot** for operators (a name or one from the time, a description, and for a running VM whether to keep its memory), and **Roll back…** and **Delete…** for administrators, each behind a confirmation that says what is lost. Proxmox does each as a task, followed for up to 20 seconds; each is in the audit log and the change log. The API token needs VM.Snapshot and VM.Snapshot.Rollback (the PVEVMAdmin role has them). The guest actions (start, shut down, restart, stop) were there already.
**Small trends in lists.** The rows of three lists carry a small line for which way things are going: each **server's card** (Infrastructure → Servers) has its load and memory over the last 24 hours (red or orange when it ends high), each **endpoint check** has how long it took to answer over the last day, with a red tick under each stretch in which a check failed, and each **integration** that keeps a history (Integrations, as cards or table, with a *Last week* column) has the figure it is known for over the last week — DNS queries for AdGuard, the queue for Sonarr, photos for Immich, the monthly cost for Hetzner. A gap in the data is a gap in the line, the newest reading is a dot, and each line is a picture with a sentence for a screen reader (*CPU load, last 24 hours: 12% now, between 3% and 40%*). They are drawn from the history the app already keeps (nothing new is stored), come from one request for the whole list, refresh every five minutes and are simply left out where there is no history. A line fitted to its own data makes a small change look steep — the sentence and the numbers beside it say how big it really is. The full charts are one click away on each page.
**Small trends in lists.** The rows of three lists carry a small line for which way things are going: each **server's card** (Infrastructure → Servers) has its load and memory over the last 24 hours and its **fullest disk over the last week** (a disk moves too slowly to show in a day; the line says which mount it is, and turns orange from 80% and red from 90%), and the admin table behind *Manage servers* has the same three lines side by side in a *Load and disk* column (load and memory turn orange from 75% and red from 90%), each **endpoint check** has how long it took to answer over the last day, with a red tick under each stretch in which a check failed, and each **integration** that keeps a history (Integrations, as cards or table, with a *Last week* column) has the figure it is known for over the last week — DNS queries for AdGuard, the queue for Sonarr, photos for Immich, the monthly cost for Hetzner. A gap in the data is a gap in the line, the newest reading is a dot, and each line is a picture with a sentence for a screen reader (*CPU load, last 24 hours: 12% now, between 3% and 40%*). They are drawn from the history the app already keeps (nothing new is stored), come from one request for the whole list, refresh every five minutes and are simply left out where there is no history. A line fitted to its own data makes a small change look steep — the sentence and the numbers beside it say how big it really is. The full charts are one click away on each page.
**On a phone.** Below desktop width the top bar (logo and menu button) stays at the top of the screen so the menu is always within reach, with a menu button of at least 44 px; an open menu scrolls by itself (it no longer pushes the page down), its rows are finger-sized and the favourite stars are always visible; text is a little larger on a small screen, toasts run across the width and drawers fill it. The page asks for the whole screen (`viewport-fit=cover`) and keeps clear of the notch, the rounded corners and the home bar, which matters when it is installed to the home screen (the status bar then sits over the app). Tables turn into stacked cards, form fields are 16 px so a phone does not zoom in on them, and what is pressed does not wait for a second tap. Checked at 375 px: no page scrolls sideways.
Binary file not shown.
+26 -2
View File
@@ -67,7 +67,12 @@ describe("servers", () => {
rows.push({ serverId: a, metric: "cpu", value: 100 - h * 4, recordedAt: hoursAgo(h).toISOString() });
rows.push({ serverId: a, metric: "mem", value: 50, recordedAt: hoursAgo(h).toISOString() });
}
// b: a disk figure only (not one of the lines), and a reading from two days ago (out of the stretch)
// a: two disks over the week — "/" climbing from 50 to 62, "/data" steady at 85 (the fuller one)
for (const d of [6, 5, 4, 3, 2, 1, 0.2]) {
rows.push({ serverId: a, metric: "disk:/", value: 50 + (6 - d) * 2, recordedAt: hoursAgo(d * 24).toISOString() });
rows.push({ serverId: a, metric: "disk:/data", value: 85, recordedAt: hoursAgo(d * 24).toISOString() });
}
// b: a disk figure only (no load or memory), and a reading from two days ago (out of the stretch)
rows.push({ serverId: b, metric: "disk:/", value: 80, recordedAt: hoursAgo(1).toISOString() });
rows.push({ serverId: b, metric: "cpu", value: 99, recordedAt: hoursAgo(48).toISOString() });
await db.insert(serverMetrics).values(rows);
@@ -75,7 +80,9 @@ describe("servers", () => {
test("load and memory over the last day, a slice an hour; a gap is null; others are left out", async () => {
const out = await S.serverSparklines(NOW);
assert.deepEqual(Object.keys(out).map(Number), [a], "b has nothing in the last day that is drawn");
assert.deepEqual(Object.keys(out).map(Number).sort(), [a, b].sort(), "b has only a disk, a has everything");
assert.equal(out[b].cpu, undefined, "b's load was two days ago: not in the last day");
assert.equal(out[b].mem, undefined);
const cpu = out[a].cpu!;
assert.equal(cpu.values.length, S.SLICES);
assert.equal(cpu.values[0], 6, "23.5 hours ago is the first slice: 100 − 94");
@@ -87,6 +94,23 @@ describe("servers", () => {
assert.ok(out[a].mem!.values.every((v) => v === null || v === 50));
});
test("the fullest disk stands for the server, over a week, with its mount", async () => {
const out = await S.serverSparklines(NOW);
const disk = out[a].disk!;
assert.deepEqual([disk.mount, disk.days, disk.latest], ["/data", 7, 85], "/data (85) is fuller than / (62)");
assert.equal(disk.values.length, S.SLICES);
assert.ok(disk.values.filter((v) => v !== null).length >= 6);
assert.deepEqual([out[b].disk!.mount, out[b].disk!.latest], ["/", 80]);
});
test("the fullest is the one that is fullest now; a tie goes to the shorter mount; none is none", () => {
assert.equal(S.fullestDisk([{ mount: "/", latest: 62 }, { mount: "/data", latest: 85 }])!.mount, "/data");
assert.equal(S.fullestDisk([{ mount: "/data", latest: 70 }, { mount: "/", latest: 70 }])!.mount, "/");
assert.equal(S.fullestDisk([{ mount: "/a", latest: null }, { mount: "/b", latest: 10 }])!.mount, "/b");
assert.equal(S.fullestDisk([]), null);
assert.equal(S.fullestDisk([{ mount: "/", latest: null }]), null);
});
test("readings in the same slice are averaged", async () => {
await db.insert(serverMetrics).values([
{ serverId: a, metric: "cpu", value: 10, recordedAt: hoursAgo(10.9).toISOString() },
+2 -2
View File
@@ -4355,8 +4355,8 @@ export const api = {
},
servers: {
list: () => request<{ servers: ServerRecord[]; agentLatest: AgentLatest; agentAutoUpdate: boolean }>("/api/servers"),
/** The last day's load and memory of each server that reports them, for the lines in the list. */
sparklines: () => request<{ hours: number; servers: Record<number, { cpu?: SparkSeries; mem?: SparkSeries }> }>("/api/servers/sparklines"),
/** The last day's load and memory of each server that reports them, and its fullest disk over the last week, for the lines in the list. */
sparklines: () => request<{ hours: number; servers: Record<number, { cpu?: SparkSeries; mem?: SparkSeries; disk?: SparkSeries & { mount: string; days: number } }> }>("/api/servers/sparklines"),
setAgentAutoUpdate: (autoUpdate: boolean) => request<{ autoUpdate: boolean }>("/api/servers/agent-update", { method: "PUT", body: JSON.stringify({ autoUpdate }) }),
create: (data: { name: string; hostname?: string; description?: string; osType?: "linux" | "windows" }) =>
request<{ server: ServerRecord; token: string }>("/api/servers", {
+59
View File
@@ -0,0 +1,59 @@
import type { SparkSeries } from "../api/client";
import { t } from "../i18n";
import { sparkWords } from "../utils/sparkline";
import Sparkline from "./Sparkline";
export interface ServerLines {
cpu?: SparkSeries;
mem?: SparkSeries;
/** The fullest disk, over a week. */
disk?: SparkSeries & { mount: string; days: number };
}
/** Orange from three quarters, red from nine tenths: how close a load, a memory or a disk is to the end of its room. */
const toneOf = (latest: number | null, at: [number, number]): "primary" | "orange" | "red" => (latest !== null && latest >= at[1] ? "red" : latest !== null && latest >= at[0] ? "orange" : "primary");
/**
* A server's small lines: load and memory over the last day, and its fullest disk over the last week (a disk moves too slowly to show in a day). On a card each is a row of its own, in a list's
* table (`compact`) they sit side by side under short names. Nothing is drawn for a figure the server does not report.
*/
export default function ServerSparks({ lines, compact = false }: { lines: ServerLines | undefined; compact?: boolean }) {
if (!lines || (!lines.cpu && !lines.mem && !lines.disk)) return null;
const rows: { key: string; name: string; short: string; line: SparkSeries; period: string; tone: "primary" | "orange" | "red" }[] = [];
if (lines.cpu) rows.push({ key: "cpu", name: t("CPU load"), short: t("CPU"), line: lines.cpu, period: t("last 24 hours"), tone: toneOf(lines.cpu.latest, [75, 90]) });
if (lines.mem) rows.push({ key: "mem", name: t("Memory"), short: t("Mem"), line: lines.mem, period: t("last 24 hours"), tone: toneOf(lines.mem.latest, [75, 90]) });
if (lines.disk) rows.push({ key: "disk", name: t("Disk {mount}", { mount: lines.disk.mount }), short: t("Disk"), line: lines.disk, period: t("last week"), tone: toneOf(lines.disk.latest, [80, 90]) });
const words = (r: (typeof rows)[number]) => sparkWords(r.name, r.period, r.line.latest, r.line.low, r.line.high, (v) => `${Math.round(v)}%`);
const value = (r: (typeof rows)[number]) => (r.line.latest === null ? "—" : `${Math.round(r.line.latest)}%`);
if (compact) {
return (
<div className="d-flex flex-wrap gap-3">
{rows.map((r) => (
<span key={r.key} className="d-inline-flex flex-column small">
<span className="text-secondary">
{r.short} <span className="text-body">{value(r)}</span>
</span>
<Sparkline values={r.line.values} min={0} max={100} width={72} height={18} tone={r.tone} label={words(r)} />
</span>
))}
</div>
);
}
return (
<div className="mt-2 small text-secondary">
{rows.map((r) => (
<div key={r.key} className="mb-1">
<div className="d-flex justify-content-between">
<span>
{r.name}
{r.key === "disk" && <span className="text-secondary"> · {t("a week")}</span>}
</span>
<span className="text-body">{value(r)}</span>
</div>
<Sparkline values={r.line.values} min={0} max={100} width={140} height={22} tone={r.tone} label={words(r)} />
</div>
))}
</div>
);
}
+6
View File
@@ -67,6 +67,7 @@ export const sv: Record<string, string> = {
"A playbook that only restarts the server. It runs once the updates are in and the server has reported again.": "En playbook som bara startar om servern. Den körs när uppdateringarna är installerade och servern har rapporterat igen.",
"A port with a note counts as taken, even when nothing is listening.": "En port med en anteckning räknas som upptagen, även när inget lyssnar.",
"A scan from this app connected to it": "En skanning från den här appen kopplade upp sig mot den",
"a week": "en vecka",
"About": "Gäller",
"Acknowledge…": "Kvittera…",
"Acknowledged": "Kvitterad",
@@ -196,6 +197,7 @@ export const sv: Record<string, string> = {
"Couldn't load the history.": "Kunde inte läsa in historiken.",
"Couldn't load the integrations.": "Kunde inte läsa in integrationerna.",
"Couldn't save that. Try again.": "Det gick inte att spara. Försök igen.",
"CPU": "CPU",
"CPU load": "Processorbelastning",
"Created": "Skapad",
"Critical": "Kritisk",
@@ -216,7 +218,9 @@ export const sv: Record<string, string> = {
"didn't finish": "blev inte klar",
"Disable": "Stäng av",
"Disabled": "Avstängd",
"Disk": "Disk",
"Disk (allocated)": "Disk (tilldelad)",
"Disk {mount}": "Disk {mount}",
"Dismiss": "Avfärda",
"Display": "Display",
"DNS answers": "DNS-svar",
@@ -346,6 +350,7 @@ export const sv: Record<string, string> = {
"Linked to": "Kopplad till",
"Linking…": "Kopplar…",
"Listening": "Lyssnar",
"Load and disk": "Belastning och disk",
"Load:": "Belastning:",
"Loading…": "Läser in…",
"Longest wait": "Längsta väntan",
@@ -365,6 +370,7 @@ export const sv: Record<string, string> = {
"Matched to a server": "Kopplad till en server",
"Matching settings": "Matchande inställningar",
"Media managers": "Mediahanterare",
"Mem": "Minne",
"Memory": "Minne",
"Monitoring": "Övervakning",
"Most in an hour": "Flest på en timme",
+9 -20
View File
@@ -28,8 +28,8 @@ import { RunsOnBulkDrawer, SilenceBulkDrawer, TagBulkDrawer } from "../component
import { doBulk, plural } from "../utils/bulk";
import { BrandTag } from "../components/BrandIcon";
import { t } from "../i18n";
import Sparkline, { useSparklines } from "../components/Sparkline";
import { sparkWords } from "../utils/sparkline";
import { useSparklines } from "../components/Sparkline";
import ServerSparks from "../components/ServerSparks";
export default function Servers({ user }: { user: CurrentUser }) {
@@ -255,22 +255,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
<div className="text-secondary small mt-2">
{s.lastSeenAt ? <>{t("Last seen")} <TimeAgo value={s.lastSeenAt} /></> : t("Never reported")}
</div>
{(sparks?.servers[s.id]?.cpu || sparks?.servers[s.id]?.mem) && (
<div className="mt-2 small text-secondary">
{([["cpu", t("CPU load")], ["mem", t("Memory")]] as const).map(([metric, name]) => {
const line = sparks?.servers[s.id]?.[metric];
return line ? (
<div key={metric} className="mb-1">
<div className="d-flex justify-content-between">
{name}
<span className="text-body">{line.latest === null ? "—" : `${Math.round(line.latest)}%`}</span>
</div>
<Sparkline values={line.values} min={0} max={100} width={140} height={22} tone={line.latest !== null && line.latest >= 90 ? "red" : line.latest !== null && line.latest >= 75 ? "orange" : "primary"} label={sparkWords(name, t("last 24 hours"), line.latest, line.low, line.high, (v) => `${Math.round(v)}%`)} />
</div>
) : null;
})}
</div>
)}
<ServerSparks lines={sparks?.servers[s.id]} />
<div className="mt-2">
<UptimeRibbon kind="servers" id={s.id} name={s.name} />
</div>
@@ -465,6 +450,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
direction={sortDir}
onSort={requestSort}
/>
<th>{t("Load and disk")}</th>
<th>{t("Last 30 days")}</th>
<th className="w-1">{t("Actions")}</th>
</tr>
@@ -488,6 +474,9 @@ export default function Servers({ user }: { user: CurrentUser }) {
</td>
<td className="text-secondary">{s.apiTokenPrefix}…</td>
<td>{s.lastSeenAt ? <TimeAgo value={s.lastSeenAt} /> : "never"}</td>
<td>
<ServerSparks lines={sparks?.servers[s.id]} compact />
</td>
<td>
<UptimeRibbon kind="servers" id={s.id} name={s.name} />
</td>
@@ -506,9 +495,9 @@ export default function Servers({ user }: { user: CurrentUser }) {
</td>
</tr>
))}
{!loaded && <LoadingRow colSpan={7} />}
{!loaded && <LoadingRow colSpan={8} />}
{loaded && sortedServers?.length === 0 && (
<EmptyRow colSpan={7} title={t("No servers yet")} hint={t("Add a server with the form above and install its agent: it then reports its tasks, disks, memory, open ports and waiting updates.")} filtered={tableSearch.active ? () => tableSearch.setQuery("") : undefined} />
<EmptyRow colSpan={8} title={t("No servers yet")} hint={t("Add a server with the form above and install its agent: it then reports its tasks, disks, memory, open ports and waiting updates.")} filtered={tableSearch.active ? () => tableSearch.setQuery("") : undefined} />
)}
</tbody>
</table>