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:
1 parent
5750350565
commit
639408c0d0
15 files changed
+707
No files matched your search
@@ -19,6 +19,8 @@ import EndpointSuggestions from "../components/EndpointSuggestions";
|
||||
import EndpointHistory from "../components/EndpointHistory";
|
||||
import PageIntro from "../components/PageIntro";
|
||||
import { t } from "../i18n";
|
||||
import Sparkline, { useSparklines } from "../components/Sparkline";
|
||||
import { sparkWords } from "../utils/sparkline";
|
||||
|
||||
const KIND_LABELS: Record<EndpointKind, string> = { http: "Web address", tcp: "Port", tls: "Certificate" };
|
||||
const KIND_HINTS: Record<EndpointKind, string> = {
|
||||
@@ -160,6 +162,7 @@ export default function Endpoints({ user }: { user: CurrentUser }) {
|
||||
const isAdmin = user.role === "admin";
|
||||
const canCheck = user.role === "admin" || user.role === "operator";
|
||||
const [checks, setChecks] = useState<EndpointCheck[] | null>(null);
|
||||
const sparks = useSparklines(() => api.endpoints.sparklines());
|
||||
const [servers, setServers] = useState<{ id: number; name: string }[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [draft, setDraft] = useState<Draft | null>(null);
|
||||
@@ -540,6 +543,18 @@ export default function Endpoints({ user }: { user: CurrentUser }) {
|
||||
)}
|
||||
{c.lastResponseMs === null ? <span className="text-secondary">—</span> : `${c.lastResponseMs} ms`}
|
||||
{c.stats?.avgMs24h != null && <div className="text-secondary small">avg {c.stats.avgMs24h} ms</div>}
|
||||
{sparks?.checks[c.id] && (
|
||||
<div className="mt-1">
|
||||
<Sparkline
|
||||
values={sparks.checks[c.id].values}
|
||||
failed={sparks.checks[c.id].failed}
|
||||
width={96}
|
||||
height={26}
|
||||
tone={sparks.checks[c.id].failed.some(Boolean) ? "red" : "primary"}
|
||||
label={sparkWords(c.name, t("answer time, last 24 hours"), sparks.checks[c.id].latest, sparks.checks[c.id].low, sparks.checks[c.id].high, (v) => `${Math.round(v)} ms`, sparks.checks[c.id].failed.filter(Boolean).length)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="stack-label" data-label="Uptime">
|
||||
{c.stats?.uptime24h == null ? (
|
||||
|
||||
@@ -23,6 +23,9 @@ import SortableTh from "../components/SortableTh";
|
||||
import PageIntro from "../components/PageIntro";
|
||||
import { BrandTag } from "../components/BrandIcon";
|
||||
import { t } from "../i18n";
|
||||
import Sparkline, { useSparklines } from "../components/Sparkline";
|
||||
import { sparkWords } from "../utils/sparkline";
|
||||
import { formatFigure } from "../utils/figureUnits";
|
||||
|
||||
function HealthBadge({ i }: { i: IntegrationSummary }) {
|
||||
const status = integrationStatus(i);
|
||||
@@ -172,6 +175,21 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
const sortedIntegrations = tableSearch.filtered ? [...tableSearch.filtered].filter(matchesStatus).sort((a, b) => a.name.localeCompare(b.name)) : null;
|
||||
|
||||
const rows = sortedIntegrations ? sortedIntegrations.map(integrationRow) : null;
|
||||
// The figure each integration is known for, over the last week (only those that keep a history have one).
|
||||
const sparks = useSparklines(() => api.integrations.sparklines());
|
||||
const trendOf = (id: number) => {
|
||||
const s = sparks?.integrations[id];
|
||||
if (!s) return <span className="text-secondary">—</span>;
|
||||
return (
|
||||
<span className="d-inline-flex align-items-center gap-2">
|
||||
<Sparkline values={s.values} width={72} height={22} label={sparkWords(s.label, t("last week"), s.latest, s.low, s.high, (v) => formatFigure(s.unit, v))} />
|
||||
<span className="small">
|
||||
<span className="text-secondary">{s.label} </span>
|
||||
{s.latest === null ? "—" : formatFigure(s.unit, s.latest)}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
const { sorted: sortedRows, sortKey, sortDir, requestSort } = useSortable<IntegrationRow>(rows, "name", "asc", { url: true });
|
||||
|
||||
// The cards in groups, as the sidebar groups their pages (a kind nobody has placed goes under "Other").
|
||||
@@ -334,6 +352,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
<SortableTh<IntegrationRow> label="Group" sortKeyName="group" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<IntegrationRow> label="Address" sortKeyName="host" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<IntegrationRow> label={t("Status")} sortKeyName="statusRank" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<th scope="col">{t("Last week")}</th>
|
||||
<th scope="col">{t("Last 30 days")}</th>
|
||||
<th scope="col">{t("Actions")}</th>
|
||||
</tr>
|
||||
@@ -352,6 +371,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
{testBadge(i)}
|
||||
{testResults[i.id] && !testResults[i.id].ok && testingId !== i.id && <div className="text-red small mt-1">{testResults[i.id].error}</div>}
|
||||
</td>
|
||||
<td>{trendOf(i.id)}</td>
|
||||
<td>{i.enabled ? <UptimeRibbon kind="integrations" id={i.id} name={i.name} /> : <span className="text-secondary">—</span>}</td>
|
||||
<td>
|
||||
<div className="btn-list">{actionsOf(i)}</div>
|
||||
@@ -389,6 +409,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
<HealthBadge i={i} />
|
||||
{testBadge(i)}
|
||||
</div>
|
||||
{i.enabled && sparks?.integrations[i.id] && <div className="mb-3">{trendOf(i.id)}</div>}
|
||||
{i.enabled && (
|
||||
<div className="mb-3">
|
||||
<UptimeRibbon kind="integrations" id={i.id} name={i.name} />
|
||||
|
||||
@@ -28,12 +28,15 @@ 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";
|
||||
|
||||
|
||||
export default function Servers({ user }: { user: CurrentUser }) {
|
||||
const isAdmin = user.role === "admin";
|
||||
|
||||
const [servers, setServers] = useState<ServerRecord[]>([]);
|
||||
const sparks = useSparklines(() => api.servers.sparklines());
|
||||
// Until the first answer arrives there is nothing to say about "no servers", so show the page's shape instead of the empty message.
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [agentLatest, setAgentLatest] = useState<AgentLatest | null>(null);
|
||||
@@ -252,6 +255,22 @@ 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>
|
||||
)}
|
||||
<div className="mt-2">
|
||||
<UptimeRibbon kind="servers" id={s.id} name={s.name} />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user