import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { api, type PaperlessInfo } from "../api/client"; import EmptyState from "../components/EmptyState"; import TimeAgo from "../components/TimeAgo"; import { BlockSkeleton } from "../components/Skeleton"; import { ErrorNotice } from "../components/Notice"; import { formatBytes } from "./settings/StorageSettings"; import { readableError } from "../utils/errors"; const NAMES: Record = { database: "Database", redis: "Redis", celery: "Document worker", index: "Search index", classifier: "Classifier", sanity_check: "Sanity check" }; function Badge({ p }: { p: PaperlessInfo }) { if (!p.enabled) return Off; if (!p.state) return Not read yet; if (!p.fresh) return Can’t be read; if (p.problems.some((x) => x.severity === "critical")) return Needs a look; if (p.problems.length > 0) return Needs a look; return In order; } const n = (v: number | null) => (v === null ? "—" : v.toLocaleString()); function Card({ p }: { p: PaperlessInfo }) { const s = p.state; const percent = s?.storage ? Math.round(((s.storage.total - s.storage.available) / s.storage.total) * 100) : null; return (

{p.name}

{p.status ? <>read : "not read yet"}
{p.status && !p.status.ok &&
The last attempt to read it failed: {p.status.error ?? "no answer"}.
} {p.problems.length > 0 && (
    {p.problems.map((x) => (
  • {x.message}
  • ))}
)} {s && ( <>
{[s.version ? `version ${s.version}` : null, s.updateAvailable && s.latestVersion ? `${s.latestVersion} is out` : null].filter(Boolean).join(" · ")}
Documents
{n(s.documents)}
In the inbox
{n(s.inbox)}
Failed to import
0 ? "text-red" : ""}`}>{s.failed === null ? "—" : s.failed.length}
in the last week
Disk
{percent === null ? "—" : `${percent} %`}
{s.storage && (
{formatBytes(s.storage.total - s.storage.available)} of {formatBytes(s.storage.total)}
)}

System status

{!s.components ? (
Paperless did not give its system status — that needs the token of a superuser.
) : (
    {s.components.map((c) => (
  • {c.status === "OK" ? "OK" : c.status === "ERROR" ? "Error" : "Warning"} {NAMES[c.name] ?? c.name} {c.error &&
    {c.error}
    }
  • ))}
)} {s.failed && s.failed.length > 0 && ( <>

Documents that failed to import

    {s.failed.slice(0, 10).map((f, i) => (
  • {f.file} {f.at && ( {" "} — )} {f.error &&
    {f.error}
    }
  • ))}
{s.failed.length > 10 &&
and {s.failed.length - 10} more
} )} )}
); } /** Paperless-ngx: whether the documents are being taken in — the worker, the imports that failed, the inbox, the disk. */ export default function Paperless() { const [data, setData] = useState(null); const [error, setError] = useState(null); useEffect(() => { const load = () => api.paperless .list() .then((r) => { setData(r.paperlesses); setError(null); }) .catch((err) => setError(readableError(err))); void load(); const t = setInterval(load, 60_000); return () => clearInterval(t); }, []); return ( <>

Paperless-ngx

Whether documents are being taken in. It is read every few minutes with an API token (see Integrations). A component in error (above all the worker that consumes documents), documents that failed to import and a{" "} disk that is filling up are alerts — see Alerts.

{!data && !error && } {data && data.length === 0 && (
)} {data?.map((p) => )} ); }