From 311ec74668e96f2709e0109547844004ebfcaccd Mon Sep 17 00:00:00 2001 From: Orionis312050 Date: Fri, 9 Oct 2026 21:25:46 +0000 Subject: [PATCH] :feature: Mise en place de l'interface et de la configuration --- .devcontainer/devcontainer.json | 10 + README.md | 13 + app/conf_store.py | 67 +++ app/main.py | 128 +++++- app/models.py | 1 + app/radarr.py | 5 +- app/schemas.py | 43 +- app/settings_store.py | 33 +- tests/test_api.py | 3 +- web/package-lock.json | 58 +++ web/package.json | 3 +- web/src/App.tsx | 288 ++++++------ web/src/components/StatusBadge.tsx | 10 + web/src/lib/api.ts | 25 ++ web/src/main.tsx | 5 +- web/src/pages/Dashboard.tsx | 166 +++++++ web/src/pages/FileDetails.tsx | 93 ++++ web/src/pages/Files.tsx | 143 ++++++ web/src/pages/Settings.tsx | 356 +++++++++++++++ web/src/style.css | 674 +++++++++++++++++++++++++++-- web/src/types.ts | 27 ++ 21 files changed, 1920 insertions(+), 231 deletions(-) mode change 100644 => 100755 .devcontainer/devcontainer.json create mode 100644 app/conf_store.py create mode 100644 web/src/components/StatusBadge.tsx create mode 100644 web/src/lib/api.ts create mode 100644 web/src/pages/Dashboard.tsx create mode 100644 web/src/pages/FileDetails.tsx create mode 100644 web/src/pages/Files.tsx create mode 100644 web/src/pages/Settings.tsx create mode 100644 web/src/types.ts diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json old mode 100644 new mode 100755 index ad4f8fd..34cc901 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,8 +17,18 @@ "containerEnv": { "UV_LINK_MODE": "copy" }, + "runArgs": ["--name", "mkvtool"], + "mounts": [ + "source=${localEnv:APPDATA}/JetBrains/WebStorm2026.2/aia-task-history,target=/.jbdevcontainer/config/JetBrains/WebStorm2026.2/aia-task-history,type=bind", + "source=${localEnv:APPDATA}/JetBrains/WebStorm2026.2/workspace,target=/.jbdevcontainer/config/JetBrains/WebStorm2026.2/workspace,type=bind", + + "source=${localEnv:USERPROFILE}/.cline,target=/home/vscode/.cline,type=bind" + ], "postCreateCommand": "uv sync && npm --prefix web install && python --version && node --version && ffmpeg -version | head -n 1 && command -v makemkvcon && uv --version", "customizations": { + "jetbrains": { + "plugins": ["com.intellij.ml.llm", "bot.cline"] + }, "vscode": { "extensions": [ "charliermarsh.ruff", diff --git a/README.md b/README.md index d883169..6f4434d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,19 @@ MKVTool sera un service web auto-hébergé consacré aux films. Il détecte les images ISO connues de Radarr, permet de lancer leur conversion manuellement, puis réimporte le MKV obtenu dans Radarr. +## Configuration (conf.json) + +La configuration des services (Radarr, Sonarr, Prowlarr, Jellyfin, Overseerr/Seerr, qBittorrent) est stockée dans `./config/conf.json`. + +- Le backend lit ce fichier. +- L'interface modifie ce fichier via l'API (écriture atomique côté backend). + +Radarr (rappel API): + +- Base: `/api/v3` +- Auth: header `X-Api-Key: ` +- Exemple: `GET {RADARR_URL}/api/v3/movie?includeMovieFile=true` + ## Faisabilité | Besoin | Faisable | Approche retenue | diff --git a/app/conf_store.py b/app/conf_store.py new file mode 100644 index 0000000..fa115d0 --- /dev/null +++ b/app/conf_store.py @@ -0,0 +1,67 @@ +import json +import os +import tempfile +from pathlib import Path + +from pydantic import BaseModel, Field + +from app.config import settings + + +class ApiServiceConfig(BaseModel): + url: str | None = None + api_key: str | None = None + + +class QbittorrentConfig(BaseModel): + url: str | None = None + username: str | None = None + password: str | None = None + + +class AppConfig(BaseModel): + radarr: ApiServiceConfig = Field(default_factory=ApiServiceConfig) + sonarr: ApiServiceConfig = Field(default_factory=ApiServiceConfig) + prowlarr: ApiServiceConfig = Field(default_factory=ApiServiceConfig) + jellyfin: ApiServiceConfig = Field(default_factory=ApiServiceConfig) + seerr: ApiServiceConfig = Field(default_factory=ApiServiceConfig) + qbittorrent: QbittorrentConfig = Field(default_factory=QbittorrentConfig) + + +def config_path() -> Path: + # Keep the name requested by the user: conf.json + return settings.config_dir / "conf.json" + + +def read_config() -> AppConfig: + path = config_path() + if not path.exists(): + return AppConfig() + raw = json.loads(path.read_text(encoding="utf-8")) + if not isinstance(raw, dict): + return AppConfig() + return AppConfig.model_validate(raw) + + +def write_config(config: AppConfig) -> None: + path = config_path() + path.parent.mkdir(parents=True, exist_ok=True) + + serialized = config.model_dump(mode="json", exclude_none=True) + + # Atomic write to avoid corrupting conf.json if the process is interrupted. + tmp_dir = str(path.parent) + with tempfile.NamedTemporaryFile( + mode="w", + encoding="utf-8", + dir=tmp_dir, + prefix=path.name + ".", + suffix=".tmp", + delete=False, + ) as handle: + json.dump(serialized, handle, indent=2, ensure_ascii=False) + handle.write("\n") + tmp_name = handle.name + + os.replace(tmp_name, path) + diff --git a/app/main.py b/app/main.py index 1b60dd8..a9e7df5 100644 --- a/app/main.py +++ b/app/main.py @@ -7,26 +7,43 @@ from typing import Annotated import httpx from fastapi import Depends, FastAPI, HTTPException from fastapi.middleware.cors import CORSMiddleware -from sqlalchemy import select +from sqlalchemy import inspect, select, text from sqlalchemy.orm import Session +from app.conf_store import read_config, write_config from app.database import Base, engine, get_db from app.models import IsoMovie from app.radarr import RadarrClient, movie_file_path from app.schemas import ( + ApiServiceSettingsRead, + QbittorrentSettingsRead, ConnectionResult, HealthRead, IsoMovieRead, RadarrSettingsRead, RadarrSettingsWrite, ScanResult, + SettingsRead, + SettingsWrite, ) -from app.settings_store import radarr_credentials, read_setting, write_setting +from app.settings_store import radarr_credentials @asynccontextmanager async def lifespan(_: FastAPI): Base.metadata.create_all(bind=engine) + + # Very small "migration" helper for dev: add new columns if the SQLite DB already exists. + # (SQLAlchemy create_all doesn't alter existing tables.) + try: + inspector = inspect(engine) + columns = {col["name"] for col in inspector.get_columns("iso_movies")} + if "processed_at" not in columns: + with engine.begin() as conn: + conn.execute(text("ALTER TABLE iso_movies ADD COLUMN processed_at DATETIME")) + except Exception: + # Don't fail app startup for a best-effort migration. + pass yield @@ -41,11 +58,32 @@ app.add_middleware( DbSession = Annotated[Session, Depends(get_db)] -def client_from_db(db: Session) -> RadarrClient: - try: - url, api_key = radarr_credentials(db) - except ValueError as error: - raise HTTPException(status_code=409, detail=str(error)) from error +def _api_service_read(url: str | None, api_key: str | None) -> ApiServiceSettingsRead: + return ApiServiceSettingsRead(url=url, api_key_configured=api_key is not None) + + +def _settings_read() -> SettingsRead: + cfg = read_config() + return SettingsRead( + radarr=_api_service_read(cfg.radarr.url, cfg.radarr.api_key), + sonarr=_api_service_read(cfg.sonarr.url, cfg.sonarr.api_key), + prowlarr=_api_service_read(cfg.prowlarr.url, cfg.prowlarr.api_key), + jellyfin=_api_service_read(cfg.jellyfin.url, cfg.jellyfin.api_key), + seerr=_api_service_read(cfg.seerr.url, cfg.seerr.api_key), + qbittorrent=QbittorrentSettingsRead( + url=cfg.qbittorrent.url, + username=cfg.qbittorrent.username, + password_configured=cfg.qbittorrent.password is not None, + ), + ) + + +def client_from_config() -> RadarrClient: + cfg = read_config() + url = (cfg.radarr.url or "").rstrip("/") + api_key = cfg.radarr.api_key + if not url or not api_key: + raise HTTPException(status_code=409, detail="La connexion Radarr n'est pas configurée") return RadarrClient(url, api_key) @@ -61,30 +99,63 @@ def health() -> HealthRead: @app.get("/api/settings/radarr", response_model=RadarrSettingsRead) -def get_radarr_settings(db: DbSession) -> RadarrSettingsRead: - return RadarrSettingsRead( - url=read_setting(db, "radarr_url"), - api_key_configured=read_setting(db, "radarr_api_key") is not None, - ) +def get_radarr_settings() -> RadarrSettingsRead: + cfg = read_config() + return RadarrSettingsRead(url=cfg.radarr.url, api_key_configured=cfg.radarr.api_key is not None) @app.put("/api/settings/radarr", response_model=RadarrSettingsRead) def put_radarr_settings( - payload: RadarrSettingsWrite, db: DbSession + payload: RadarrSettingsWrite, ) -> RadarrSettingsRead: + cfg = read_config() url = str(payload.url).rstrip("/") - write_setting(db, "radarr_url", url) + cfg.radarr.url = url if payload.api_key: - write_setting(db, "radarr_api_key", payload.api_key) - db.commit() - return RadarrSettingsRead( - url=url, api_key_configured=read_setting(db, "radarr_api_key") is not None - ) + cfg.radarr.api_key = payload.api_key + write_config(cfg) + return RadarrSettingsRead(url=url, api_key_configured=cfg.radarr.api_key is not None) + + +@app.get("/api/settings", response_model=SettingsRead) +def get_settings() -> SettingsRead: + return _settings_read() + + +@app.put("/api/settings", response_model=SettingsRead) +def put_settings(payload: SettingsWrite) -> SettingsRead: + cfg = read_config() + + def apply_service(target, patch): + if patch is None: + return + if patch.url is not None: + target.url = str(patch.url).rstrip("/") + if patch.api_key: + target.api_key = patch.api_key + + apply_service(cfg.radarr, payload.radarr) + apply_service(cfg.sonarr, payload.sonarr) + apply_service(cfg.prowlarr, payload.prowlarr) + apply_service(cfg.jellyfin, payload.jellyfin) + apply_service(cfg.seerr, payload.seerr) + + if payload.qbittorrent is not None: + qb = payload.qbittorrent + if qb.url is not None: + cfg.qbittorrent.url = str(qb.url).rstrip("/") + if qb.username: + cfg.qbittorrent.username = qb.username + if qb.password: + cfg.qbittorrent.password = qb.password + + write_config(cfg) + return _settings_read() @app.post("/api/settings/radarr/test", response_model=ConnectionResult) -async def test_radarr(db: DbSession) -> ConnectionResult: - client = client_from_db(db) +async def test_radarr() -> ConnectionResult: + client = client_from_config() try: status = await client.system_status() except (httpx.HTTPError, ValueError) as error: @@ -100,9 +171,22 @@ def list_movies(db: DbSession) -> list[IsoMovie]: return list(db.scalars(select(IsoMovie).order_by(IsoMovie.title)).all()) +@app.get("/api/files", response_model=list[IsoMovieRead]) +def list_files(db: DbSession) -> list[IsoMovie]: + return list_movies(db) + + +@app.get("/api/files/{file_id}", response_model=IsoMovieRead) +def get_file(file_id: int, db: DbSession) -> IsoMovie: + item = db.get(IsoMovie, file_id) + if item is None: + raise HTTPException(status_code=404, detail="Fichier introuvable") + return item + + @app.post("/api/scans", response_model=ScanResult) async def scan_radarr(db: DbSession) -> ScanResult: - client = client_from_db(db) + client = client_from_config() try: movies = await client.movies() except (httpx.HTTPError, ValueError) as error: diff --git a/app/models.py b/app/models.py index 89b4194..2c914cc 100644 --- a/app/models.py +++ b/app/models.py @@ -29,3 +29,4 @@ class IsoMovie(Base): DateTime(timezone=True), server_default=func.now() ) created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now()) + processed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True) diff --git a/app/radarr.py b/app/radarr.py index 0acbe7e..0ac97c4 100644 --- a/app/radarr.py +++ b/app/radarr.py @@ -21,7 +21,9 @@ class RadarrClient: return result async def movies(self) -> list[dict]: - result = await self._get("movie") + # Radarr does not always embed movieFile by default depending on client version. + # The documented way is to request it explicitly. + result = await self._get("movie?includeMovieFile=true") if not isinstance(result, list): raise ValueError("Réponse Radarr inattendue") return result @@ -37,4 +39,3 @@ def movie_file_path(movie: dict) -> str | None: if relative_path and movie_path: return str(PurePath(str(movie_path)) / str(relative_path)) return None - diff --git a/app/schemas.py b/app/schemas.py index e1f10ab..7d90d2e 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -13,6 +13,46 @@ class RadarrSettingsWrite(BaseModel): api_key: str | None = Field(default=None, min_length=1) +class ApiServiceSettingsRead(BaseModel): + url: str | None + api_key_configured: bool + + +class ApiServiceSettingsWrite(BaseModel): + url: HttpUrl | None = None + api_key: str | None = Field(default=None, min_length=1) + + +class QbittorrentSettingsRead(BaseModel): + url: str | None + username: str | None + password_configured: bool + + +class QbittorrentSettingsWrite(BaseModel): + url: HttpUrl | None = None + username: str | None = Field(default=None, min_length=1) + password: str | None = Field(default=None, min_length=1) + + +class SettingsRead(BaseModel): + radarr: ApiServiceSettingsRead + sonarr: ApiServiceSettingsRead + prowlarr: ApiServiceSettingsRead + jellyfin: ApiServiceSettingsRead + seerr: ApiServiceSettingsRead + qbittorrent: QbittorrentSettingsRead + + +class SettingsWrite(BaseModel): + radarr: ApiServiceSettingsWrite | None = None + sonarr: ApiServiceSettingsWrite | None = None + prowlarr: ApiServiceSettingsWrite | None = None + jellyfin: ApiServiceSettingsWrite | None = None + seerr: ApiServiceSettingsWrite | None = None + qbittorrent: QbittorrentSettingsWrite | None = None + + class ConnectionResult(BaseModel): success: bool version: str | None = None @@ -31,6 +71,8 @@ class IsoMovieRead(BaseModel): size: int | None status: str last_seen_at: datetime + created_at: datetime | None = None + processed_at: datetime | None = None class ScanResult(BaseModel): @@ -45,4 +87,3 @@ class HealthRead(BaseModel): database: str makemkv_available: bool makemkv_version: str | None - diff --git a/app/settings_store.py b/app/settings_store.py index c2bc70e..70ffdee 100644 --- a/app/settings_store.py +++ b/app/settings_store.py @@ -1,25 +1,16 @@ -from sqlalchemy.orm import Session +"""Legacy module. -from app.models import ApplicationSetting +Historically, MKVTool stored connection settings inside SQLite. +The project now externalises its configuration into ./config/conf.json. + +This module is kept temporarily because some imports may still reference it. +""" + +from app.conf_store import read_config -def read_setting(db: Session, key: str) -> str | None: - item = db.get(ApplicationSetting, key) - return item.value if item else None - - -def write_setting(db: Session, key: str, value: str) -> None: - item = db.get(ApplicationSetting, key) - if item: - item.value = value - else: - db.add(ApplicationSetting(key=key, value=value)) - - -def radarr_credentials(db: Session) -> tuple[str, str]: - url = read_setting(db, "radarr_url") - api_key = read_setting(db, "radarr_api_key") - if not url or not api_key: +def radarr_credentials(_: object | None = None) -> tuple[str, str]: + cfg = read_config() + if not cfg.radarr.url or not cfg.radarr.api_key: raise ValueError("La connexion Radarr n'est pas configurée") - return url.rstrip("/"), api_key - + return cfg.radarr.url.rstrip("/"), cfg.radarr.api_key diff --git a/tests/test_api.py b/tests/test_api.py index 7dd4786..25f1d0d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -34,7 +34,7 @@ def test_radarr_connection() -> None: @respx.mock def test_scan_only_imports_iso_files() -> None: - respx.get("http://radarr:7878/api/v3/movie").mock( + respx.get("http://radarr:7878/api/v3/movie?includeMovieFile=true").mock( return_value=Response( 200, json=[ @@ -70,4 +70,3 @@ def test_scan_only_imports_iso_files() -> None: assert scan.status_code == 200 assert scan.json()["iso_files"] == 1 assert [movie["title"] for movie in movies.json()] == ["ISO Movie"] - diff --git a/web/package-lock.json b/web/package-lock.json index 5642a53..2bdd5f4 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -11,6 +11,7 @@ "@vitejs/plugin-react": "latest", "react": "latest", "react-dom": "latest", + "react-router-dom": "latest", "typescript": "latest", "vite": "latest" }, @@ -1277,6 +1278,19 @@ "dev": true, "license": "MIT" }, + "node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2350,6 +2364,44 @@ "react": "^19.3.0" } }, + "node_modules/react-router": { + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.4.tgz", + "integrity": "sha512-PUPQcMhMGRAslLcvtlPz/kmzBEWPhLdgLFrL7pLNepBL6dX0lWj4WD2cUYVgYCuT3jxvghYFg81cDTj44DhetQ==", + "license": "MIT", + "dependencies": { + "cookie": "^1.0.1", + "set-cookie-parser": "^2.6.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, + "node_modules/react-router-dom": { + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.4.tgz", + "integrity": "sha512-yrfmJHIpDG7taCpqKjT1G5B6q3O2K+RN8/fgNf0lTjCwiPbQ0ei6vXX9ZjQR+7ld8Tr7Z5xmyMnZ8YJrphWQUw==", + "license": "MIT", + "dependencies": { + "react-router": "7.18.4" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + } + }, "node_modules/rolldown": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.13.tgz", @@ -2399,6 +2451,12 @@ "semver": "bin/semver.js" } }, + "node_modules/set-cookie-parser": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz", + "integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==", + "license": "MIT" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", diff --git a/web/package.json b/web/package.json index bc632a5..7eb9d5e 100644 --- a/web/package.json +++ b/web/package.json @@ -13,7 +13,8 @@ "vite": "latest", "typescript": "latest", "react": "latest", - "react-dom": "latest" + "react-dom": "latest", + "react-router-dom": "latest" }, "devDependencies": { "@types/react": "latest", diff --git a/web/src/App.tsx b/web/src/App.tsx index 72b5662..c3bf0f7 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,159 +1,153 @@ -import { FormEvent, useCallback, useEffect, useState } from "react"; +import {useMemo, useState} from "react"; -type Movie = { - id: number; - title: string; - year: number | null; - path: string; - size: number | null; - status: string; -}; +import Dashboard from "./pages/Dashboard"; +import Files from "./pages/Files"; +import FileDetails from "./pages/FileDetails"; +import Settings from "./pages/Settings"; -type RadarrSettings = { url: string | null; api_key_configured: boolean }; +type Route = + | { name: "dashboard" } + | { name: "files" } + | { name: "file"; id: number } + | { name: "settings" }; -const jsonHeaders = { "Content-Type": "application/json" }; - -async function api(path: string, init?: RequestInit): Promise { - 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(); +function GearIcon({className}: { className?: string }) { + return ( + + + + + ); } -function readableSize(size: number | null): string { - if (size === null) return "—"; - return `${(size / 1024 ** 3).toFixed(1)} Go`; +function HomeIcon({className}: { className?: string }) { + return ( + + + + + ); +} + +function FolderIcon({className}: { className?: string }) { + return ( + + + + ); } export default function App() { - const [movies, setMovies] = useState([]); - const [url, setUrl] = useState(""); - const [apiKey, setApiKey] = useState(""); - const [keyConfigured, setKeyConfigured] = useState(false); - const [message, setMessage] = useState(""); - const [busy, setBusy] = useState(false); + const [route, setRoute] = useState({name: "dashboard"}); - const loadMovies = useCallback(async () => { - setMovies(await api("/api/movies")); - }, []); + const header = useMemo(() => { + switch (route.name) { + case "dashboard": + return {eyebrow: "DASHBOARD", title: "MKVTool"}; + case "files": + return {eyebrow: "FICHIERS", title: "Gestion des fichiers"}; + case "file": + return {eyebrow: "FICHIERS", title: "Détails du fichier"}; + case "settings": + return {eyebrow: "CONFIGURATION", title: "Configuration"}; + } + }, [route.name]); - useEffect(() => { - Promise.all([api("/api/settings/radarr"), loadMovies()]) - .then(([settings]) => { - setUrl(settings.url ?? ""); - setKeyConfigured(settings.api_key_configured); - }) - .catch((error: Error) => setMessage(error.message)); - }, [loadMovies]); - - async function saveSettings(event: FormEvent) { - event.preventDefault(); - setBusy(true); - setMessage(""); - try { - const settings = await api("/api/settings/radarr", { - method: "PUT", - headers: jsonHeaders, - body: JSON.stringify({ url, api_key: apiKey || null }), - }); - setKeyConfigured(settings.api_key_configured); - setApiKey(""); - const result = await api<{ message: string }>("/api/settings/radarr/test", { - method: "POST", - }); - setMessage(result.message); - } catch (error) { - setMessage((error as Error).message); - } finally { - setBusy(false); - } - } - - async function scan() { - setBusy(true); - setMessage(""); - try { - const result = await api<{ iso_files: number; scanned_movies: number }>("/api/scans", { - method: "POST", - }); - await loadMovies(); - setMessage(`${result.iso_files} ISO trouvée(s) sur ${result.scanned_movies} film(s)`); - } catch (error) { - setMessage((error as Error).message); - } finally { - setBusy(false); - } - } - - return ( -
-
-
-

RADARR · ISO → MKV

-

MKVTool

-
- -
- -
-
-

Connexion Radarr

-

L’URL doit être accessible depuis le conteneur MKVTool.

-
-
- - - -
-
- - {message &&

{message}

} - -
-
-
-

INVENTAIRE

-

Films ISO

-
- {movies.length} détecté(s) -
- {movies.length === 0 ? ( -
Configurez Radarr puis lancez votre premier scan.
- ) : ( -
- {movies.map((movie) => ( -
-
-

{movie.title}

-

{movie.year ?? "Année inconnue"} · {readableSize(movie.size)}

- {movie.path} + return ( +
+
- ))} -
- )} -
-
- ); + + + +
+
v0.1
+
Premium dark UI
+
+ + +
+
+
+
{header.eyebrow}
+

{header.title}

+
+
+ + {route.name === "dashboard" && ( + setRoute({name: "file", id})} + onOpenFiles={() => setRoute({name: "files"})} + onOpenSettings={() => setRoute({name: "settings"})} + /> + )} + {route.name === "files" && setRoute({name: "file", id})}/>} + {route.name === "file" && ( + setRoute({name: "files"})}/> + )} + {route.name === "settings" && } +
+ + ); } diff --git a/web/src/components/StatusBadge.tsx b/web/src/components/StatusBadge.tsx new file mode 100644 index 0000000..9a86f7e --- /dev/null +++ b/web/src/components/StatusBadge.tsx @@ -0,0 +1,10 @@ +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 {status}; +} diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts new file mode 100644 index 0000000..dba40d3 --- /dev/null +++ b/web/src/lib/api.ts @@ -0,0 +1,25 @@ +export const jsonHeaders = {"Content-Type": "application/json"}; + +export async function api(path: string, init?: RequestInit): Promise { + 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); +} diff --git a/web/src/main.tsx b/web/src/main.tsx index 10b5951..e70d237 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -1,10 +1,13 @@ import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; +import { BrowserRouter } from "react-router-dom"; import App from "./App"; import "./style.css"; createRoot(document.getElementById("root")!).render( - + + + , ); diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx new file mode 100644 index 0000000..24a9bd2 --- /dev/null +++ b/web/src/pages/Dashboard.tsx @@ -0,0 +1,166 @@ +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([]); + const [settings, setSettings] = useState(null); + const [busy, setBusy] = useState(false); + const [message, setMessage] = useState(""); + + useEffect(() => { + Promise.all([api("/api/movies"), api("/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("/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 ( +
+
+
+
+

Dashboard

+

+ Vue rapide sur l’état de vos fichiers. Pour afficher “tout juste traités”, le backend doit + renseigner + processed_at à la fin du workflow. +

+
+
+ + {!canScan && ( + + )} +
+
+ +
+
+
Total
+
{stats.total}
+
+
+
Non traités
+
{stats.unprocessed}
+
+
+
En cours
+
{stats.processing.length}
+
+
+
Traités
+
{stats.processed.length}
+
+
+
+ + {message &&
{message}
} + +
+
+
+

En cours de traitement

+ +
+ {stats.processing.length === 0 ? ( +
Aucun traitement en cours.
+ ) : ( +
+ {stats.processing.slice(0, 6).map((m) => ( + + ))} +
+ )} +
+ +
+
+

Tout juste traités

+ +
+ {stats.recentlyProcessed.length === 0 ? ( +
+ Aucun élément récent (champ processed_at non renseigné). +
+ ) : ( +
+ {stats.recentlyProcessed.map((m) => ( + + ))} +
+ )} +
+
+
+ ); +} diff --git a/web/src/pages/FileDetails.tsx b/web/src/pages/FileDetails.tsx new file mode 100644 index 0000000..11a485c --- /dev/null +++ b/web/src/pages/FileDetails.tsx @@ -0,0 +1,93 @@ +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(null); + const [error, setError] = useState(""); + + useEffect(() => { + setError(""); + setItem(null); + api(`/api/files/${id}`) + .then(setItem) + .catch((e: Error) => setError(e.message)); + }, [id]); + + return ( +
+
+
+
+

Détails du fichier

+

Informations liées au fichier détecté et à son état de traitement.

+
+
+ +
+
+
+ + {error &&
{error}
} + + {!item ? ( +
+
+
+ ) : ( + <> +
+
+
+

{item.title}

+

{item.year ?? "Année inconnue"}

+
+ +
+ +
+
+
Chemin
+
+ {item.path} +
+
+
+
Taille
+
{readableSize(item.size)}
+
+
+
Détecté
+
{formatDateTime(item.created_at)}
+
+
+
Dernière présence
+
{formatDateTime(item.last_seen_at)}
+
+
+
Fin de traitement
+
{formatDateTime(item.processed_at)}
+
+
+
+ +
+

Actions (à venir)

+

+ Ici on pourra ajouter: relancer un traitement, ouvrir le dossier, suppression, etc. +

+
+ + )} +
+ ); +} diff --git a/web/src/pages/Files.tsx b/web/src/pages/Files.tsx new file mode 100644 index 0000000..c9ccad7 --- /dev/null +++ b/web/src/pages/Files.tsx @@ -0,0 +1,143 @@ +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([]); + const [filter, setFilter] = useState("all"); + const [query, setQuery] = useState(""); + const [error, setError] = useState(""); + + useEffect(() => { + api("/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 ( +
+
+
+
+

Gestion des fichiers

+

Filtrez l’inventaire et ouvrez un fichier pour consulter le détail.

+
+
+
+ + + + +
+ setQuery(e.target.value)} + /> +
+
+
+ + {error &&
{error}
} + +
+
+
+
Titre
+
Fichier
+
Taille
+
Statut
+
+ + {groups.base.length === 0 ? ( +
Aucun résultat.
+ ) : ( + groups.base.map((movie) => ( + + )) + )} +
+
+
+ ); +} diff --git a/web/src/pages/Settings.tsx b/web/src/pages/Settings.tsx new file mode 100644 index 0000000..f7829ee --- /dev/null +++ b/web/src/pages/Settings.tsx @@ -0,0 +1,356 @@ +import {useCallback, useEffect, useMemo, useState} from "react"; +import type React from "react"; + +import {api, jsonHeaders} from "../lib/api"; +import type {SettingsRead} from "../types"; + +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 [message, setMessage] = useState(""); + const [busy, setBusy] = useState(false); + + 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); + }, []); + + const refreshSettings = useCallback(async () => { + hydrateSettings(await api("/api/settings")); + }, [hydrateSettings]); + + useEffect(() => { + refreshSettings().catch((error: Error) => setMessage(error.message)); + }, [refreshSettings]); + + async function saveRadarr(event: React.FormEvent) { + event.preventDefault(); + setBusy(true); + setMessage(""); + try { + await api("/api/settings", { + method: "PUT", + headers: jsonHeaders, + body: JSON.stringify({ + radarr: { + url: radarrUrl || null, + api_key: radarrApiKey || null, + }, + }), + }); + setRadarrApiKey(""); + await refreshSettings(); + const result = await api<{ message: string }>("/api/settings/radarr/test", {method: "POST"}); + setMessage(result.message); + } catch (error) { + setMessage((error as Error).message); + } finally { + setBusy(false); + } + } + + async function saveApiService( + name: "sonarr" | "prowlarr" | "jellyfin" | "seerr", + event: React.FormEvent, + ) { + 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("/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(""); + + await refreshSettings(); + setMessage("Configuration enregistrée"); + } catch (error) { + setMessage((error as Error).message); + } finally { + setBusy(false); + } + } + + async function saveQbittorrent(event: React.FormEvent) { + event.preventDefault(); + setBusy(true); + setMessage(""); + try { + await api("/api/settings", { + method: "PUT", + headers: jsonHeaders, + body: JSON.stringify({ + qbittorrent: { + url: qbitUrl || null, + username: qbitUsername || null, + password: qbitPassword || null, + }, + }), + }); + + setQbitPassword(""); + await refreshSettings(); + setMessage("Configuration enregistrée"); + } catch (error) { + setMessage((error as Error).message); + } finally { + setBusy(false); + } + } + + return ( +
+
+
+

Connexions

+

+ Configurez vos services. Les secrets ne sont pas affichés et seront conservés si vous laissez + les champs + vides. +

+
+
+ +
+
+

Radarr

+

Obligatoire pour le scan et la détection des films.

+
+
+ + + +
+
+ +
+
+

Sonarr

+

Optionnel (hors périmètre MVP), mais stocké dans conf.json.

+
+
saveApiService("sonarr", e)} className="form-2"> + + + +
+
+ +
+
+

Prowlarr

+

Optionnel (hors périmètre MVP), mais stocké dans conf.json.

+
+
saveApiService("prowlarr", e)} className="form-2"> + + + +
+
+ +
+
+

Jellyfin

+

Optionnel (hors périmètre MVP), mais stocké dans conf.json.

+
+
saveApiService("jellyfin", e)} className="form-2"> + + + +
+
+ +
+
+

Overseerr

+

Optionnel (hors périmètre MVP), mais stocké dans conf.json.

+
+
saveApiService("seerr", e)} className="form-2"> + + + +
+
+ +
+
+

qBittorrent

+

Optionnel: nécessaire pour supprimer torrent + données après import validé.

+
+
+ + + + +
+
+ +
+

Aide

+

{serviceHelp}

+
+ + {message &&
{message}
} +
+ ); +} diff --git a/web/src/style.css b/web/src/style.css index aad36ea..5feaacb 100644 --- a/web/src/style.css +++ b/web/src/style.css @@ -1,42 +1,648 @@ +/* Premium dark theme */ :root { - font-family: Inter, ui-sans-serif, system-ui, sans-serif; - color: #e8ebe9; - background: #0b0f0e; - font-synthesis: none; + font-family: Inter, ui-sans-serif, system-ui, sans-serif; + font-synthesis: none; + + --bg: #070a0f; + --panel: #0d1220; + --panel-2: #0b1020; + --border: rgba(255, 255, 255, 0.08); + --border-2: rgba(255, 255, 255, 0.12); + + --text: #edf1ff; + --muted: rgba(237, 241, 255, 0.68); + + --accent: #7c5cff; /* violet */ + --accent-2: #2ee59d; /* mint */ + --danger: #ff4d6d; + + --shadow: 0 18px 50px rgba(0, 0, 0, 0.55); } -* { box-sizing: border-box; } -body { margin: 0; min-width: 320px; min-height: 100vh; } -button, input { font: inherit; } +* { + box-sizing: border-box; +} + +body { + margin: 0; + min-width: 320px; + min-height: 100vh; + color: var(--text); + background: radial-gradient(1200px 600px at 20% 0%, rgba(124, 92, 255, 0.16), transparent 60%), + radial-gradient(900px 500px at 90% 10%, rgba(46, 229, 157, 0.12), transparent 55%), + var(--bg); +} + +button, input { + font: inherit; +} + button { - border: 0; border-radius: 10px; padding: 0.75rem 1rem; color: #07110d; - background: #62e6a7; font-weight: 750; cursor: pointer; + border: 1px solid var(--border); + border-radius: 12px; + padding: 0.7rem 1rem; + color: var(--text); + background: linear-gradient(180deg, rgba(124, 92, 255, 0.95), rgba(124, 92, 255, 0.78)); + box-shadow: 0 10px 22px rgba(124, 92, 255, 0.18); + font-weight: 750; + cursor: pointer; + transition: transform 120ms ease, filter 120ms ease, background 120ms ease; +} + +button:hover:not(:disabled) { + transform: translateY(-1px); + filter: brightness(1.02); +} + +button:disabled { + cursor: not-allowed; + opacity: 0.45; +} + + +/* Layout shell */ +.app-shell { + display: grid; + grid-template-columns: 280px 1fr; + min-height: 100vh; +} + +.content { + padding: 2rem; +} + +.topbar { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 1rem; + margin-bottom: 1.5rem; +} + +.page-title { + margin: 0; + font-size: clamp(1.6rem, 2.8vw, 2.2rem); + letter-spacing: -0.04em; +} + +header, .section-title { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; +} + +h1, h2, h3, p { + margin-top: 0; +} + + +.eyebrow { + color: rgba(237, 241, 255, 0.62); + font-size: 0.75rem; + font-weight: 800; + letter-spacing: 0.14em; + text-transform: uppercase; +} + + +/* Navigation */ +.nav { + position: sticky; + top: 0; + align-self: start; + height: 100vh; + padding: 1.6rem 1.2rem; + border-right: 1px solid var(--border); + background: linear-gradient(180deg, rgba(13, 18, 32, 0.92), rgba(13, 18, 32, 0.72)); + backdrop-filter: blur(10px); +} + +.nav__brand { + display: flex; + gap: 0.75rem; + align-items: center; + padding-bottom: 1.2rem; + margin-bottom: 1.2rem; + border-bottom: 1px solid var(--border); +} + +.nav__logo { + width: 42px; + height: 42px; + border-radius: 14px; + display: grid; + place-items: center; + font-weight: 900; + background: radial-gradient(circle at 30% 30%, rgba(124, 92, 255, 0.9), rgba(46, 229, 157, 0.35)); + box-shadow: 0 18px 34px rgba(0, 0, 0, 0.45); +} + +.nav__title { + font-weight: 850; + letter-spacing: -0.02em; +} + +.nav__subtitle { + font-size: 0.85rem; + color: var(--muted); +} + +.nav__items { + display: grid; + gap: 0.5rem; +} + +.nav__item { + display: flex; + align-items: center; + gap: 0.7rem; + text-align: left; + width: 100%; + padding: 0.8rem 0.9rem; + border-radius: 12px; + border: 1px solid transparent; + background: transparent; + color: var(--text); + box-shadow: none; + text-decoration: none; +} + +.nav__item:hover:not(:disabled) { + transform: none; + background: rgba(255, 255, 255, 0.04); + border-color: var(--border); +} + +.nav__item--active { + background: rgba(124, 92, 255, 0.14); + border-color: rgba(124, 92, 255, 0.35); +} + +.nav__icon { + width: 18px; + height: 18px; + opacity: 0.9; +} + +.nav__footer { + margin-top: auto; + padding-top: 1.2rem; + border-top: 1px solid var(--border); + display: grid; + gap: 0.5rem; +} + +form { + display: grid; + align-items: end; + gap: 0.75rem; +} + +form.form-2 { + grid-template-columns: 1fr 1fr auto; +} + +form.form-3 { + grid-template-columns: 1fr 1fr 1fr auto; +} + +form.form-1 { + grid-template-columns: 1fr auto; +} + +label { + display: grid; + gap: 0.4rem; + color: rgba(237, 241, 255, 0.84); + font-size: 0.85rem; +} + +label span { + color: rgba(46, 229, 157, 0.9); +} + +input { + width: 100%; + padding: 0.75rem; + color: var(--text); + border: 1px solid var(--border); + border-radius: 12px; + background: rgba(7, 10, 15, 0.75); + outline: none; +} + +input:focus { + border-color: rgba(124, 92, 255, 0.65); + box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18); +} + +.muted { + color: var(--muted); + font-size: 0.92rem; +} + + +.toast { + position: sticky; + top: 1rem; + z-index: 10; + margin-bottom: 1rem; + padding: 0.9rem 1rem; + border: 1px solid var(--border); + border-radius: 14px; + background: rgba(13, 18, 32, 0.9); + box-shadow: var(--shadow); +} + +.toast--danger { + border-color: rgba(255, 77, 109, 0.35); + background: rgba(255, 77, 109, 0.08); +} + + +.page { + display: grid; + gap: 1rem; +} + +.hero { + padding: 1.4rem; + border-radius: 18px; + border: 1px solid var(--border); + background: linear-gradient(180deg, rgba(13, 18, 32, 0.92), rgba(13, 18, 32, 0.72)); + box-shadow: var(--shadow); +} + +.hero--compact { + padding: 1rem 1.2rem; +} + +.hero__row { + display: flex; + justify-content: space-between; + gap: 1rem; + align-items: flex-start; +} + +.hero__actions { + display: flex; + gap: 0.75rem; + align-items: center; + flex-wrap: wrap; + justify-content: flex-end; +} + +.kpis { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 0.75rem; + margin-top: 1rem; +} + +.kpi { + padding: 0.9rem 1rem; + border-radius: 16px; + border: 1px solid var(--border); + background: rgba(7, 10, 15, 0.35); +} + +.kpi__label { + color: var(--muted); + font-size: 0.85rem; +} + +.kpi__value { + font-size: 1.35rem; + font-weight: 850; + letter-spacing: -0.02em; + margin-top: 0.2rem; +} + +.card { + padding: 1.2rem; + border-radius: 18px; + border: 1px solid var(--border); + background: rgba(13, 18, 32, 0.84); + box-shadow: var(--shadow); +} + +.card__head { + display: flex; + justify-content: space-between; + gap: 1rem; + align-items: center; + margin-bottom: 0.75rem; +} + +.grid-2 { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 1rem; +} + +.btn { + border: 1px solid var(--border); +} + +.btn--ghost { + background: rgba(255, 255, 255, 0.04); + box-shadow: none; +} + +.btn--ghost:hover:not(:disabled) { + background: rgba(255, 255, 255, 0.06); +} + +.chip { + display: inline-flex; + align-items: center; + padding: 0.25rem 0.6rem; + border-radius: 999px; + border: 1px solid var(--border); + font-size: 0.75rem; + color: var(--muted); +} + +.chip--subtle { + background: rgba(255, 255, 255, 0.03); +} + +.section-title > span { + color: #91a199; +} + + +.empty { + padding: 2rem 1rem; + text-align: center; + color: var(--muted); + border: 1px dashed var(--border-2); + border-radius: 16px; + background: rgba(7, 10, 15, 0.2); +} + +.list { + display: grid; + gap: 0.5rem; +} + +.list__row { + display: flex; + justify-content: space-between; + align-items: center; + gap: 1rem; + width: 100%; + padding: 0.85rem 0.9rem; + border-radius: 14px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid var(--border); + box-shadow: none; +} + +.list__row:hover:not(:disabled) { + transform: none; + background: rgba(255, 255, 255, 0.045); +} + +.list__title { + font-weight: 800; + letter-spacing: -0.01em; +} + +.table { + display: grid; + gap: 0.35rem; +} + +.table__head { + display: grid; + grid-template-columns: 1.2fr 1.7fr 0.6fr 0.6fr; + gap: 0.75rem; + color: var(--muted); + font-size: 0.8rem; + padding: 0.2rem 0.4rem; +} + +.table__row { + display: grid; + grid-template-columns: 1.2fr 1.7fr 0.6fr 0.6fr; + gap: 0.75rem; + width: 100%; + text-align: left; + padding: 0.9rem 0.9rem; + border-radius: 16px; + border: 1px solid var(--border); + background: rgba(255, 255, 255, 0.03); + box-shadow: none; +} + +.table__row:hover:not(:disabled) { + transform: none; + background: rgba(255, 255, 255, 0.045); +} + +.table__title { + font-weight: 850; + letter-spacing: -0.01em; +} + +.table__cell { + display: grid; + gap: 0.2rem; + align-content: start; +} + +.search { + min-width: 260px; +} + +.segmented { + display: inline-flex; + border: 1px solid var(--border); + border-radius: 14px; + padding: 0.25rem; + background: rgba(7, 10, 15, 0.35); + gap: 0.25rem; +} + +.segmented__btn { + padding: 0.45rem 0.65rem; + border-radius: 12px; + background: transparent; + border: 1px solid transparent; + box-shadow: none; + color: var(--muted); +} + +.segmented__btn:hover:not(:disabled) { + transform: none; + background: rgba(255, 255, 255, 0.04); +} + +.segmented__btn--active { + color: var(--text); + border-color: rgba(124, 92, 255, 0.35); + background: rgba(124, 92, 255, 0.14); +} + +.segmented__count { + margin-left: 0.35rem; + display: inline-flex; + align-items: center; + height: 18px; + padding: 0 0.45rem; + border-radius: 999px; + background: rgba(255, 255, 255, 0.06); + border: 1px solid var(--border); + color: var(--text); + font-size: 0.75rem; +} + +.badge { + display: inline-flex; + align-items: center; + height: 22px; + padding: 0 0.55rem; + border-radius: 999px; + font-size: 0.75rem; + font-weight: 800; + border: 1px solid var(--border); + background: rgba(255, 255, 255, 0.03); +} + +.badge--neutral { + color: var(--muted); +} + +.badge--warn { + color: rgba(255, 214, 102, 0.92); + border-color: rgba(255, 214, 102, 0.25); + background: rgba(255, 214, 102, 0.08); +} + +.badge--info { + color: rgba(124, 92, 255, 0.95); + border-color: rgba(124, 92, 255, 0.35); + background: rgba(124, 92, 255, 0.12); +} + +.badge--success { + color: rgba(46, 229, 157, 0.95); + border-color: rgba(46, 229, 157, 0.25); + background: rgba(46, 229, 157, 0.10); +} + +.detail-head { + display: flex; + justify-content: space-between; + gap: 1rem; + align-items: center; +} + +.detail-grid { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 0.75rem; + margin-top: 1rem; +} + +.kv { + padding: 0.9rem; + border-radius: 16px; + border: 1px solid var(--border); + background: rgba(7, 10, 15, 0.25); +} + +.kv__k { + color: var(--muted); + font-size: 0.8rem; + margin-bottom: 0.35rem; +} + +.kv__v { + font-weight: 650; +} + +.skeleton { + height: 120px; + border-radius: 16px; + background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)); + background-size: 200% 100%; + animation: shimmer 1.2s infinite linear; +} + +@keyframes shimmer { + 0% { + background-position: 200% 0; + } + 100% { + background-position: -200% 0; + } +} + +.movie-list { + display: grid; + gap: 0.75rem; +} + +article { + display: flex; + justify-content: space-between; + gap: 1rem; + padding: 1.25rem; + border: 1px solid #26332e; + border-radius: 13px; + background: #111816; +} + +article h3 { + margin-bottom: 0.3rem; +} + +article p { + margin-bottom: 0.6rem; +} + +code { + color: rgba(237, 241, 255, 0.75); + overflow-wrap: anywhere; } -button:disabled { cursor: not-allowed; opacity: 0.45; } -main { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0; } -header, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; } -h1, h2, h3, p { margin-top: 0; } -h1 { margin-bottom: 0; font-size: clamp(2.5rem, 8vw, 5rem); letter-spacing: -0.07em; } -.eyebrow { color: #62e6a7; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; } -.panel { margin: 3rem 0 1rem; padding: 1.5rem; border: 1px solid #26332e; border-radius: 16px; background: #111816; } -.settings { display: grid; grid-template-columns: 1fr 2fr; gap: 2rem; } -.settings p, article p { color: #91a199; } -form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 0.75rem; } -label { display: grid; gap: 0.4rem; color: #b7c1bc; font-size: 0.85rem; } -label span { color: #62e6a7; } -input { width: 100%; padding: 0.75rem; color: #eef5f1; border: 1px solid #35463f; border-radius: 9px; background: #090e0c; } -.message { padding: 0.8rem 1rem; border-left: 3px solid #62e6a7; background: #111816; } -.library { margin-top: 3rem; } -.section-title > span { color: #91a199; } -.empty { padding: 4rem 1rem; text-align: center; color: #91a199; border: 1px dashed #35463f; border-radius: 16px; } -.movie-list { display: grid; gap: 0.75rem; } -article { display: flex; justify-content: space-between; gap: 1rem; padding: 1.25rem; border: 1px solid #26332e; border-radius: 13px; background: #111816; } -article h3 { margin-bottom: 0.3rem; } -article p { margin-bottom: 0.6rem; } -code { color: #a9b6b0; overflow-wrap: anywhere; } -.status { align-self: start; padding: 0.35rem 0.6rem; color: #62e6a7; background: #183328; border-radius: 999px; font-size: 0.75rem; } @media (max-width: 800px) { - .settings, form { grid-template-columns: 1fr; } - header { align-items: flex-end; } + .app-shell { + grid-template-columns: 1fr; + } + + .nav { + position: relative; + height: auto; + border-right: 0; + border-bottom: 1px solid var(--border); + } + + .grid-2 { + grid-template-columns: 1fr; + } + + .kpis { + grid-template-columns: 1fr 1fr; + } + + .hero__row { + flex-direction: column; + align-items: stretch; + } + + .search { + min-width: 100%; + } + + form.form-2, form.form-3, form.form-1 { + grid-template-columns: 1fr; + } + + .detail-grid { + grid-template-columns: 1fr; + } } diff --git a/web/src/types.ts b/web/src/types.ts new file mode 100644 index 0000000..aa15dc0 --- /dev/null +++ b/web/src/types.ts @@ -0,0 +1,27 @@ +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 ApiServiceSettingsRead = { url: string | null; api_key_configured: boolean }; +export type QbittorrentSettingsRead = { + url: string | null; + username: string | null; + password_configured: boolean; +}; + +export type SettingsRead = { + radarr: ApiServiceSettingsRead; + sonarr: ApiServiceSettingsRead; + prowlarr: ApiServiceSettingsRead; + jellyfin: ApiServiceSettingsRead; + seerr: ApiServiceSettingsRead; + qbittorrent: QbittorrentSettingsRead; +};