✨ UI dynamique (couleurs par etat, spinner, terminal de conversion live, restes de conversion, liens MKV), responsive, scan ISO par contenu, retrait Sonarr/Prowlarr/Jellyfin/Seerr
This commit is contained in:
1 parent
078905e944
commit
70ce0b95a8
20 files changed
+793
-1143
No files matched your search
+263
-21
@@ -17,7 +17,21 @@ type Movie = {
|
||||
last_seen_at: string;
|
||||
};
|
||||
|
||||
type RadarrSettings = {
|
||||
type MovieDetail = Movie & {
|
||||
work_mkv_path?: string | null;
|
||||
linked_mkv_path?: string | null;
|
||||
workspace_folder?: string | null;
|
||||
workspace_files?: string[];
|
||||
};
|
||||
|
||||
type ServiceStatus = {
|
||||
status: "unconfigured" | "configured" | "tested" | "error";
|
||||
tested_version?: string | null;
|
||||
tested_at?: string | null;
|
||||
test_error?: string | null;
|
||||
};
|
||||
|
||||
type RadarrSettings = ServiceStatus & {
|
||||
url: string | null;
|
||||
port: number | null;
|
||||
api_key_configured: boolean;
|
||||
@@ -25,7 +39,7 @@ type RadarrSettings = {
|
||||
|
||||
type NotificationKind = "info" | "error" | "warning";
|
||||
type Notification = { id: number; text: string; kind: NotificationKind };
|
||||
type QbittorrentSettings = {
|
||||
type QbittorrentSettings = ServiceStatus & {
|
||||
url: string | null;
|
||||
port: number | null;
|
||||
username: string | null;
|
||||
@@ -70,7 +84,18 @@ async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const response = await fetch(path, init);
|
||||
if (!response.ok) {
|
||||
const body = await response.json().catch(() => null);
|
||||
throw new Error(body?.detail ?? `Erreur HTTP ${response.status}`);
|
||||
const detail = body?.detail;
|
||||
if (typeof detail === "string") {
|
||||
throw new Error(detail);
|
||||
}
|
||||
if (detail && typeof detail === "object" && "message" in detail) {
|
||||
const error = new Error(String(detail.message)) as Error & {
|
||||
detail?: { code?: string; files?: string[]; folder?: string };
|
||||
};
|
||||
error.detail = detail;
|
||||
throw error;
|
||||
}
|
||||
throw new Error(`Erreur HTTP ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
@@ -84,6 +109,59 @@ function statusLabel(status: string): string {
|
||||
return STATUS_LABELS[status] ?? status;
|
||||
}
|
||||
|
||||
// Classe CSS par etat: chaque etat a sa couleur, les etats actifs ont un
|
||||
// spinner (voir style.css).
|
||||
const STATUS_CLASSES: Record<string, string> = {
|
||||
detected: "status st-detected",
|
||||
ready: "status st-detected",
|
||||
queued: "status st-queued",
|
||||
converting: "status st-active",
|
||||
importing: "status st-active",
|
||||
validating: "status st-validating",
|
||||
completed: "status st-completed",
|
||||
failed: "status error",
|
||||
missing: "status error",
|
||||
};
|
||||
|
||||
function statusClass(status: string): string {
|
||||
return STATUS_CLASSES[status] ?? "status";
|
||||
}
|
||||
|
||||
function isSpinning(status: string): boolean {
|
||||
return ["queued", "converting", "importing"].includes(status);
|
||||
}
|
||||
|
||||
function StatusPill({status}: { status: string }) {
|
||||
return (
|
||||
<span className={statusClass(status)}>
|
||||
{isSpinning(status) && <span className="spinner" aria-hidden="true" />}
|
||||
{statusLabel(status)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// Badge de statut de connexion pour la page Configuration.
|
||||
function ServiceBadge({state, label}: { state: ServiceStatus; label: string }) {
|
||||
if (state.status === "tested") {
|
||||
return (
|
||||
<span className="status st-completed" title={state.test_error ?? undefined}>
|
||||
Testé{state.tested_version ? ` · ${state.tested_version}` : ""}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (state.status === "error") {
|
||||
return (
|
||||
<span className="status error" title={state.test_error ?? undefined}>
|
||||
Test échoué
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (state.status === "configured") {
|
||||
return <span className="status st-queued">Configuré · non testé</span>;
|
||||
}
|
||||
return <span className="status st-detected">{label} non configuré</span>;
|
||||
}
|
||||
|
||||
function formatDateTime(iso: string): string {
|
||||
const date = new Date(iso);
|
||||
return Number.isNaN(date.getTime()) ? "—" : dateFormatter.format(date);
|
||||
@@ -122,7 +200,12 @@ export default function App() {
|
||||
const [qbitPassword, setQbitPassword] = useState("");
|
||||
const [qbitApiKey, setQbitApiKey] = useState("");
|
||||
const [qbitConfigured, setQbitConfigured] = useState(false);
|
||||
const [selected, setSelected] = useState<Movie | null>(null);
|
||||
const [radarrState, setRadarrState] = useState<ServiceStatus | null>(null);
|
||||
const [qbittorrentState, setQbittorrentState] = useState<ServiceStatus | null>(null);
|
||||
const [logLines, setLogLines] = useState<string[]>([]);
|
||||
const [logRunning, setLogRunning] = useState(false);
|
||||
const terminalRef = useRef<HTMLPreElement | null>(null);
|
||||
const [selected, setSelected] = useState<MovieDetail | null>(null);
|
||||
const [posterUrl, setPosterUrl] = useState<string | null>(null);
|
||||
const [modalBusy, setModalBusy] = useState(false);
|
||||
const [modalMessage, setModalMessage] = useState("");
|
||||
@@ -213,12 +296,25 @@ export default function App() {
|
||||
setQbitUrl(qbittorrent.url ?? "");
|
||||
setQbitPort(qbittorrent.port?.toString() ?? "");
|
||||
setQbitUsername(qbittorrent.username ?? "");
|
||||
setQbitConfigured(qbittorrent.password_configured || qbittorrent.api_key_configured);
|
||||
if (!radarr.api_key_configured || !qbittorrent.password_configured) {
|
||||
setQbitConfigured(qbittorrent.status !== "unconfigured");
|
||||
setRadarrState(radarr);
|
||||
setQbittorrentState(qbittorrent);
|
||||
if (radarr.status === "unconfigured") {
|
||||
notify(
|
||||
"Configuration incomplète — renseignez les connexions Radarr et qBittorrent dans la page Configuration.",
|
||||
"Connexion Radarr non configurée — renseignez-la dans la page Configuration.",
|
||||
"warning",
|
||||
);
|
||||
} else if (radarr.status === "error") {
|
||||
notify(
|
||||
"Connexion Radarr en échec au dernier test — vérifiez la page Configuration.",
|
||||
"warning",
|
||||
);
|
||||
}
|
||||
if (qbittorrent.status === "unconfigured") {
|
||||
notify(
|
||||
"qBittorrent non configuré — la suppression du torrent à la validation sera désactivée.",
|
||||
"info",
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
@@ -226,13 +322,54 @@ export default function App() {
|
||||
});
|
||||
}, [authState, loadMovies]);
|
||||
|
||||
const hasActive = movies.some((movie) =>
|
||||
["queued", "converting", "importing"].includes(movie.status),
|
||||
);
|
||||
useEffect(() => {
|
||||
if (authState !== "authed") return;
|
||||
const timer = setInterval(() => {
|
||||
loadMovies().catch(() => undefined);
|
||||
}, 10_000);
|
||||
}, hasActive ? 3_000 : 10_000);
|
||||
return () => clearInterval(timer);
|
||||
}, [authState, loadMovies]);
|
||||
}, [authState, loadMovies, hasActive]);
|
||||
|
||||
// Fiche ouverte: rafraichit le detail et le terminal de conversion pendant
|
||||
// les etats actifs ou apres un echec.
|
||||
useEffect(() => {
|
||||
if (!selected) return;
|
||||
if (!["queued", "converting", "importing", "failed"].includes(selected.status)) {
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
const timer = setInterval(async () => {
|
||||
const detail = await api<MovieDetail>(`/api/files/${selected.id}`).catch(() => null);
|
||||
const log = await api<{ lines: string[]; running: boolean }>(
|
||||
`/api/movies/${selected.id}/log`,
|
||||
).catch(() => null);
|
||||
if (cancelled) return;
|
||||
if (detail) setSelected(detail);
|
||||
if (log) {
|
||||
setLogLines(log.lines);
|
||||
setLogRunning(log.running);
|
||||
}
|
||||
}, 2_000);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, [selected]);
|
||||
|
||||
// Terminal: reste colle en bas de la sortie.
|
||||
useEffect(() => {
|
||||
if (terminalRef.current) {
|
||||
terminalRef.current.scrollTop = terminalRef.current.scrollHeight;
|
||||
}
|
||||
}, [logLines]);
|
||||
|
||||
function copyPath(path: string) {
|
||||
navigator.clipboard.writeText(path).catch(() => undefined);
|
||||
notify("Chemin copié dans le presse-papiers.");
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
setTheme((current) => {
|
||||
@@ -311,12 +448,21 @@ export default function App() {
|
||||
});
|
||||
setKeyConfigured(settings.api_key_configured);
|
||||
setApiKey("");
|
||||
setRadarrState(settings);
|
||||
const result = await api<{ message: string }>("/api/settings/radarr/test", {
|
||||
method: "POST",
|
||||
});
|
||||
notify(result.message);
|
||||
// Le resultat du test est persiste: on recharge le statut.
|
||||
const fresh = await api<RadarrSettings>("/api/settings/radarr").catch(() => null);
|
||||
if (fresh) {
|
||||
setRadarrState(fresh);
|
||||
setKeyConfigured(fresh.api_key_configured);
|
||||
}
|
||||
} catch (error) {
|
||||
notify((error as Error).message, "error");
|
||||
const fresh = await api<RadarrSettings>("/api/settings/radarr").catch(() => null);
|
||||
if (fresh) setRadarrState(fresh);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
@@ -337,15 +483,23 @@ export default function App() {
|
||||
api_key: qbitApiKey || null,
|
||||
}),
|
||||
});
|
||||
setQbitConfigured(settings.password_configured || settings.api_key_configured);
|
||||
setQbitConfigured(settings.status !== "unconfigured");
|
||||
setQbittorrentState(settings);
|
||||
setQbitPassword("");
|
||||
setQbitApiKey("");
|
||||
const result = await api<{ message: string }>("/api/settings/qbittorrent/test", {
|
||||
method: "POST",
|
||||
});
|
||||
notify(result.message);
|
||||
const fresh = await api<QbittorrentSettings>("/api/settings/qbittorrent").catch(() => null);
|
||||
if (fresh) {
|
||||
setQbittorrentState(fresh);
|
||||
setQbitConfigured(fresh.status !== "unconfigured");
|
||||
}
|
||||
} catch (error) {
|
||||
notify((error as Error).message, "error");
|
||||
const fresh = await api<QbittorrentSettings>("/api/settings/qbittorrent").catch(() => null);
|
||||
if (fresh) setQbittorrentState(fresh);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
@@ -441,11 +595,23 @@ export default function App() {
|
||||
setDeleting(false);
|
||||
}
|
||||
|
||||
function openMovie(movie: Movie) {
|
||||
async function openMovie(movie: Movie) {
|
||||
setSelected(movie);
|
||||
setPosterUrl(movie.poster_url);
|
||||
setModalMessage("");
|
||||
setModalError(false);
|
||||
setLogLines([]);
|
||||
setLogRunning(false);
|
||||
const detail = await api<MovieDetail>(`/api/files/${movie.id}`).catch(() => null);
|
||||
if (detail) {
|
||||
setSelected(detail);
|
||||
api<{ lines: string[]; running: boolean }>(`/api/movies/${movie.id}/log`)
|
||||
.then((log) => {
|
||||
setLogLines(log.lines);
|
||||
setLogRunning(log.running);
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
@@ -455,19 +621,32 @@ export default function App() {
|
||||
setModalError(false);
|
||||
}
|
||||
|
||||
async function convert(movie: Movie) {
|
||||
async function convert(movie: MovieDetail, force = false) {
|
||||
setModalBusy(true);
|
||||
setModalMessage("");
|
||||
try {
|
||||
await api<Movie>(`/api/movies/${movie.id}/convert`, { method: "POST" });
|
||||
await api<Movie>(
|
||||
`/api/movies/${movie.id}/convert${force ? "?force=true" : ""}`,
|
||||
{ method: "POST" },
|
||||
);
|
||||
await loadMovies();
|
||||
setModalMessage("Conversion mise en file d'attente.");
|
||||
setModalError(false);
|
||||
closeModal();
|
||||
notify(`Conversion de « ${movie.title} » mise en file d'attente.`);
|
||||
} catch (error) {
|
||||
setModalMessage((error as Error).message);
|
||||
setModalError(true);
|
||||
const detail = (error as { detail?: { code?: string } }).detail;
|
||||
if (detail?.code === "workspace_not_empty") {
|
||||
// Restes d'anciennes conversions: la fiche les affiche avec le
|
||||
// bouton de suppression.
|
||||
setModalMessage((error as Error).message);
|
||||
setModalError(true);
|
||||
const fresh = await api<MovieDetail>(`/api/files/${movie.id}`).catch(() => null);
|
||||
if (fresh) setSelected(fresh);
|
||||
} else {
|
||||
setModalMessage((error as Error).message);
|
||||
setModalError(true);
|
||||
}
|
||||
} finally {
|
||||
setModalBusy(false);
|
||||
}
|
||||
@@ -903,9 +1082,7 @@ export default function App() {
|
||||
</button>
|
||||
)}
|
||||
{movie.radarr_linked && <span className="status linked">Radarr lié</span>}
|
||||
<span className={BROKEN.includes(movie.status) ? "status error" : "status"}>
|
||||
{statusLabel(movie.status)}
|
||||
</span>
|
||||
<StatusPill status={movie.status} />
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
@@ -919,7 +1096,10 @@ export default function App() {
|
||||
<section className="panel settings">
|
||||
<div className="panel-head">
|
||||
<p className="eyebrow">CONFIGURATION</p>
|
||||
<h2>Connexion Radarr</h2>
|
||||
<h2>
|
||||
Connexion Radarr{" "}
|
||||
{radarrState && <ServiceBadge state={radarrState} label="Radarr" />}
|
||||
</h2>
|
||||
<p>L’URL doit être accessible depuis le conteneur MKVTool.</p>
|
||||
</div>
|
||||
<form onSubmit={saveSettings}>
|
||||
@@ -962,7 +1142,10 @@ export default function App() {
|
||||
<section className="panel settings">
|
||||
<div className="panel-head">
|
||||
<p className="eyebrow">CONFIGURATION</p>
|
||||
<h2>Connexion qBittorrent</h2>
|
||||
<h2>
|
||||
Connexion qBittorrent{" "}
|
||||
{qbittorrentState && <ServiceBadge state={qbittorrentState} label="qBittorrent" />}
|
||||
</h2>
|
||||
<p>
|
||||
Utilisée pour supprimer le torrent et ses données lors de la validation
|
||||
finale d’une conversion.
|
||||
@@ -1062,7 +1245,7 @@ export default function App() {
|
||||
<dl className="modal-grid">
|
||||
<div>
|
||||
<dt>État</dt>
|
||||
<dd>{statusLabel(selected.status)}</dd>
|
||||
<dd><StatusPill status={selected.status} /></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Taille de l’ISO</dt>
|
||||
@@ -1092,10 +1275,69 @@ export default function App() {
|
||||
<dt>Emplacement</dt>
|
||||
<dd><code>{selected.path}</code></dd>
|
||||
</div>
|
||||
{["validating", "completed"].includes(selected.status) && selected.linked_mkv_path && (
|
||||
<div className="modal-path">
|
||||
<dt>MKV lié (dossier du film)</dt>
|
||||
<dd className="path-row">
|
||||
<code>{selected.linked_mkv_path}</code>
|
||||
<button className="small copy" onClick={() => copyPath(selected.linked_mkv_path ?? "")}>
|
||||
Copier
|
||||
</button>
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
{["validating", "completed"].includes(selected.status) && selected.work_mkv_path && (
|
||||
<div className="modal-path">
|
||||
<dt>MKV brut (dossier de travail)</dt>
|
||||
<dd className="path-row">
|
||||
<code>{selected.work_mkv_path}</code>
|
||||
<button className="small copy" onClick={() => copyPath(selected.work_mkv_path ?? "")}>
|
||||
Copier
|
||||
</button>
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
</dl>
|
||||
|
||||
{selected.last_error && <p className="message error">{selected.last_error}</p>}
|
||||
|
||||
{convertible && (selected.workspace_files?.length ?? 0) > 0 && (
|
||||
<div className="workspace-warning">
|
||||
<p>
|
||||
Des fichiers issus d’anciennes conversions sont présents dans le dossier
|
||||
de travail <code>{selected.workspace_folder}</code> :
|
||||
</p>
|
||||
<ul>
|
||||
{(selected.workspace_files ?? []).map((name) => (
|
||||
<li key={name}><code>{name}</code></li>
|
||||
))}
|
||||
</ul>
|
||||
<button
|
||||
className="danger"
|
||||
disabled={modalBusy}
|
||||
onClick={() => convert(selected, true)}
|
||||
>
|
||||
{modalBusy ? "Nettoyage…" : "Tout supprimer et reprendre la conversion"}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{["converting", "importing", "failed"].includes(selected.status) && (
|
||||
<div className="terminal-box">
|
||||
<div className="terminal-head">
|
||||
<span className={logRunning ? "dotpulse" : "dot"} aria-hidden="true" />
|
||||
<span>
|
||||
{logRunning
|
||||
? "Terminal de conversion — en direct"
|
||||
: "Journal de la dernière conversion"}
|
||||
</span>
|
||||
</div>
|
||||
<pre className="terminal" ref={terminalRef}>
|
||||
{logLines.length > 0 ? logLines.join("\n") : "En attente de sortie…"}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<p className="modal-explain">
|
||||
La conversion extrait le film du disque ISO vers un fichier MKV avec MakeMKV,
|
||||
sans réencodage : vidéo, audio et sous-titres sont conservés à l’identique.
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import type {ServiceStatus} from "../types";
|
||||
|
||||
type Props = ServiceStatus;
|
||||
|
||||
export default function ServiceStatusBadge({status, tested_version: version, test_error: error}: Props) {
|
||||
if (status === "tested") {
|
||||
return (
|
||||
<span className="status linked" title={error ?? undefined}>
|
||||
Testé{version ? ` · ${version}` : ""}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (status === "error") {
|
||||
return (
|
||||
<span className="status error" title={error ?? undefined}>
|
||||
Test échoué
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (status === "configured") {
|
||||
return <span className="status warn">Configuré · non testé</span>;
|
||||
}
|
||||
return <span className="status">Non configuré</span>;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
export default function StatusBadge({status}: { status: string }) {
|
||||
const normalized = status.toLowerCase();
|
||||
|
||||
let variant: "neutral" | "warn" | "info" | "success" = "neutral";
|
||||
if (["processing", "in_progress", "converting", "moving"].includes(normalized)) variant = "info";
|
||||
if (["detected", "new", "pending", "todo", "unprocessed"].includes(normalized)) variant = "warn";
|
||||
if (["processed", "done", "completed", "success"].includes(normalized)) variant = "success";
|
||||
|
||||
return <span className={`badge badge--${variant}`}>{status}</span>;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
export const jsonHeaders = {"Content-Type": "application/json"};
|
||||
|
||||
export async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const response = await fetch(path, init);
|
||||
if (!response.ok) {
|
||||
const body = await response.json().catch(() => null);
|
||||
throw new Error(body?.detail ?? `Erreur HTTP ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export function readableSize(size: number | null): string {
|
||||
if (size === null) return "—";
|
||||
return `${(size / 1024 ** 3).toFixed(1)} Go`;
|
||||
}
|
||||
|
||||
export function formatDateTime(iso: string | null | undefined): string {
|
||||
if (!iso) return "—";
|
||||
const date = new Date(iso);
|
||||
if (Number.isNaN(date.getTime())) return iso;
|
||||
return new Intl.DateTimeFormat("fr-FR", {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "short",
|
||||
}).format(date);
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
|
||||
import {api, formatDateTime, readableSize} from "../lib/api";
|
||||
import type {Movie, SettingsRead} from "../types";
|
||||
import StatusBadge from "../components/StatusBadge";
|
||||
|
||||
type Props = {
|
||||
onOpenFile: (id: number) => void;
|
||||
onOpenFiles: () => void;
|
||||
onOpenSettings: () => void;
|
||||
};
|
||||
|
||||
function isProcessing(status: string): boolean {
|
||||
return ["processing", "in_progress", "converting", "moving"].includes(status.toLowerCase());
|
||||
}
|
||||
|
||||
function isProcessed(status: string): boolean {
|
||||
return ["processed", "done", "completed", "success"].includes(status.toLowerCase());
|
||||
}
|
||||
|
||||
export default function Dashboard({onOpenFile, onOpenFiles, onOpenSettings}: Props) {
|
||||
const [movies, setMovies] = useState<Movie[]>([]);
|
||||
const [settings, setSettings] = useState<SettingsRead | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [message, setMessage] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([api<Movie[]>("/api/movies"), api<SettingsRead>("/api/settings")])
|
||||
.then(([m, s]) => {
|
||||
setMovies(m);
|
||||
setSettings(s);
|
||||
})
|
||||
.catch((e: Error) => setMessage(e.message));
|
||||
}, []);
|
||||
|
||||
const canScan = settings?.radarr.api_key_configured ?? false;
|
||||
|
||||
async function scan() {
|
||||
setBusy(true);
|
||||
setMessage("");
|
||||
try {
|
||||
const result = await api<{ iso_files: number; scanned_movies: number }>("/api/scans", {method: "POST"});
|
||||
setMovies(await api<Movie[]>("/api/movies"));
|
||||
setMessage(`${result.iso_files} ISO trouvée(s) sur ${result.scanned_movies} film(s)`);
|
||||
} catch (e) {
|
||||
setMessage((e as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
const stats = useMemo(() => {
|
||||
const total = movies.length;
|
||||
const processing = movies.filter((m) => isProcessing(m.status));
|
||||
const processed = movies.filter((m) => isProcessed(m.status));
|
||||
const unprocessed = total - processing.length - processed.length;
|
||||
|
||||
const recentlyProcessed = [...processed]
|
||||
.filter((m) => !!m.processed_at)
|
||||
.sort((a, b) => (b.processed_at ?? "").localeCompare(a.processed_at ?? ""))
|
||||
.slice(0, 6);
|
||||
|
||||
return {total, processing, processed, unprocessed, recentlyProcessed};
|
||||
}, [movies]);
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<section className="hero">
|
||||
<div className="hero__row">
|
||||
<div>
|
||||
<h2>Dashboard</h2>
|
||||
<p className="muted">
|
||||
Vue rapide sur l’état de vos fichiers. Pour afficher “tout juste traités”, le backend doit
|
||||
renseigner
|
||||
<code> processed_at</code> à la fin du workflow.
|
||||
</p>
|
||||
</div>
|
||||
<div className="hero__actions">
|
||||
<button className="btn" onClick={scan} disabled={busy || !canScan}>
|
||||
Scanner maintenant
|
||||
</button>
|
||||
{!canScan && (
|
||||
<button className="btn btn--ghost" type="button" onClick={onOpenSettings}>
|
||||
Configurer Radarr
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="kpis">
|
||||
<div className="kpi">
|
||||
<div className="kpi__label">Total</div>
|
||||
<div className="kpi__value">{stats.total}</div>
|
||||
</div>
|
||||
<div className="kpi">
|
||||
<div className="kpi__label">Non traités</div>
|
||||
<div className="kpi__value">{stats.unprocessed}</div>
|
||||
</div>
|
||||
<div className="kpi">
|
||||
<div className="kpi__label">En cours</div>
|
||||
<div className="kpi__value">{stats.processing.length}</div>
|
||||
</div>
|
||||
<div className="kpi">
|
||||
<div className="kpi__label">Traités</div>
|
||||
<div className="kpi__value">{stats.processed.length}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{message && <div className="toast">{message}</div>}
|
||||
|
||||
<section className="grid-2">
|
||||
<section className="card">
|
||||
<div className="card__head">
|
||||
<h3>En cours de traitement</h3>
|
||||
<button className="btn btn--ghost" type="button" onClick={onOpenFiles}>
|
||||
Voir tous
|
||||
</button>
|
||||
</div>
|
||||
{stats.processing.length === 0 ? (
|
||||
<div className="empty">Aucun traitement en cours.</div>
|
||||
) : (
|
||||
<div className="list">
|
||||
{stats.processing.slice(0, 6).map((m) => (
|
||||
<button key={m.id} className="list__row" type="button" onClick={() => onOpenFile(m.id)}>
|
||||
<div>
|
||||
<div className="list__title">{m.title}</div>
|
||||
<div
|
||||
className="muted">{m.year ?? "Année inconnue"} · {readableSize(m.size)}</div>
|
||||
</div>
|
||||
<StatusBadge status={m.status}/>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<div className="card__head">
|
||||
<h3>Tout juste traités</h3>
|
||||
<button className="btn btn--ghost" type="button" onClick={onOpenFiles}>
|
||||
Voir tous
|
||||
</button>
|
||||
</div>
|
||||
{stats.recentlyProcessed.length === 0 ? (
|
||||
<div className="empty">
|
||||
Aucun élément récent (champ <code>processed_at</code> non renseigné).
|
||||
</div>
|
||||
) : (
|
||||
<div className="list">
|
||||
{stats.recentlyProcessed.map((m) => (
|
||||
<button key={m.id} className="list__row" type="button" onClick={() => onOpenFile(m.id)}>
|
||||
<div>
|
||||
<div className="list__title">{m.title}</div>
|
||||
<div className="muted">Fini le {formatDateTime(m.processed_at)}</div>
|
||||
</div>
|
||||
<StatusBadge status={m.status}/>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
import {api, formatDateTime, readableSize} from "../lib/api";
|
||||
import type {Movie} from "../types";
|
||||
import StatusBadge from "../components/StatusBadge";
|
||||
|
||||
type Props = {
|
||||
id: number;
|
||||
onBack: () => void;
|
||||
};
|
||||
|
||||
export default function FileDetails({id, onBack}: Props) {
|
||||
const [item, setItem] = useState<Movie | null>(null);
|
||||
const [error, setError] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
setError("");
|
||||
setItem(null);
|
||||
api<Movie>(`/api/files/${id}`)
|
||||
.then(setItem)
|
||||
.catch((e: Error) => setError(e.message));
|
||||
}, [id]);
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<section className="hero hero--compact">
|
||||
<div className="hero__row">
|
||||
<div>
|
||||
<h2>Détails du fichier</h2>
|
||||
<p className="muted">Informations liées au fichier détecté et à son état de traitement.</p>
|
||||
</div>
|
||||
<div className="hero__actions">
|
||||
<button className="btn btn--ghost" type="button" onClick={onBack}>
|
||||
← Retour
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{error && <div className="toast toast--danger">{error}</div>}
|
||||
|
||||
{!item ? (
|
||||
<section className="card">
|
||||
<div className="skeleton"/>
|
||||
</section>
|
||||
) : (
|
||||
<>
|
||||
<section className="card">
|
||||
<div className="detail-head">
|
||||
<div>
|
||||
<h3>{item.title}</h3>
|
||||
<p className="muted">{item.year ?? "Année inconnue"}</p>
|
||||
</div>
|
||||
<StatusBadge status={item.status}/>
|
||||
</div>
|
||||
|
||||
<div className="detail-grid">
|
||||
<div className="kv">
|
||||
<div className="kv__k">Chemin</div>
|
||||
<div className="kv__v">
|
||||
<code>{item.path}</code>
|
||||
</div>
|
||||
</div>
|
||||
<div className="kv">
|
||||
<div className="kv__k">Taille</div>
|
||||
<div className="kv__v">{readableSize(item.size)}</div>
|
||||
</div>
|
||||
<div className="kv">
|
||||
<div className="kv__k">Détecté</div>
|
||||
<div className="kv__v">{formatDateTime(item.created_at)}</div>
|
||||
</div>
|
||||
<div className="kv">
|
||||
<div className="kv__k">Dernière présence</div>
|
||||
<div className="kv__v">{formatDateTime(item.last_seen_at)}</div>
|
||||
</div>
|
||||
<div className="kv">
|
||||
<div className="kv__k">Fin de traitement</div>
|
||||
<div className="kv__v">{formatDateTime(item.processed_at)}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h3>Actions (à venir)</h3>
|
||||
<p className="muted">
|
||||
Ici on pourra ajouter: relancer un traitement, ouvrir le dossier, suppression, etc.
|
||||
</p>
|
||||
</section>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
|
||||
import {api, readableSize} from "../lib/api";
|
||||
import type {Movie} from "../types";
|
||||
import StatusBadge from "../components/StatusBadge";
|
||||
|
||||
type Props = {
|
||||
onOpenFile: (id: number) => void;
|
||||
};
|
||||
|
||||
type UiStatus = "non_traite" | "en_cours" | "traite";
|
||||
|
||||
function mapStatus(status: string): UiStatus {
|
||||
const s = status.toLowerCase();
|
||||
if (["processing", "in_progress", "converting", "moving"].includes(s)) return "en_cours";
|
||||
if (["processed", "done", "completed", "success"].includes(s)) return "traite";
|
||||
return "non_traite";
|
||||
}
|
||||
|
||||
export default function Files({onOpenFile}: Props) {
|
||||
const [items, setItems] = useState<Movie[]>([]);
|
||||
const [filter, setFilter] = useState<UiStatus | "all">("all");
|
||||
const [query, setQuery] = useState("");
|
||||
const [error, setError] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
api<Movie[]>("/api/files")
|
||||
.then(setItems)
|
||||
.catch((e: Error) => setError(e.message));
|
||||
}, []);
|
||||
|
||||
const groups = useMemo(() => {
|
||||
const base = items
|
||||
.filter((x) => (filter === "all" ? true : mapStatus(x.status) === filter))
|
||||
.filter((x) => {
|
||||
const q = query.trim().toLowerCase();
|
||||
if (!q) return true;
|
||||
return `${x.title} ${x.year ?? ""} ${x.path}`.toLowerCase().includes(q);
|
||||
});
|
||||
|
||||
const counts = {
|
||||
all: items.length,
|
||||
non_traite: items.filter((x) => mapStatus(x.status) === "non_traite").length,
|
||||
en_cours: items.filter((x) => mapStatus(x.status) === "en_cours").length,
|
||||
traite: items.filter((x) => mapStatus(x.status) === "traite").length,
|
||||
};
|
||||
|
||||
return {base, counts};
|
||||
}, [items, filter, query]);
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<section className="hero hero--compact">
|
||||
<div className="hero__row">
|
||||
<div>
|
||||
<h2>Gestion des fichiers</h2>
|
||||
<p className="muted">Filtrez l’inventaire et ouvrez un fichier pour consulter le détail.</p>
|
||||
</div>
|
||||
<div className="hero__actions">
|
||||
<div className="segmented">
|
||||
<button
|
||||
type="button"
|
||||
className={filter === "all" ? "segmented__btn segmented__btn--active" : "segmented__btn"}
|
||||
onClick={() => setFilter("all")}
|
||||
>
|
||||
Tous <span className="segmented__count">{groups.counts.all}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={
|
||||
filter === "non_traite" ? "segmented__btn segmented__btn--active" : "segmented__btn"
|
||||
}
|
||||
onClick={() => setFilter("non_traite")}
|
||||
>
|
||||
Non traités <span className="segmented__count">{groups.counts.non_traite}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={
|
||||
filter === "en_cours" ? "segmented__btn segmented__btn--active" : "segmented__btn"
|
||||
}
|
||||
onClick={() => setFilter("en_cours")}
|
||||
>
|
||||
En cours <span className="segmented__count">{groups.counts.en_cours}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={filter === "traite" ? "segmented__btn segmented__btn--active" : "segmented__btn"}
|
||||
onClick={() => setFilter("traite")}
|
||||
>
|
||||
Traités <span className="segmented__count">{groups.counts.traite}</span>
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
className="search"
|
||||
placeholder="Rechercher (titre, année, chemin…)"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{error && <div className="toast toast--danger">{error}</div>}
|
||||
|
||||
<section className="card">
|
||||
<div className="table">
|
||||
<div className="table__head">
|
||||
<div>Titre</div>
|
||||
<div>Fichier</div>
|
||||
<div>Taille</div>
|
||||
<div>Statut</div>
|
||||
</div>
|
||||
|
||||
{groups.base.length === 0 ? (
|
||||
<div className="empty">Aucun résultat.</div>
|
||||
) : (
|
||||
groups.base.map((movie) => (
|
||||
<button
|
||||
key={movie.id}
|
||||
className="table__row"
|
||||
type="button"
|
||||
onClick={() => onOpenFile(movie.id)}
|
||||
>
|
||||
<div className="table__cell">
|
||||
<div className="table__title">{movie.title}</div>
|
||||
<div className="muted">{movie.year ?? "Année inconnue"}</div>
|
||||
</div>
|
||||
<div className="table__cell">
|
||||
<code>{movie.path}</code>
|
||||
</div>
|
||||
<div className="table__cell">{readableSize(movie.size)}</div>
|
||||
<div className="table__cell">
|
||||
<StatusBadge status={movie.status}/>
|
||||
</div>
|
||||
</button>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,412 +0,0 @@
|
||||
import {useCallback, useEffect, useMemo, useState} from "react";
|
||||
import type React from "react";
|
||||
|
||||
import {api, jsonHeaders} from "../lib/api";
|
||||
import type {SettingsRead} from "../types";
|
||||
import ServiceStatusBadge from "../components/ServiceStatusBadge";
|
||||
|
||||
export default function Settings() {
|
||||
const [radarrUrl, setRadarrUrl] = useState("");
|
||||
const [radarrApiKey, setRadarrApiKey] = useState("");
|
||||
const [radarrKeyConfigured, setRadarrKeyConfigured] = useState(false);
|
||||
|
||||
const [sonarrUrl, setSonarrUrl] = useState("");
|
||||
const [sonarrApiKey, setSonarrApiKey] = useState("");
|
||||
const [sonarrKeyConfigured, setSonarrKeyConfigured] = useState(false);
|
||||
|
||||
const [prowlarrUrl, setProwlarrUrl] = useState("");
|
||||
const [prowlarrApiKey, setProwlarrApiKey] = useState("");
|
||||
const [prowlarrKeyConfigured, setProwlarrKeyConfigured] = useState(false);
|
||||
|
||||
const [jellyfinUrl, setJellyfinUrl] = useState("");
|
||||
const [jellyfinApiKey, setJellyfinApiKey] = useState("");
|
||||
const [jellyfinKeyConfigured, setJellyfinKeyConfigured] = useState(false);
|
||||
|
||||
const [seerrUrl, setSeerrUrl] = useState("");
|
||||
const [seerrApiKey, setSeerrApiKey] = useState("");
|
||||
const [seerrKeyConfigured, setSeerrKeyConfigured] = useState(false);
|
||||
|
||||
const [qbitUrl, setQbitUrl] = useState("");
|
||||
const [qbitUsername, setQbitUsername] = useState("");
|
||||
const [qbitPassword, setQbitPassword] = useState("");
|
||||
const [qbitPasswordConfigured, setQbitPasswordConfigured] = useState(false);
|
||||
const [qbitApiKey, setQbitApiKey] = useState("");
|
||||
const [qbitApiKeyConfigured, setQbitApiKeyConfigured] = useState(false);
|
||||
|
||||
const [message, setMessage] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [settings, setSettings] = useState<SettingsRead | null>(null);
|
||||
|
||||
const serviceHelp = useMemo(() => "L’URL doit être accessible depuis le conteneur MKVTool.", []);
|
||||
|
||||
const hydrateSettings = useCallback((settings: SettingsRead) => {
|
||||
setRadarrUrl(settings.radarr.url ?? "");
|
||||
setRadarrKeyConfigured(settings.radarr.api_key_configured);
|
||||
|
||||
setSonarrUrl(settings.sonarr.url ?? "");
|
||||
setSonarrKeyConfigured(settings.sonarr.api_key_configured);
|
||||
|
||||
setProwlarrUrl(settings.prowlarr.url ?? "");
|
||||
setProwlarrKeyConfigured(settings.prowlarr.api_key_configured);
|
||||
|
||||
setJellyfinUrl(settings.jellyfin.url ?? "");
|
||||
setJellyfinKeyConfigured(settings.jellyfin.api_key_configured);
|
||||
|
||||
setSeerrUrl(settings.seerr.url ?? "");
|
||||
setSeerrKeyConfigured(settings.seerr.api_key_configured);
|
||||
|
||||
setQbitUrl(settings.qbittorrent.url ?? "");
|
||||
setQbitUsername(settings.qbittorrent.username ?? "");
|
||||
setQbitPasswordConfigured(settings.qbittorrent.password_configured);
|
||||
setQbitApiKeyConfigured(settings.qbittorrent.api_key_configured);
|
||||
}, []);
|
||||
|
||||
const refreshSettings = useCallback(async (): Promise<SettingsRead> => {
|
||||
const fresh = await api<SettingsRead>("/api/settings");
|
||||
hydrateSettings(fresh);
|
||||
setSettings(fresh);
|
||||
return fresh;
|
||||
}, [hydrateSettings]);
|
||||
|
||||
useEffect(() => {
|
||||
refreshSettings().catch((error: Error) => setMessage(error.message));
|
||||
}, [refreshSettings]);
|
||||
|
||||
async function testService(name: "radarr" | "sonarr" | "prowlarr" | "jellyfin" | "seerr" | "qbittorrent"): Promise<void> {
|
||||
try {
|
||||
const result = await api<{ message: string }>(`/api/settings/${name}/test`, {method: "POST"});
|
||||
setMessage(result.message);
|
||||
} catch (error) {
|
||||
setMessage((error as Error).message);
|
||||
}
|
||||
await refreshSettings().catch(() => undefined);
|
||||
}
|
||||
|
||||
async function saveRadarr(event: React.FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
setMessage("");
|
||||
try {
|
||||
await api<SettingsRead>("/api/settings", {
|
||||
method: "PUT",
|
||||
headers: jsonHeaders,
|
||||
body: JSON.stringify({
|
||||
radarr: {
|
||||
url: radarrUrl || null,
|
||||
api_key: radarrApiKey || null,
|
||||
},
|
||||
}),
|
||||
});
|
||||
setRadarrApiKey("");
|
||||
await refreshSettings();
|
||||
await testService("radarr");
|
||||
} catch (error) {
|
||||
setMessage((error as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveApiService(
|
||||
name: "sonarr" | "prowlarr" | "jellyfin" | "seerr",
|
||||
event: React.FormEvent<HTMLFormElement>,
|
||||
) {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
setMessage("");
|
||||
|
||||
const model = {
|
||||
sonarr: {url: sonarrUrl || null, api_key: sonarrApiKey || null},
|
||||
prowlarr: {url: prowlarrUrl || null, api_key: prowlarrApiKey || null},
|
||||
jellyfin: {url: jellyfinUrl || null, api_key: jellyfinApiKey || null},
|
||||
seerr: {url: seerrUrl || null, api_key: seerrApiKey || null},
|
||||
}[name];
|
||||
|
||||
try {
|
||||
await api<SettingsRead>("/api/settings", {
|
||||
method: "PUT",
|
||||
headers: jsonHeaders,
|
||||
body: JSON.stringify({[name]: model}),
|
||||
});
|
||||
|
||||
if (name === "sonarr") setSonarrApiKey("");
|
||||
if (name === "prowlarr") setProwlarrApiKey("");
|
||||
if (name === "jellyfin") setJellyfinApiKey("");
|
||||
if (name === "seerr") setSeerrApiKey("");
|
||||
|
||||
const fresh = await refreshSettings();
|
||||
if (fresh[name].status === "unconfigured") {
|
||||
setMessage("Configuration enregistrée");
|
||||
} else {
|
||||
await testService(name);
|
||||
}
|
||||
} catch (error) {
|
||||
setMessage((error as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveQbittorrent(event: React.FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
setMessage("");
|
||||
try {
|
||||
await api<SettingsRead>("/api/settings", {
|
||||
method: "PUT",
|
||||
headers: jsonHeaders,
|
||||
body: JSON.stringify({
|
||||
qbittorrent: {
|
||||
url: qbitUrl || null,
|
||||
username: qbitUsername || null,
|
||||
password: qbitPassword || null,
|
||||
api_key: qbitApiKey || null,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
setQbitPassword("");
|
||||
setQbitApiKey("");
|
||||
const fresh = await refreshSettings();
|
||||
if (fresh.qbittorrent.status === "unconfigured") {
|
||||
setMessage("Configuration enregistrée");
|
||||
} else {
|
||||
await testService("qbittorrent");
|
||||
}
|
||||
} catch (error) {
|
||||
setMessage((error as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<section className="hero">
|
||||
<div>
|
||||
<h2>Connexions</h2>
|
||||
<p className="muted">
|
||||
Configurez vos services. Les secrets ne sont pas affichés et seront conservés si vous laissez
|
||||
les champs
|
||||
vides.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<div className="service-head">
|
||||
<h3>Radarr</h3>
|
||||
{settings && <ServiceStatusBadge {...settings.radarr}/>}
|
||||
</div>
|
||||
<p className="muted">Obligatoire pour le scan et la détection des films.</p>
|
||||
</div>
|
||||
<form onSubmit={saveRadarr} className="form-2">
|
||||
<label>
|
||||
URL Radarr
|
||||
<input
|
||||
type="url"
|
||||
required
|
||||
placeholder="http://radarr:7878"
|
||||
value={radarrUrl}
|
||||
onChange={(event) => setRadarrUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {radarrKeyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
required={!radarrKeyConfigured}
|
||||
placeholder={radarrKeyConfigured ? "Laisser vide pour conserver" : "Clé API Radarr"}
|
||||
value={radarrApiKey}
|
||||
onChange={(event) => setRadarrApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<div className="service-head">
|
||||
<h3>Sonarr</h3>
|
||||
{settings && <ServiceStatusBadge {...settings.sonarr}/>}
|
||||
</div>
|
||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||
</div>
|
||||
<form onSubmit={(e) => saveApiService("sonarr", e)} className="form-2">
|
||||
<label>
|
||||
URL Sonarr
|
||||
<input
|
||||
type="url"
|
||||
placeholder="http://sonarr:8989"
|
||||
value={sonarrUrl}
|
||||
onChange={(event) => setSonarrUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {sonarrKeyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
placeholder={sonarrKeyConfigured ? "Laisser vide pour conserver" : "Clé API Sonarr"}
|
||||
value={sonarrApiKey}
|
||||
onChange={(event) => setSonarrApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<div className="service-head">
|
||||
<h3>Prowlarr</h3>
|
||||
{settings && <ServiceStatusBadge {...settings.prowlarr}/>}
|
||||
</div>
|
||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||
</div>
|
||||
<form onSubmit={(e) => saveApiService("prowlarr", e)} className="form-2">
|
||||
<label>
|
||||
URL Prowlarr
|
||||
<input
|
||||
type="url"
|
||||
placeholder="http://prowlarr:9696"
|
||||
value={prowlarrUrl}
|
||||
onChange={(event) => setProwlarrUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {prowlarrKeyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
placeholder={prowlarrKeyConfigured ? "Laisser vide pour conserver" : "Clé API Prowlarr"}
|
||||
value={prowlarrApiKey}
|
||||
onChange={(event) => setProwlarrApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<div className="service-head">
|
||||
<h3>Jellyfin</h3>
|
||||
{settings && <ServiceStatusBadge {...settings.jellyfin}/>}
|
||||
</div>
|
||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||
</div>
|
||||
<form onSubmit={(e) => saveApiService("jellyfin", e)} className="form-2">
|
||||
<label>
|
||||
URL Jellyfin
|
||||
<input
|
||||
type="url"
|
||||
placeholder="http://jellyfin:8096"
|
||||
value={jellyfinUrl}
|
||||
onChange={(event) => setJellyfinUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {jellyfinKeyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
placeholder={jellyfinKeyConfigured ? "Laisser vide pour conserver" : "Clé API Jellyfin"}
|
||||
value={jellyfinApiKey}
|
||||
onChange={(event) => setJellyfinApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<div className="service-head">
|
||||
<h3>Overseerr</h3>
|
||||
{settings && <ServiceStatusBadge {...settings.seerr}/>}
|
||||
</div>
|
||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||
</div>
|
||||
<form onSubmit={(e) => saveApiService("seerr", e)} className="form-2">
|
||||
<label>
|
||||
URL Seerr
|
||||
<input
|
||||
type="url"
|
||||
placeholder="http://seerr:5055"
|
||||
value={seerrUrl}
|
||||
onChange={(event) => setSeerrUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {seerrKeyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
placeholder={seerrKeyConfigured ? "Laisser vide pour conserver" : "Clé API Seerr"}
|
||||
value={seerrApiKey}
|
||||
onChange={(event) => setSeerrApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<div className="service-head">
|
||||
<h3>qBittorrent</h3>
|
||||
{settings && <ServiceStatusBadge {...settings.qbittorrent}/>}
|
||||
</div>
|
||||
<p className="muted">Optionnel: nécessaire pour supprimer torrent + données après import validé.</p>
|
||||
</div>
|
||||
<form onSubmit={saveQbittorrent} className="form-4">
|
||||
<label>
|
||||
URL WebUI
|
||||
<input
|
||||
type="url"
|
||||
placeholder="http://qbittorrent:8080"
|
||||
value={qbitUrl}
|
||||
onChange={(event) => setQbitUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Utilisateur
|
||||
<input
|
||||
type="text"
|
||||
placeholder="admin"
|
||||
value={qbitUsername}
|
||||
onChange={(event) => setQbitUsername(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Mot de passe {qbitPasswordConfigured && <span>· configuré</span>}
|
||||
<input
|
||||
type="password"
|
||||
placeholder={qbitPasswordConfigured ? "Laisser vide pour conserver" : "Mot de passe"}
|
||||
value={qbitPassword}
|
||||
onChange={(event) => setQbitPassword(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {qbitApiKeyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
placeholder={
|
||||
qbitApiKeyConfigured ? "Laisser vide pour conserver" : "qbt_... (qBittorrent ≥ 5.2)"
|
||||
}
|
||||
value={qbitApiKey}
|
||||
onChange={(event) => setQbitApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h3>Aide</h3>
|
||||
<p className="muted">{serviceHelp}</p>
|
||||
</section>
|
||||
|
||||
{message && <div className="toast">{message}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -559,3 +559,143 @@ button.danger:hover:not(:disabled) {
|
||||
background: var(--surface-raised);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
/* --- Pastilles d'etat: une couleur par etat --- */
|
||||
.status.st-detected {
|
||||
color: #fbbf24;
|
||||
border-color: rgba(251, 191, 36, 0.45);
|
||||
}
|
||||
.status.st-queued {
|
||||
color: #93c5fd;
|
||||
border-color: rgba(147, 197, 253, 0.45);
|
||||
}
|
||||
.status.st-active {
|
||||
color: #93c5fd;
|
||||
border-color: rgba(147, 197, 253, 0.45);
|
||||
}
|
||||
.status.st-validating {
|
||||
color: #fbbf24;
|
||||
border-color: rgba(251, 191, 36, 0.45);
|
||||
}
|
||||
.status.st-completed {
|
||||
color: #4ade80;
|
||||
border-color: rgba(74, 222, 128, 0.45);
|
||||
}
|
||||
|
||||
/* --- Spinner (etats actifs) --- */
|
||||
.spinner {
|
||||
display: inline-block;
|
||||
width: 0.65rem;
|
||||
height: 0.65rem;
|
||||
margin-right: 0.35rem;
|
||||
vertical-align: -1px;
|
||||
border: 2px solid rgba(147, 197, 253, 0.35);
|
||||
border-top-color: #93c5fd;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* --- Terminal de conversion --- */
|
||||
.terminal-box {
|
||||
margin-top: 1.25rem;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.terminal-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
padding: 0.5rem 0.85rem;
|
||||
background: var(--surface-raised);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 0.78rem;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.dotpulse {
|
||||
width: 0.55rem;
|
||||
height: 0.55rem;
|
||||
border-radius: 50%;
|
||||
background: #4ade80;
|
||||
animation: pulse 1.2s ease-in-out infinite;
|
||||
}
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.25; }
|
||||
}
|
||||
.terminal {
|
||||
margin: 0;
|
||||
padding: 0.85rem;
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
background: #0a0a0b;
|
||||
color: #d4d4d8;
|
||||
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* --- Restes d'anciennes conversions --- */
|
||||
.workspace-warning {
|
||||
margin-top: 1.25rem;
|
||||
padding: 1rem 1.1rem;
|
||||
border: 1px solid rgba(251, 191, 36, 0.45);
|
||||
border-left: 3px solid #fbbf24;
|
||||
border-radius: 10px;
|
||||
background: var(--surface);
|
||||
}
|
||||
.workspace-warning p { margin: 0 0 0.5rem; font-size: 0.9rem; }
|
||||
.workspace-warning ul {
|
||||
margin: 0 0 0.9rem;
|
||||
padding-left: 1.2rem;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* --- Lignes de chemin copiables --- */
|
||||
.path-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
.path-row code { flex: 1; }
|
||||
button.copy { color: var(--text-muted); border-color: transparent; }
|
||||
button.copy:hover:not(:disabled) {
|
||||
color: var(--text);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
|
||||
/* --- Responsive --- */
|
||||
@media (max-width: 760px) {
|
||||
header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 1rem;
|
||||
}
|
||||
.header-actions { justify-content: space-between; }
|
||||
.pages { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
|
||||
.page-link, .tab { white-space: nowrap; }
|
||||
.stats { grid-template-columns: repeat(2, 1fr); }
|
||||
.activity { grid-template-columns: 1fr; }
|
||||
.settings { grid-template-columns: 1fr; }
|
||||
form, form.wide { grid-template-columns: 1fr; }
|
||||
form > button { width: 100%; }
|
||||
article { flex-direction: column; align-items: flex-start; }
|
||||
.row-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
|
||||
article code { font-size: 0.68rem; }
|
||||
.modal { width: calc(100vw - 1.5rem); max-height: 92vh; padding: 1.25rem; }
|
||||
.modal-head { flex-direction: column; gap: 0.5rem; }
|
||||
.modal-head .modal-close { align-self: flex-end; }
|
||||
.modal-grid { grid-template-columns: 1fr; }
|
||||
.modal-poster { max-width: 45%; }
|
||||
.modal-actions { flex-direction: column-reverse; align-items: stretch; }
|
||||
.bulk-bar { flex-wrap: wrap; gap: 0.75rem; }
|
||||
.tabs { overflow-x: auto; flex-wrap: nowrap; }
|
||||
.notifications { left: 0.5rem; right: 0.5rem; }
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
export type Movie = {
|
||||
id: number;
|
||||
title: string;
|
||||
year: number | null;
|
||||
path: string;
|
||||
size: number | null;
|
||||
status: string;
|
||||
created_at?: string | null;
|
||||
last_seen_at?: string | null;
|
||||
processed_at?: string | null;
|
||||
};
|
||||
|
||||
export type ServiceStatus = {
|
||||
status: "unconfigured" | "configured" | "tested" | "error";
|
||||
tested_version?: string | null;
|
||||
tested_at?: string | null;
|
||||
test_error?: string | null;
|
||||
};
|
||||
|
||||
export type ApiServiceSettingsRead = ServiceStatus & { url: string | null; api_key_configured: boolean };
|
||||
export type QbittorrentSettingsRead = ServiceStatus & {
|
||||
url: string | null;
|
||||
username: string | null;
|
||||
password_configured: boolean;
|
||||
api_key_configured: boolean;
|
||||
};
|
||||
|
||||
export type SettingsRead = {
|
||||
radarr: ApiServiceSettingsRead;
|
||||
sonarr: ApiServiceSettingsRead;
|
||||
prowlarr: ApiServiceSettingsRead;
|
||||
jellyfin: ApiServiceSettingsRead;
|
||||
seerr: ApiServiceSettingsRead;
|
||||
qbittorrent: QbittorrentSettingsRead;
|
||||
};
|
||||
Reference in new issue
Block a user