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:
1 parent
01acbaf831
commit
b29c0b7d04
13 files changed
+434
-128
No files matched your search
+18
-13
@@ -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()} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user