Add Read now to the AdGuard, Technitium, Grafana, Hetzner Cloud, Game servers and Speedtest pages
Operators and administrators get a Read now button in the card header of each enabled integration on these six pages, the same as on the media, download client and Hetzner Robot pages. No server change: all six kinds were already in the Read-now list. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d980c12a04
commit
d88a24b33a
9 files changed
+72
-38
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type AdguardInstance } from "../api/client";
|
||||
import ReadNowButton from "../components/ReadNowButton";
|
||||
import { api, type CurrentUser, type AdguardInstance } from "../api/client";
|
||||
import EmptyState from "../components/EmptyState";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
@@ -52,7 +53,7 @@ function Counted({ title, items, empty }: { title: string; items: { name: string
|
||||
);
|
||||
}
|
||||
|
||||
function Card({ a }: { a: AdguardInstance }) {
|
||||
function Card({ a, canRead, onRead }: { a: AdguardInstance; canRead: boolean; onRead: () => void }) {
|
||||
const s = a.state;
|
||||
const st = s?.stats ?? null;
|
||||
const lists = s?.filters?.lists ?? [];
|
||||
@@ -64,7 +65,10 @@ function Card({ a }: { a: AdguardInstance }) {
|
||||
<h3 className="card-title">
|
||||
{a.name} <span className="text-secondary fw-normal">{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>}
|
||||
@@ -141,7 +145,9 @@ function Card({ a }: { a: AdguardInstance }) {
|
||||
}
|
||||
|
||||
/** AdGuard Home: whether DNS really answers, whether it protects, what it has done and whether its lists are kept up to date. */
|
||||
export default function AdguardHome() {
|
||||
export default function AdguardHome({ user }: { user: CurrentUser }) {
|
||||
const canRead = user.role === "admin" || user.role === "operator";
|
||||
const [tick, setTick] = useState(0);
|
||||
const [data, setData] = useState<AdguardInstance[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
@@ -156,7 +162,7 @@ export default function AdguardHome() {
|
||||
void load();
|
||||
const t = setInterval(load, 60_000);
|
||||
return () => clearInterval(t);
|
||||
}, []);
|
||||
}, [tick]);
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title">AdGuard Home</h2>
|
||||
@@ -173,7 +179,7 @@ export default function AdguardHome() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{data?.map((a) => <Card key={a.id} a={a} />)}
|
||||
{data?.map((a) => <Card key={a.id} a={a} canRead={canRead} onRead={() => setTick((n) => n + 1)} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user