Phone card layout, status symbols, breadcrumbs, integration cards and server trends

Tables stack into labelled cards on a phone. Green, red and amber badges carry
a check, cross or triangle as well as their colour. Pages inside a menu group
show a breadcrumb, with the thing's name on a server's page. Integrations are
cards with an Open button and a live status (working, failing, not checked yet,
disabled). Agent-reported servers keep a short history of load, memory and disk
use (migration 0019, one sample per ten minutes for 35 days) and show it as a
Trends card with a days-until-full forecast for a filling disk.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-14 23:56:05 +02:00
1 parent 617dc1ea2f
commit 9965d94036
22 files changed
+3000 -84

No files matched your search

+116 -80
View File
@@ -1,10 +1,10 @@
import { useEffect, useState, type CSSProperties } from "react";
import { useSearchParams } from "react-router-dom";
import { Link, useSearchParams } from "react-router-dom";
import { api, type CurrentUser, type IntegrationSummary, type IntegrationType } from "../api/client";
import IntegrationForm from "../components/IntegrationForm";
import IntegrationEditForm from "../components/IntegrationEditForm";
import { useSortable } from "../hooks/useSortable";
import SortableTh from "../components/SortableTh";
import TableToolbar from "../components/TableToolbar";
import { useTableSearch } from "../hooks/useTableSearch";
import { downloadCsv } from "../utils/csv";
import { confirmDialog } from "../utils/dialogs";
import { ErrorNotice } from "../components/Notice";
@@ -23,6 +23,48 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
osticket: "osTicket",
};
/** The page each kind of integration gets once it is connected. */
const TYPE_PAGES: Record<IntegrationType, string> = {
tailscale: "/tailscale",
proxmox: "/proxmox",
synology: "/synology",
semaphore: "/semaphore",
gitea: "/gitea",
dockhand: "/docker",
uptimekuma: "/uptime-kuma",
phpipam: "/ipam",
pbs: "/pbs",
osticket: "/osticket",
};
/** "pve.example.lan" out of "https://pve.example.lan:8006/", or the text itself when it isn't an address. */
function hostOf(baseUrl: string): string {
if (!baseUrl) return "";
try {
return new URL(baseUrl).host;
} catch {
return baseUrl;
}
}
function HealthBadge({ i }: { i: IntegrationSummary }) {
const health = i.health;
if (!i.enabled || health?.status === "disabled") return <span className="badge bg-secondary-lt text-secondary">Disabled</span>;
if (health?.status === "failing") {
return (
<span className="badge bg-red-lt text-red">
Failing — last {health.consecutiveFailures} call{health.consecutiveFailures === 1 ? "" : "s"} failed
</span>
);
}
if (health?.status === "ok") return <span className="badge bg-green-lt text-green">Working</span>;
return (
<span className="badge bg-secondary-lt text-secondary" title="Nothing has called it since the app started. Use Test to check it now.">
Not checked yet
</span>
);
}
function typeBadgeStyle(colors: Record<string, string>, type: IntegrationType): CSSProperties {
const color = colors[type];
if (!color) return {};
@@ -93,7 +135,8 @@ export default function Integrations({ user }: { user: CurrentUser }) {
}
}
const { sorted: sortedIntegrations, sortKey, sortDir, requestSort } = useSortable(integrations);
const tableSearch = useTableSearch(integrations);
const sortedIntegrations = tableSearch.filtered ? [...tableSearch.filtered].sort((a, b) => a.name.localeCompare(b.name)) : null;
function exportCsv() {
if (!sortedIntegrations) return;
@@ -143,97 +186,90 @@ export default function Integrations({ user }: { user: CurrentUser }) {
)
)}
<div className="card">
<div className="card-header justify-content-end">
<button className="btn btn-outline-secondary btn-sm" onClick={exportCsv} disabled={!integrations || integrations.length === 0}>
Export CSV
</button>
</div>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<SortableTh<IntegrationSummary> label="Name" sortKeyName="name" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<IntegrationSummary> label="Type" sortKeyName="type" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<IntegrationSummary>
label="Status"
sortKeyName="enabled"
activeKey={sortKey}
direction={sortDir}
onSort={requestSort}
/>
{isAdmin && <th className="w-1">Actions</th>}
</tr>
</thead>
<tbody>
{sortedIntegrations?.map((i) => (
<tr key={i.id}>
<td>{i.name}</td>
<td>
<span className="badge" style={typeBadgeStyle(integrationColors, i.type)}>
<div className="card mb-3">
<TableToolbar
search={tableSearch.query}
onSearch={tableSearch.setQuery}
placeholder="Search integrations…"
shown={sortedIntegrations?.length}
total={integrations?.length}
onExport={exportCsv}
exportDisabled={!integrations || integrations.length === 0}
/>
</div>
<div className="row row-cards">
{sortedIntegrations?.map((i) => {
const result = testResults[i.id];
const page = TYPE_PAGES[i.type];
return (
<div className="col-md-6 col-xl-4" key={i.id}>
<div className="card h-100">
<div className="card-body d-flex flex-column">
<div className="d-flex align-items-start gap-2 mb-2">
<div className="flex-fill" style={{ minWidth: 0 }}>
<div className="fw-bold text-truncate">{i.name}</div>
<div className="text-secondary small text-truncate">{hostOf(i.baseUrl) || "no web address"}</div>
</div>
<span className="badge flex-shrink-0" style={typeBadgeStyle(integrationColors, i.type)}>
{TYPE_LABELS[i.type]}
</span>
</td>
<td>
{isAdmin ? (
<button
className={`badge ${i.enabled ? "bg-green-lt text-green" : "bg-secondary-lt text-secondary"} border-0`}
onClick={() => toggleEnabled(i)}
>
{i.enabled ? "Enabled" : "Disabled"}
</button>
) : (
<span className={`badge ${i.enabled ? "bg-green-lt text-green" : "bg-secondary-lt text-secondary"}`}>
{i.enabled ? "Enabled" : "Disabled"}
</div>
<div className="mb-3">
<HealthBadge i={i} />
{result && testingId !== i.id && (
<span className={`badge ms-2 ${result.ok ? "bg-green-lt text-green" : "bg-red-lt text-red"}`}>
Test {result.ok ? `passed${result.latencyMs !== undefined ? ` (${result.latencyMs}ms)` : ""}` : "failed"}
</span>
)}
</td>
{isAdmin && (
<td>
<div className="btn-list flex-nowrap align-items-center">
</div>
{result && !result.ok && testingId !== i.id && <div className="text-red small mb-3">{result.error}</div>}
<div className="btn-list mt-auto">
{i.enabled && (
<Link to={page} className="btn btn-sm btn-primary">
Open
</Link>
)}
{isAdmin && (
<>
<button className="btn btn-sm" onClick={() => testIntegration(i)} disabled={testingId === i.id}>
{testingId === i.id ? "Testing…" : "Test"}
</button>
{testResults[i.id] && testingId !== i.id && (
<span className={`badge ${testResults[i.id].ok ? "bg-green-lt text-green" : "bg-red-lt text-red"}`}>
{testResults[i.id].ok
? `OK${testResults[i.id].latencyMs !== undefined ? ` (${testResults[i.id].latencyMs}ms)` : ""}`
: "Failed"}
</span>
)}
<button className="btn btn-sm" onClick={() => setEditingIntegration(i)}>
Edit
</button>
<button className="btn btn-sm" onClick={() => toggleEnabled(i)}>
{i.enabled ? "Disable" : "Enable"}
</button>
<button className="btn btn-sm btn-outline-danger" onClick={() => removeIntegration(i)}>
Delete
</button>
</div>
{testResults[i.id] && !testResults[i.id].ok && testingId !== i.id && (
<div className="text-red small mt-1">{testResults[i.id].error}</div>
)}
</td>
)}
</tr>
))}
{sortedIntegrations?.length === 0 && (
<tr>
<td colSpan={isAdmin ? 4 : 3} className="text-secondary text-center">
No integrations configured yet.
{isAdmin && (
<>
{" "}
<button className="btn btn-link p-0 align-baseline" onClick={() => setAdding(true)}>
Add one
</button>
.
</>
)}
</td>
</tr>
)}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
);
})}
{sortedIntegrations?.length === 0 && (
<div className="col-12">
<div className="card">
<div className="card-body text-secondary text-center">
{tableSearch.active ? "Nothing matches that search." : "No integrations configured yet."}
{isAdmin && !tableSearch.active && (
<>
{" "}
<button className="btn btn-link p-0 align-baseline" onClick={() => setAdding(true)}>
Add one
</button>
.
</>
)}
</div>
</div>
</div>
)}
</div>
</>
);