Add small trend lines to the rows of the server, endpoint and integration lists

Server cards show load and memory over the last 24 hours, endpoint checks show
their answer times with a tick where a check failed, and integrations that keep
a figure history show their headline figure over the last week. Each list asks
for all its lines in one request, drawn from the history already kept, and each
line has a sentence for screen readers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-12 22:52:26 +01:00
1 parent 5750350565
commit 639408c0d0
15 files changed
+707

No files matched your search

+24
View File
@@ -1,3 +1,4 @@
import { } from "../i18n";
export type UserRole = "admin" | "operator" | "viewer";
export interface CurrentUser {
@@ -864,6 +865,23 @@ export interface IntegrationFigure {
high: number | null;
}
/** A short series for a row in a list: `values` is a fixed number of slices, oldest first, null where nothing was read. */
export interface SparkSeries {
values: (number | null)[];
latest: number | null;
low: number | null;
high: number | null;
}
export interface EndpointSparkSeries extends SparkSeries {
/** In which slices a check failed. */
failed: boolean[];
}
export interface IntegrationSparkSeries extends SparkSeries {
key: string;
label: string;
unit: string;
}
export interface UpdateRun {
id: number;
serverId: number;
@@ -3888,6 +3906,8 @@ export const api = {
},
endpoints: {
list: () => request<{ checks: EndpointCheck[]; servers: { id: number; name: string }[] }>("/api/endpoints"),
/** How long each check took to answer over the last day, and when one failed, for the lines in the list. */
sparklines: () => request<{ hours: number; checks: Record<number, EndpointSparkSeries> }>("/api/endpoints/sparklines"),
create: (data: EndpointInput) => request<{ check: EndpointCheck }>("/api/endpoints", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: EndpointInput) => request<{ check: EndpointCheck }>(`/api/endpoints/${id}`, { method: "PUT", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/endpoints/${id}`, { method: "DELETE" }),
@@ -4292,6 +4312,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"),
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", {
@@ -4408,6 +4430,8 @@ export const api = {
integration: { id: number; type: IntegrationType; name: string; enabled: boolean };
config: Record<string, string | boolean>;
}>(`/api/integrations/${id}/config`),
/** The figure each integration is known for, over the last week, for the lines in a list. */
sparklines: () => request<{ days: number; integrations: Record<number, IntegrationSparkSeries> }>("/api/integrations/sparklines"),
/** How the figures it reports have moved over the last `days` (a day to a year); `kept` is false for a kind that keeps none. */
figures: (id: number, days: number) => request<{ kept: boolean; days: number; figures: IntegrationFigure[] }>(`/api/integrations/${id}/figures?days=${days}`),
inspect: (id: number) => request<IntegrationInspection>(`/api/integrations/${id}/inspect`, { method: "POST" }),