Lidarr and Readarr join the shared *arr reader. Integrations get an Inspect button that runs the reader once and shows what each request returned as shapes (never values) and where the result is empty. Operations -> App versions compares each application's version with its newest GitHub release (lookup off until an admin switches it on; optional alert). The Alerts page can group by source, kind of problem or type of alert. The shared HTTP helper no longer reuses connections (stale-socket resets). Migration 0078; docs and tests included. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
188 lines
8.8 KiB
TypeScript
188 lines
8.8 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { Link } from "react-router-dom";
|
|
import { api, type AppVersions, type CurrentUser } from "../api/client";
|
|
import EmptyState from "../components/EmptyState";
|
|
import TimeAgo from "../components/TimeAgo";
|
|
import { BlockSkeleton } from "../components/Skeleton";
|
|
import { ErrorNotice } from "../components/Notice";
|
|
import { readableError } from "../utils/errors";
|
|
import { toast } from "../utils/toast";
|
|
|
|
type Row = AppVersions["rows"][number];
|
|
|
|
const LAG: Record<Row["lag"], { text: string; badge: string }> = {
|
|
same: { text: "Up to date", badge: "bg-green-lt text-green" },
|
|
patch: { text: "A patch behind", badge: "bg-blue-lt text-blue" },
|
|
minor: { text: "A minor update behind", badge: "bg-yellow-lt text-yellow" },
|
|
major: { text: "A major version behind", badge: "bg-red-lt text-red" },
|
|
ahead: { text: "Ahead of the newest release", badge: "bg-secondary-lt text-secondary" },
|
|
unknown: { text: "Not compared", badge: "bg-secondary-lt text-secondary" },
|
|
};
|
|
const ORDER: Record<Row["lag"], number> = { major: 0, minor: 1, patch: 2, unknown: 3, ahead: 4, same: 5 };
|
|
|
|
/** What each connected application runs, against the newest release of it — the lookup is switched on here, and is the only thing this app asks of an address of its own choosing. */
|
|
export default function Versions({ user }: { user: CurrentUser }) {
|
|
const isAdmin = user.role === "admin";
|
|
const [data, setData] = useState<AppVersions | null>(null);
|
|
const [error, setError] = useState<string | null>(null);
|
|
const [busy, setBusy] = useState(false);
|
|
const [days, setDays] = useState("0");
|
|
|
|
const adopt = (d: AppVersions) => {
|
|
setData(d);
|
|
setDays(String(d.alertAfterDays));
|
|
setError(null);
|
|
};
|
|
useEffect(() => {
|
|
api.versions
|
|
.get()
|
|
.then(adopt)
|
|
.catch((err) => setError(readableError(err)));
|
|
}, []);
|
|
|
|
async function save(enabled: boolean, alertAfterDays: number) {
|
|
setBusy(true);
|
|
try {
|
|
adopt(await api.versions.save({ enabled, alertAfterDays }));
|
|
toast.success(enabled ? "Saved." : "Switched off.");
|
|
} catch (err) {
|
|
toast.error(readableError(err));
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
async function refresh() {
|
|
setBusy(true);
|
|
try {
|
|
const r = await api.versions.refresh();
|
|
adopt(r);
|
|
toast[r.result.failed > 0 ? "error" : "success"](r.result.failed > 0 ? `${r.result.failed} could not be looked up — see the list.` : `Looked up ${r.result.checked}.`);
|
|
} catch (err) {
|
|
toast.error(readableError(err));
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
const rows = [...(data?.rows ?? [])].sort((a, b) => ORDER[a.lag] - ORDER[b.lag] || a.label.localeCompare(b.label));
|
|
const behind = rows.filter((r) => r.lag === "patch" || r.lag === "minor" || r.lag === "major").length;
|
|
return (
|
|
<>
|
|
<h2 className="page-title">App versions</h2>
|
|
<p className="text-secondary">
|
|
The version each connected application runs — as it was last read (see <Link to="/integrations">Integrations</Link>) — against the newest release of it. It looks the newest ones up on GitHub once a day; <strong>that is the only thing this app asks of an address that is not yours</strong>, so it is switched
|
|
off until you switch it on. Proxmox, Synology and the rest, which have no release to compare with, are not listed.
|
|
</p>
|
|
<ErrorNotice error={error} />
|
|
{!data && !error && <BlockSkeleton lines={4} />}
|
|
{data && (
|
|
<>
|
|
<div className="card mb-3">
|
|
<div className="card-body">
|
|
<label className="form-check mb-2">
|
|
<input type="checkbox" className="form-check-input" checked={data.enabled} disabled={!isAdmin || busy} onChange={(e) => void save(e.target.checked, Number(days) || 0)} />
|
|
<span className="form-check-label">
|
|
Look up the newest releases
|
|
<span className="form-hint d-block">
|
|
Asks <code>api.github.com</code> for the newest release of each application you have connected — its name, nothing about you or your systems. An administrator can switch this.
|
|
</span>
|
|
</span>
|
|
</label>
|
|
<div className="d-flex flex-wrap align-items-center gap-2">
|
|
<label htmlFor="alert-after">Warn when a newer release has been out for</label>
|
|
<input
|
|
id="alert-after"
|
|
className="form-control form-control-sm"
|
|
style={{ width: 80 }}
|
|
inputMode="numeric"
|
|
value={days}
|
|
disabled={!isAdmin || busy || !data.enabled}
|
|
onChange={(e) => setDays(e.target.value.replace(/[^0-9]/g, ""))}
|
|
onBlur={() => Number(days) !== data.alertAfterDays && void save(data.enabled, Math.min(365, Number(days) || 0))}
|
|
/>
|
|
<span>days (0 = never)</span>
|
|
{isAdmin && data.enabled && (
|
|
<button className="btn btn-sm ms-auto" disabled={busy} onClick={() => void refresh()}>
|
|
{busy ? "Looking…" : "Look up now"}
|
|
</button>
|
|
)}
|
|
</div>
|
|
<div className="text-secondary small mt-2">
|
|
{data.enabled ? (data.lastCheckedAt ? <>Last looked up <TimeAgo value={data.lastCheckedAt} />.</> : "Not looked up yet — it is done a few minutes after it is switched on.") : "Switched off."} A warning is raised under <Link to="/alerts">Alerts</Link> only with a number of days above 0.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{rows.length === 0 ? (
|
|
<div className="card">
|
|
<div className="card-body">
|
|
<EmptyState title="No versions known yet" hint="An application's version is known once its integration has been read: Sonarr, Radarr, Prowlarr, Lidarr, Readarr, AdGuard Home, Grafana, Jellyfin, Immich, Paperless-ngx, Nextcloud, NetBox, Authentik and Prometheus are compared." />
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<div className="card">
|
|
<div className="card-header">
|
|
<h3 className="card-title">
|
|
{rows.length} {rows.length === 1 ? "application" : "applications"}
|
|
{data.enabled ? `, ${behind === 0 ? "none behind" : `${behind} behind`}` : ""}
|
|
</h3>
|
|
</div>
|
|
<div className="table-responsive">
|
|
<table className="table table-vcenter card-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Application</th>
|
|
<th>Running</th>
|
|
<th>Newest release</th>
|
|
<th>Compared</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{rows.map((r) => (
|
|
<tr key={r.integrationId}>
|
|
<td>
|
|
<strong>{r.label}</strong>
|
|
<div className="text-secondary small">{r.name}</div>
|
|
</td>
|
|
<td>
|
|
<code>{r.running}</code>
|
|
</td>
|
|
<td>
|
|
{r.latest ? (
|
|
<>
|
|
{r.latest.url ? (
|
|
<a href={r.latest.url} target="_blank" rel="noopener noreferrer">
|
|
<code>{r.latest.tag}</code>
|
|
</a>
|
|
) : (
|
|
<code>{r.latest.tag}</code>
|
|
)}
|
|
{r.latest.publishedAt && (
|
|
<div className="text-secondary small">
|
|
out <TimeAgo value={r.latest.publishedAt} />
|
|
</div>
|
|
)}
|
|
</>
|
|
) : (
|
|
<span className="text-secondary">{data.enabled ? "not known yet" : "—"}</span>
|
|
)}
|
|
{r.lookupError && <div className="text-yellow small">{r.lookupError}</div>}
|
|
</td>
|
|
<td>
|
|
<span className={`badge ${LAG[r.lag].badge}`}>{LAG[r.lag].text}</span>
|
|
{r.daysOut !== null && <div className="text-secondary small">{r.daysOut === 0 ? "a newer one came out today" : r.daysOut === 1 ? "a newer one has been out a day" : `a newer one has been out ${r.daysOut} days`}</div>}
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
}
|