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 DownloadClient, type DownloadItem, type DownloadState } from "../api/client";
import { api, type CurrentUser, type DownloadClient, type DownloadItem, type DownloadState } from "../api/client";
import ReadNowButton from "../components/ReadNowButton";
import EmptyState from "../components/EmptyState";
import TimeAgo from "../components/TimeAgo";
import { BlockSkeleton } from "../components/Skeleton";
@@ -120,7 +121,7 @@ function ItemsTable({ items, stuck }: { items: DownloadItem[]; stuck: Set<string
);
}
function Card({ c }: { c: DownloadClient }) {
function Card({ c, canRead, onRead }: { c: DownloadClient; canRead: boolean; onRead: () => void }) {
const s = c.state;
const stuck = new Set(s?.stuck ?? []);
const failedRecent = new Set(s?.failedRecent ?? []);
@@ -133,7 +134,10 @@ function Card({ c }: { c: DownloadClient }) {
<h3 className="card-title">
{c.name} <span className="text-secondary fw-normal">{KIND_NAMES[c.kind]}{s?.version ? ` ${s.version}` : ""}</span> <Badge c={c} />
</h3>
<div className="card-actions text-secondary small">{c.status ? <>read <TimeAgo value={c.status.at} /></> : "not read yet"}</div>
<div className="card-actions d-flex align-items-center gap-2 text-secondary small">
{c.status ? <>read <TimeAgo value={c.status.at} /></> : "not read yet"}
{canRead && c.enabled && <ReadNowButton integrationId={c.id} name={c.name} onDone={onRead} />}
</div>
</div>
<div className="card-body">
{c.status && !c.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {c.status.error ?? "no answer"}.</div>}
@@ -235,22 +239,23 @@ function Card({ c }: { c: DownloadClient }) {
}
/** qBittorrent and SABnzbd: how fast they are going, what is in their queues and in what state, what is stuck or failed, and the room they have. */
export default function Downloads() {
export default function Downloads({ user }: { user: CurrentUser }) {
const [data, setData] = useState<DownloadClient[] | null>(null);
const [error, setError] = useState<string | null>(null);
const load = () =>
api.downloads
.list()
.then((r) => {
setData(r.clients);
setError(null);
})
.catch((err) => setError(readableError(err)));
useEffect(() => {
const load = () =>
api.downloads
.list()
.then((r) => {
setData(r.clients);
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">Download clients</h2>
@@ -267,7 +272,7 @@ export default function Downloads() {
</div>
</div>
)}
{data?.map((c) => <Card key={c.id} c={c} />)}
{data?.map((c) => <Card key={c.id} c={c} canRead={canRead} onRead={() => void load()} />)}
</>
);
}
+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()} />)}
</>
);
}
+2
View File
@@ -14,6 +14,7 @@ import { toast } from "../utils/toast";
import UptimeRibbon from "../components/UptimeRibbon";
import RunbookEntry from "../components/RunbookEntry";
import IntegrationInspector from "../components/IntegrationInspector";
import ReadNowButton from "../components/ReadNowButton";
import { groupOfType, INSPECTABLE, TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes";
/** "pve.example.lan" out of "https://pve.example.lan:8006/", or the text itself when it isn't an address. */
@@ -291,6 +292,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
Open
</Link>
)}
{isOperator && i.enabled && <ReadNowButton integrationId={i.id} name={i.name} onDone={loadIntegrations} />}
{isAdmin && (
<>
<button className="btn btn-sm" onClick={() => testIntegration(i)} disabled={testingId === i.id}>
+18 -13
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type ArrApp } from "../api/client";
import { api, type ArrApp, type CurrentUser } from "../api/client";
import ReadNowButton from "../components/ReadNowButton";
import EmptyState from "../components/EmptyState";
import TimeAgo from "../components/TimeAgo";
import { BlockSkeleton } from "../components/Skeleton";
@@ -34,7 +35,7 @@ function Tile({ label, value, sub, warn }: { label: string; value: string; sub?:
);
}
function Card({ a }: { a: ArrApp }) {
function Card({ a, canRead, onRead }: { a: ArrApp; canRead: boolean; onRead: () => void }) {
const s = a.state;
const stuck = new Set(s?.stuck ?? []);
const queue = s?.queue ?? null;
@@ -47,7 +48,10 @@ function Card({ a }: { a: ArrApp }) {
<h3 className="card-title">
{a.name} <span className="text-secondary fw-normal">{KIND_NAMES[a.kind]}{s?.version ? ` ${s.version}` : ""}</span> <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>}
@@ -194,22 +198,23 @@ function Card({ a }: { a: ArrApp }) {
}
/** Sonarr, Radarr and Prowlarr: what each says is wrong, the downloads that are stuck, the disks they fill and the indexers that have failed. */
export default function Media() {
export default function Media({ user }: { user: CurrentUser }) {
const [data, setData] = useState<ArrApp[] | null>(null);
const [error, setError] = useState<string | null>(null);
const load = () =>
api.arr
.list()
.then((r) => {
setData(r.apps);
setError(null);
})
.catch((err) => setError(readableError(err)));
useEffect(() => {
const load = () =>
api.arr
.list()
.then((r) => {
setData(r.apps);
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">Media managers</h2>
@@ -226,7 +231,7 @@ export default function Media() {
</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()} />)}
</>
);
}