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

+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>