Add Read now to every integration

POST /api/integrations/:id/read-now reads one integration at once (operators and administrators; not again within 20 s): a kind with a stored reading is read and judged again, a kind read live is asked whether it answers. The three per-kind lists in the integrations routes (add, change, delete) are now one map in services/integrationSyncs.ts. Button on the Integrations cards and the Media managers, Download clients and Hetzner Robot pages.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-04 23:40:31 +01:00
1 parent 01acbaf831
commit b29c0b7d04
13 files changed
+434 -128

No files matched your search

+18 -13
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type RobotAccount } from "../api/client";
import { api, type CurrentUser, type RobotAccount } from "../api/client";
import ReadNowButton from "../components/ReadNowButton";
import EmptyState from "../components/EmptyState";
import TimeAgo from "../components/TimeAgo";
import { BlockSkeleton } from "../components/Skeleton";
@@ -47,7 +48,7 @@ function Until({ date, cancelled, days }: { date: string | null; cancelled: bool
);
}
function Card({ a }: { a: RobotAccount }) {
function Card({ a, canRead, onRead }: { a: RobotAccount; canRead: boolean; onRead: () => void }) {
const s = a.state;
const rescue = s?.servers.filter((v) => v.rescue === true).length ?? 0;
const cancelled = (s?.servers.filter((v) => v.cancelled).length ?? 0) + (s?.storageBoxes?.filter((b) => b.cancelled).length ?? 0);
@@ -57,7 +58,10 @@ function Card({ a }: { a: RobotAccount }) {
<h3 className="card-title">
{a.name} <Badge a={a} />
</h3>
<div className="card-actions text-secondary small">{a.status ? <>read <TimeAgo value={a.status.at} /></> : "not read yet"}</div>
<div className="card-actions d-flex align-items-center gap-2 text-secondary small">
{a.status ? <>read <TimeAgo value={a.status.at} /></> : "not read yet"}
{canRead && a.enabled && <ReadNowButton integrationId={a.id} name={a.name} onDone={onRead} />}
</div>
</div>
<div className="card-body">
{a.status && !a.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {a.status.error ?? "no answer"}.</div>}
@@ -183,22 +187,23 @@ function Card({ a }: { a: RobotAccount }) {
}
/** Hetzner Robot: the account's dedicated servers (rescue system, cancellation) and storage boxes. */
export default function HetznerRobot() {
export default function HetznerRobot({ user }: { user: CurrentUser }) {
const [data, setData] = useState<RobotAccount[] | null>(null);
const [error, setError] = useState<string | null>(null);
const load = () =>
api.hetznerRobot
.list()
.then((r) => {
setData(r.accounts);
setError(null);
})
.catch((err) => setError(readableError(err)));
useEffect(() => {
const load = () =>
api.hetznerRobot
.list()
.then((r) => {
setData(r.accounts);
setError(null);
})
.catch((err) => setError(readableError(err)));
void load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
const canRead = user.role === "admin" || user.role === "operator";
return (
<>
<h2 className="page-title">Hetzner Robot</h2>
@@ -215,7 +220,7 @@ export default function HetznerRobot() {
</div>
</div>
)}
{data?.map((a) => <Card key={a.id} a={a} />)}
{data?.map((a) => <Card key={a.id} a={a} canRead={canRead} onRead={() => void load()} />)}
</>
);
}