Endpoint checks, restore tests, and a change log
- Endpoints: HTTP, TCP and TLS checks with answer time, uptime and certificate expiry; failures and expiring certificates become alerts and notifications; linked to a server for maintenance and tags - Restore tests: record when a backup was restored and how it went; failed tests always alert, overdue ones with a limit set; shown on the Backup coverage page - Change log: one filterable timeline made from the audit log and the incident record Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3bc6bbf72
commit
92726568b7
37 files changed
+6918
-21
No files matched your search
@@ -0,0 +1,494 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type CurrentUser, type EndpointCheck, type EndpointInput, type EndpointKind } from "../api/client";
|
||||
import Pagination from "../components/Pagination";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import TableToolbar from "../components/TableToolbar";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { usePagination } from "../hooks/usePagination";
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const KIND_LABELS: Record<EndpointKind, string> = { http: "Web address", tcp: "Port", tls: "Certificate" };
|
||||
const KIND_HINTS: Record<EndpointKind, string> = {
|
||||
http: "Asks the address and wants a good answer (and, if you like, a word in the page).",
|
||||
tcp: "Opens a connection to the port and sees whether anything answers.",
|
||||
tls: "Reads the certificate the service shows and warns before it runs out.",
|
||||
};
|
||||
|
||||
type State = "waiting" | "up" | "failing" | "down" | "off";
|
||||
const STATE_BADGE: Record<State, { label: string; badge: string }> = {
|
||||
waiting: { label: "Not asked yet", badge: "bg-secondary-lt text-secondary" },
|
||||
up: { label: "Up", badge: "bg-green-lt text-green" },
|
||||
failing: { label: "Failing", badge: "bg-yellow-lt text-yellow" },
|
||||
down: { label: "Down", badge: "bg-red-lt text-red" },
|
||||
off: { label: "Switched off", badge: "bg-secondary-lt text-secondary" },
|
||||
};
|
||||
const RANK: Record<State, number> = { down: 0, failing: 1, waiting: 2, up: 3, off: 4 };
|
||||
|
||||
function stateOf(c: EndpointCheck): State {
|
||||
if (!c.enabled) return "off";
|
||||
if (c.lastOk === null) return "waiting";
|
||||
if (c.lastOk) return "up";
|
||||
return c.consecutiveFailures >= c.failuresBeforeAlert ? "down" : "failing";
|
||||
}
|
||||
|
||||
const daysLeft = (iso: string | null) => (iso ? Math.floor((Date.parse(iso) - Date.now()) / 86_400_000) : null);
|
||||
|
||||
interface Row extends EndpointCheck {
|
||||
state: State;
|
||||
rank: number;
|
||||
certDays: number | null;
|
||||
uptime24h: number | null;
|
||||
}
|
||||
|
||||
/** The last results as a row of small ticks: green for an answer, red for none. */
|
||||
function Ticks({ recent }: { recent: { at: string; ok: boolean }[] }) {
|
||||
if (recent.length === 0) return <span className="text-secondary">—</span>;
|
||||
return (
|
||||
<span className="d-inline-flex gap-1 align-middle" role="img" aria-label={`The last ${recent.length} checks: ${recent.filter((r) => r.ok).length} answered`}>
|
||||
{recent.map((r) => (
|
||||
<span key={r.at} title={`${r.at.slice(0, 16).replace("T", " ")} UTC — ${r.ok ? "answered" : "no good answer"}`} style={{ width: 4, height: 14, borderRadius: 1, background: r.ok ? "#2fb344" : "#e05252", display: "inline-block" }} />
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface Draft {
|
||||
id: number | null;
|
||||
name: string;
|
||||
kind: EndpointKind;
|
||||
target: string;
|
||||
port: string;
|
||||
expectStatus: string;
|
||||
keyword: string;
|
||||
insecure: boolean;
|
||||
intervalMinutes: string;
|
||||
timeoutSeconds: string;
|
||||
failuresBeforeAlert: string;
|
||||
warnDays: string;
|
||||
serverId: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
const EMPTY: Draft = { id: null, name: "", kind: "http", target: "", port: "", expectStatus: "", keyword: "", insecure: false, intervalMinutes: "5", timeoutSeconds: "10", failuresBeforeAlert: "2", warnDays: "14", serverId: "", enabled: true };
|
||||
|
||||
const toDraft = (c: EndpointCheck): Draft => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
kind: c.kind,
|
||||
target: c.target,
|
||||
port: c.port === null ? "" : String(c.port),
|
||||
expectStatus: c.expectStatus ?? "",
|
||||
keyword: c.keyword ?? "",
|
||||
insecure: c.insecure,
|
||||
intervalMinutes: String(c.intervalMinutes),
|
||||
timeoutSeconds: String(c.timeoutSeconds),
|
||||
failuresBeforeAlert: String(c.failuresBeforeAlert),
|
||||
warnDays: String(c.warnDays),
|
||||
serverId: c.serverId === null ? "" : String(c.serverId),
|
||||
enabled: c.enabled,
|
||||
});
|
||||
|
||||
const toInput = (d: Draft): EndpointInput => ({
|
||||
name: d.name.trim(),
|
||||
kind: d.kind,
|
||||
target: d.target.trim(),
|
||||
port: d.kind === "http" || d.port.trim() === "" ? null : Number(d.port),
|
||||
expectStatus: d.kind === "http" && d.expectStatus.trim() ? d.expectStatus.trim() : null,
|
||||
keyword: d.kind === "http" && d.keyword ? d.keyword : null,
|
||||
insecure: d.insecure,
|
||||
intervalMinutes: Number(d.intervalMinutes),
|
||||
timeoutSeconds: Number(d.timeoutSeconds),
|
||||
failuresBeforeAlert: Number(d.failuresBeforeAlert),
|
||||
warnDays: Number(d.warnDays),
|
||||
serverId: d.serverId === "" ? null : Number(d.serverId),
|
||||
enabled: d.enabled,
|
||||
});
|
||||
|
||||
/**
|
||||
* "Is it up?" for the simple cases: a web address, a TCP port, a certificate. The app asks every few minutes, remembers how it went, and
|
||||
* raises an alert (and a notification) when a check keeps failing or a certificate is about to run out. Everyone can look; an administrator
|
||||
* sets them up, since each one makes this server connect somewhere.
|
||||
*/
|
||||
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 [servers, setServers] = useState<{ id: number; name: string }[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [draft, setDraft] = useState<Draft | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [asking, setAsking] = useState<number | null>(null);
|
||||
|
||||
function load() {
|
||||
api.endpoints
|
||||
.list()
|
||||
.then((res) => {
|
||||
setChecks(res.checks);
|
||||
setServers(res.servers);
|
||||
})
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}
|
||||
useEffect(() => {
|
||||
load();
|
||||
// The results come in on their own every few minutes: look again now and then.
|
||||
const t = setInterval(load, 60_000);
|
||||
return () => clearInterval(t);
|
||||
}, []);
|
||||
|
||||
const rows: Row[] = (checks ?? []).map((c) => ({ ...c, state: stateOf(c), rank: RANK[stateOf(c)], certDays: daysLeft(c.certExpiresAt), uptime24h: c.stats?.uptime24h ?? null }));
|
||||
const tableSearch = useTableSearch(rows);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "rank", "asc", { url: true });
|
||||
const page = usePagination(sorted);
|
||||
const down = rows.filter((r) => r.state === "down" || r.state === "failing").length;
|
||||
const certs = rows.filter((r) => r.certDays !== null && r.certDays <= r.warnDays).length;
|
||||
|
||||
async function save(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!draft) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
if (draft.id === null) await api.endpoints.create(toInput(draft));
|
||||
else await api.endpoints.update(draft.id, toInput(draft));
|
||||
toast.success(draft.id === null ? `Added ${draft.name}.` : "Saved.");
|
||||
setDraft(null);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(c: EndpointCheck) {
|
||||
if (!(await confirmDialog({ title: "Remove a check", message: `Remove "${c.name}" and its history?`, confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
await api.endpoints.remove(c.id);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
async function askNow(c: EndpointCheck) {
|
||||
setAsking(c.id);
|
||||
try {
|
||||
const { result } = await api.endpoints.check(c.id);
|
||||
if (result.ok) toast.success(`${c.name}: ${result.message}`);
|
||||
else toast.error(`${c.name}: ${result.message}`);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setAsking(null);
|
||||
}
|
||||
}
|
||||
|
||||
function exportCsv() {
|
||||
downloadCsv(
|
||||
"endpoint-checks.csv",
|
||||
["Name", "Kind", "Target", "Port", "Status", "Last answer", "Answer time (ms)", "Uptime 24 h (%)", "Uptime 7 d (%)", "Certificate expires", "Last checked", "Server"],
|
||||
(sorted ?? []).map((r) => [r.name, KIND_LABELS[r.kind], r.target, r.port ?? "", STATE_BADGE[r.state].label, r.lastMessage ?? "", r.lastResponseMs ?? "", r.stats?.uptime24h ?? "", r.stats?.uptime7d ?? "", r.certExpiresAt?.slice(0, 10) ?? "", r.lastCheckedAt ?? "", r.server?.name ?? ""]),
|
||||
);
|
||||
}
|
||||
|
||||
const set = <K extends keyof Draft>(key: K, value: Draft[K]) => setDraft((d) => (d ? { ...d, [key]: value } : d));
|
||||
const cards = [
|
||||
{ label: "Checks", value: checks ? String(rows.length) : "…", color: "" },
|
||||
{ label: "Not answering", value: checks ? String(down) : "…", color: down > 0 ? "text-red" : "text-green" },
|
||||
{ label: "Certificates to renew", value: checks ? String(certs) : "…", color: certs > 0 ? "text-yellow" : "" },
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="d-flex align-items-center mb-1">
|
||||
<h2 className="page-title mb-0">Endpoints</h2>
|
||||
{isAdmin && !draft && (
|
||||
<button className="btn btn-primary ms-auto" onClick={() => setDraft({ ...EMPTY })}>
|
||||
Add a check
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-secondary">
|
||||
The app asks a web address, a port or a certificate whether it is fine, every few minutes, and says so on the <Link to="/alerts">Alerts</Link> page and in notifications when it keeps failing or a
|
||||
certificate is about to run out.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
<div className="row row-cards mb-3">
|
||||
{cards.map((c) => (
|
||||
<div className="col-6 col-md-4" key={c.label}>
|
||||
<div className="card card-sm">
|
||||
<div className="card-body">
|
||||
<div className={`h2 mb-0 ${c.color}`}>{c.value}</div>
|
||||
<div className="text-secondary">{c.label}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{draft && (
|
||||
<form className="card mb-3" onSubmit={save}>
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">{draft.id === null ? "Add a check" : `Edit ${draft.name || "the check"}`}</h3>
|
||||
</div>
|
||||
<div className="card-body row g-3">
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="ep-name">
|
||||
Name
|
||||
</label>
|
||||
<input id="ep-name" className="form-control" required maxLength={100} placeholder="e.g. Gitea" value={draft.name} onChange={(e) => set("name", e.target.value)} />
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="ep-kind">
|
||||
What to ask
|
||||
</label>
|
||||
<select id="ep-kind" className="form-select" value={draft.kind} onChange={(e) => set("kind", e.target.value as EndpointKind)}>
|
||||
{(Object.keys(KIND_LABELS) as EndpointKind[]).map((k) => (
|
||||
<option key={k} value={k}>
|
||||
{KIND_LABELS[k]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="form-hint text-secondary small mt-1">{KIND_HINTS[draft.kind]}</div>
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="ep-server">
|
||||
It is about the server
|
||||
</label>
|
||||
<select id="ep-server" className="form-select" value={draft.serverId} onChange={(e) => set("serverId", e.target.value)}>
|
||||
<option value="">— none in particular —</option>
|
||||
{servers.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="form-hint text-secondary small mt-1">Maintenance on that server silences this check’s alerts, and its tags can route them.</div>
|
||||
</div>
|
||||
<div className={draft.kind === "http" ? "col-md-8" : "col-md-5"}>
|
||||
<label className="form-label" htmlFor="ep-target">
|
||||
{draft.kind === "http" ? "Address" : "Host name or address"}
|
||||
</label>
|
||||
<input
|
||||
id="ep-target"
|
||||
className="form-control"
|
||||
required
|
||||
maxLength={500}
|
||||
placeholder={draft.kind === "http" ? "https://git.example.lan/" : "git.example.lan"}
|
||||
value={draft.target}
|
||||
onChange={(e) => set("target", e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{draft.kind !== "http" && (
|
||||
<div className="col-md-3">
|
||||
<label className="form-label" htmlFor="ep-port">
|
||||
Port
|
||||
</label>
|
||||
<input id="ep-port" type="number" min={1} max={65535} className="form-control" required value={draft.port} placeholder={draft.kind === "tls" ? "443" : ""} onChange={(e) => set("port", e.target.value)} />
|
||||
</div>
|
||||
)}
|
||||
{draft.kind === "http" && (
|
||||
<>
|
||||
<div className="col-md-2">
|
||||
<label className="form-label" htmlFor="ep-status">
|
||||
Good answers
|
||||
</label>
|
||||
<input id="ep-status" className="form-control" placeholder="200-399" value={draft.expectStatus} onChange={(e) => set("expectStatus", e.target.value)} />
|
||||
</div>
|
||||
<div className="col-md-2">
|
||||
<label className="form-label" htmlFor="ep-keyword">
|
||||
Page contains
|
||||
</label>
|
||||
<input id="ep-keyword" className="form-control" maxLength={200} value={draft.keyword} onChange={(e) => set("keyword", e.target.value)} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="col-md-2">
|
||||
<label className="form-label" htmlFor="ep-interval">
|
||||
Every
|
||||
</label>
|
||||
<div className="input-group">
|
||||
<input id="ep-interval" type="number" min={1} max={1440} className="form-control" value={draft.intervalMinutes} onChange={(e) => set("intervalMinutes", e.target.value)} />
|
||||
<span className="input-group-text">min</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-md-2">
|
||||
<label className="form-label" htmlFor="ep-timeout">
|
||||
Give up after
|
||||
</label>
|
||||
<div className="input-group">
|
||||
<input id="ep-timeout" type="number" min={1} max={60} className="form-control" value={draft.timeoutSeconds} onChange={(e) => set("timeoutSeconds", e.target.value)} />
|
||||
<span className="input-group-text">s</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
<label className="form-label" htmlFor="ep-fails">
|
||||
Alert after
|
||||
</label>
|
||||
<div className="input-group">
|
||||
<input id="ep-fails" type="number" min={1} max={20} className="form-control" value={draft.failuresBeforeAlert} onChange={(e) => set("failuresBeforeAlert", e.target.value)} />
|
||||
<span className="input-group-text">failures in a row</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
<label className="form-label" htmlFor="ep-warn">
|
||||
Warn about the certificate
|
||||
</label>
|
||||
<div className="input-group">
|
||||
<input id="ep-warn" type="number" min={1} max={90} className="form-control" value={draft.warnDays} onChange={(e) => set("warnDays", e.target.value)} />
|
||||
<span className="input-group-text">days before</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12 d-flex flex-wrap gap-4">
|
||||
<label className="form-check mb-0">
|
||||
<input type="checkbox" className="form-check-input" checked={draft.insecure} onChange={(e) => set("insecure", e.target.checked)} />
|
||||
<span className="form-check-label">Accept a certificate that isn’t trusted (self-signed, a private authority). Its expiry is still watched.</span>
|
||||
</label>
|
||||
<label className="form-check mb-0">
|
||||
<input type="checkbox" className="form-check-input" checked={draft.enabled} onChange={(e) => set("enabled", e.target.checked)} />
|
||||
<span className="form-check-label">Switched on</span>
|
||||
</label>
|
||||
</div>
|
||||
<div className="col-12 text-secondary small">Only addresses this server may reach are accepted: not itself (loopback) and not the cloud metadata address. Your own network is fine.</div>
|
||||
</div>
|
||||
<div className="card-footer d-flex gap-2">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy || draft.name.trim() === "" || draft.target.trim() === ""}>
|
||||
{busy ? "Saving…" : "Save"}
|
||||
</button>
|
||||
<button type="button" className="btn" onClick={() => setDraft(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<div className="card">
|
||||
<TableToolbar search={tableSearch.query} onSearch={tableSearch.setQuery} placeholder="Search checks…" shown={sorted?.length} total={rows.length} onExport={exportCsv} exportDisabled={!sorted || sorted.length === 0} />
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table table-stack">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortableTh<Row> label="Check" sortKeyName="name" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Status" sortKeyName="rank" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Answer" sortKeyName="lastResponseMs" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Uptime" sortKeyName="uptime24h" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Certificate" sortKeyName="certDays" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Checked" sortKeyName="lastCheckedAt" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
{(canCheck || isAdmin) && <th className="w-1">Actions</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{checks === null && !error && (
|
||||
<tr>
|
||||
<td colSpan={7}>
|
||||
<BlockSkeleton lines={3} />
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{page.pageItems?.map((c) => (
|
||||
<tr key={c.id}>
|
||||
<td className="stack-wide">
|
||||
<strong>{c.name}</strong> <span className="badge bg-secondary-lt text-secondary">{KIND_LABELS[c.kind]}</span>
|
||||
<div className="text-secondary small text-break">
|
||||
{c.target}
|
||||
{c.port !== null ? `:${c.port}` : ""}
|
||||
</div>
|
||||
{c.server && (
|
||||
<div className="small">
|
||||
about <Link to={`/servers/${c.server.id}`}>{c.server.name}</Link>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<span className={`badge ${STATE_BADGE[c.state].badge}`}>{STATE_BADGE[c.state].label}</span>
|
||||
{c.lastOk === false && c.lastMessage && <div className="text-secondary small">{c.lastMessage}</div>}
|
||||
{c.lastOk === false && c.state === "failing" && (
|
||||
<div className="text-secondary small">
|
||||
failed {c.consecutiveFailures} of {c.failuresBeforeAlert}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="stack-label" data-label="Answer">
|
||||
{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>}
|
||||
</td>
|
||||
<td className="stack-label" data-label="Uptime">
|
||||
{c.stats?.uptime24h == null ? (
|
||||
<span className="text-secondary">—</span>
|
||||
) : (
|
||||
<>
|
||||
{c.stats.uptime24h}% <span className="text-secondary small">24 h</span>
|
||||
<div className="text-secondary small">{c.stats.uptime7d}% 7 d</div>
|
||||
</>
|
||||
)}
|
||||
<div>
|
||||
<Ticks recent={c.stats?.recent ?? []} />
|
||||
</div>
|
||||
</td>
|
||||
<td className="stack-label" data-label="Certificate">
|
||||
{c.certDays === null ? (
|
||||
<span className="text-secondary">—</span>
|
||||
) : c.certDays < 0 ? (
|
||||
<span className="badge bg-red-lt text-red" title={c.certExpiresAt?.slice(0, 10)}>
|
||||
expired {-c.certDays} d ago
|
||||
</span>
|
||||
) : c.certDays <= c.warnDays ? (
|
||||
<span className={`badge ${c.certDays <= 3 ? "bg-red-lt text-red" : "bg-yellow-lt text-yellow"}`} title={c.certExpiresAt?.slice(0, 10)}>
|
||||
{c.certDays} d left
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-secondary">{c.certDays} d left</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="text-secondary stack-label" data-label="Checked">
|
||||
{c.lastCheckedAt ? <TimeAgo value={c.lastCheckedAt} /> : "—"}
|
||||
</td>
|
||||
{(canCheck || isAdmin) && (
|
||||
<td className="stack-wide">
|
||||
<div className="btn-list flex-nowrap">
|
||||
{canCheck && (
|
||||
<button className="btn btn-sm btn-outline-primary" disabled={asking === c.id} onClick={() => void askNow(c)}>
|
||||
{asking === c.id ? "Asking…" : "Check now"}
|
||||
</button>
|
||||
)}
|
||||
{isAdmin && (
|
||||
<>
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => setDraft(toDraft(c))}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="btn btn-sm btn-outline-danger" onClick={() => void remove(c)}>
|
||||
Remove
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
{checks !== null && sorted?.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={7} className="text-secondary text-center">
|
||||
{tableSearch.active ? "Nothing matches that." : `Nothing is being checked yet.${isAdmin ? " Add the first check: a web address, a port, or a certificate." : ""}`}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<Pagination page={page.page} pageCount={page.pageCount} totalCount={page.totalCount} onPageChange={page.setPage} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user