:feature: Mise en place de l'interface et de la configuration
This commit is contained in:
1 parent
6278d19618
commit
311ec74668
21 files changed
+1920
-231
No files matched your search
Regular → Executable
+10
@@ -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",
|
||||
|
||||
@@ -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: <API_KEY>`
|
||||
- Exemple: `GET {RADARR_URL}/api/v3/movie?includeMovieFile=true`
|
||||
|
||||
## Faisabilité
|
||||
|
||||
| Besoin | Faisable | Approche retenue |
|
||||
|
||||
@@ -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)
|
||||
|
||||
+106
-22
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
+3
-2
@@ -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
|
||||
|
||||
+42
-1
@@ -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
|
||||
|
||||
+12
-21
@@ -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
|
||||
+1
-2
@@ -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"]
|
||||
|
||||
Generated
+58
@@ -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",
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@
|
||||
"vite": "latest",
|
||||
"typescript": "latest",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
"react-dom": "latest",
|
||||
"react-router-dom": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "latest",
|
||||
|
||||
+141
-147
@@ -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<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();
|
||||
function GearIcon({className}: { className?: string }) {
|
||||
return (
|
||||
<svg
|
||||
className={className}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
aria-hidden
|
||||
>
|
||||
<path
|
||||
d="M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
/>
|
||||
<path
|
||||
d="M19.4 15a8.9 8.9 0 0 0 .1-1l2-1.5-2-3.5-2.4.6a8.2 8.2 0 0 0-1.7-1L15 6h-6l-.4 2.6a8.2 8.2 0 0 0-1.7 1L4.5 9l-2 3.5 2 1.5a8.9 8.9 0 0 0 .1 1 8.9 8.9 0 0 0-.1 1l-2 1.5 2 3.5 2.4-.6a8.2 8.2 0 0 0 1.7 1L9 22h6l.4-2.6a8.2 8.2 0 0 0 1.7-1l2.4.6 2-3.5-2-1.5a8.9 8.9 0 0 0-.1-1Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function readableSize(size: number | null): string {
|
||||
if (size === null) return "—";
|
||||
return `${(size / 1024 ** 3).toFixed(1)} Go`;
|
||||
function HomeIcon({className}: { className?: string }) {
|
||||
return (
|
||||
<svg className={className} viewBox="0 0 24 24" fill="none" aria-hidden>
|
||||
<path
|
||||
d="M4 10.5 12 4l8 6.5V20a1.5 1.5 0 0 1-1.5 1.5H5.5A1.5 1.5 0 0 1 4 20v-9.5Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
<path
|
||||
d="M9.5 21.5v-6a2.5 2.5 0 0 1 5 0v6"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function FolderIcon({className}: { className?: string }) {
|
||||
return (
|
||||
<svg className={className} viewBox="0 0 24 24" fill="none" aria-hidden>
|
||||
<path
|
||||
d="M3.5 19.5V6.8c0-.7.6-1.3 1.3-1.3h5.1l2 2h8.3c.7 0 1.3.6 1.3 1.3v10.7c0 .7-.6 1.3-1.3 1.3H4.8c-.7 0-1.3-.6-1.3-1.3Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const [movies, setMovies] = useState<Movie[]>([]);
|
||||
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<Route>({name: "dashboard"});
|
||||
|
||||
const loadMovies = useCallback(async () => {
|
||||
setMovies(await api<Movie[]>("/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<RadarrSettings>("/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<RadarrSettings>("/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 (
|
||||
<main>
|
||||
<header>
|
||||
<div>
|
||||
<p className="eyebrow">RADARR · ISO → MKV</p>
|
||||
<h1>MKVTool</h1>
|
||||
</div>
|
||||
<button onClick={scan} disabled={busy || !keyConfigured}>Scanner maintenant</button>
|
||||
</header>
|
||||
|
||||
<section className="panel settings">
|
||||
<div>
|
||||
<h2>Connexion Radarr</h2>
|
||||
<p>L’URL doit être accessible depuis le conteneur MKVTool.</p>
|
||||
</div>
|
||||
<form onSubmit={saveSettings}>
|
||||
<label>
|
||||
URL Radarr
|
||||
<input
|
||||
type="url"
|
||||
required
|
||||
placeholder="http://radarr:7878"
|
||||
value={url}
|
||||
onChange={(event) => setUrl(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Clé API {keyConfigured && <span>· configurée</span>}
|
||||
<input
|
||||
type="password"
|
||||
required={!keyConfigured}
|
||||
placeholder={keyConfigured ? "Laisser vide pour conserver" : "Clé API Radarr"}
|
||||
value={apiKey}
|
||||
onChange={(event) => setApiKey(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button disabled={busy}>Enregistrer et tester</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
{message && <p className="message">{message}</p>}
|
||||
|
||||
<section className="library">
|
||||
<div className="section-title">
|
||||
<div>
|
||||
<p className="eyebrow">INVENTAIRE</p>
|
||||
<h2>Films ISO</h2>
|
||||
</div>
|
||||
<span>{movies.length} détecté(s)</span>
|
||||
</div>
|
||||
{movies.length === 0 ? (
|
||||
<div className="empty">Configurez Radarr puis lancez votre premier scan.</div>
|
||||
) : (
|
||||
<div className="movie-list">
|
||||
{movies.map((movie) => (
|
||||
<article key={movie.id}>
|
||||
<div>
|
||||
<h3>{movie.title}</h3>
|
||||
<p>{movie.year ?? "Année inconnue"} · {readableSize(movie.size)}</p>
|
||||
<code>{movie.path}</code>
|
||||
return (
|
||||
<div className="app-shell">
|
||||
<aside className="nav">
|
||||
<div className="nav__brand">
|
||||
<div className="nav__logo">M</div>
|
||||
<div>
|
||||
<div className="nav__title">MKVTool</div>
|
||||
<div className="nav__subtitle">ISO → MKV</div>
|
||||
</div>
|
||||
</div>
|
||||
<span className="status">{movie.status}</span>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
|
||||
<nav className="nav__items">
|
||||
<button
|
||||
className={route.name === "dashboard" ? "nav__item nav__item--active" : "nav__item"}
|
||||
onClick={() => setRoute({name: "dashboard"})}
|
||||
type="button"
|
||||
>
|
||||
<HomeIcon className="nav__icon"/>
|
||||
Dashboard
|
||||
</button>
|
||||
<button
|
||||
className={route.name === "files" || route.name === "file" ? "nav__item nav__item--active" : "nav__item"}
|
||||
onClick={() => setRoute({name: "files"})}
|
||||
type="button"
|
||||
>
|
||||
<FolderIcon className="nav__icon"/>
|
||||
Fichiers
|
||||
</button>
|
||||
<button
|
||||
className={route.name === "settings" ? "nav__item nav__item--active" : "nav__item"}
|
||||
onClick={() => setRoute({name: "settings"})}
|
||||
type="button"
|
||||
>
|
||||
<GearIcon className="nav__icon"/>
|
||||
Configuration
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div className="nav__footer">
|
||||
<div className="chip chip--subtle">v0.1</div>
|
||||
<div className="muted">Premium dark UI</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main className="content">
|
||||
<header className="topbar">
|
||||
<div>
|
||||
<div className="eyebrow">{header.eyebrow}</div>
|
||||
<h1 className="page-title">{header.title}</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{route.name === "dashboard" && (
|
||||
<Dashboard
|
||||
onOpenFile={(id) => setRoute({name: "file", id})}
|
||||
onOpenFiles={() => setRoute({name: "files"})}
|
||||
onOpenSettings={() => setRoute({name: "settings"})}
|
||||
/>
|
||||
)}
|
||||
{route.name === "files" && <Files onOpenFile={(id) => setRoute({name: "file", id})}/>}
|
||||
{route.name === "file" && (
|
||||
<FileDetails id={route.id} onBack={() => setRoute({name: "files"})}/>
|
||||
)}
|
||||
{route.name === "settings" && <Settings/>}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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 <span className={`badge badge--${variant}`}>{status}</span>;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
||||
+4
-1
@@ -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(
|
||||
<StrictMode>
|
||||
<App />
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</StrictMode>,
|
||||
);
|
||||
@@ -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<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>
|
||||
);
|
||||
}
|
||||
@@ -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<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>
|
||||
);
|
||||
}
|
||||
@@ -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<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>
|
||||
);
|
||||
}
|
||||
@@ -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<SettingsRead>("/api/settings"));
|
||||
}, [hydrateSettings]);
|
||||
|
||||
useEffect(() => {
|
||||
refreshSettings().catch((error: Error) => setMessage(error.message));
|
||||
}, [refreshSettings]);
|
||||
|
||||
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();
|
||||
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<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("");
|
||||
|
||||
await refreshSettings();
|
||||
setMessage("Configuration enregistrée");
|
||||
} 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,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
setQbitPassword("");
|
||||
await refreshSettings();
|
||||
setMessage("Configuration enregistrée");
|
||||
} 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>
|
||||
<h3>Radarr</h3>
|
||||
<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>
|
||||
<h3>Sonarr</h3>
|
||||
<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</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<h3>Prowlarr</h3>
|
||||
<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</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<h3>Jellyfin</h3>
|
||||
<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</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<h3>Overseerr</h3>
|
||||
<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</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card grid-2">
|
||||
<div>
|
||||
<h3>qBittorrent</h3>
|
||||
<p className="muted">Optionnel: nécessaire pour supprimer torrent + données après import validé.</p>
|
||||
</div>
|
||||
<form onSubmit={saveQbittorrent} className="form-3">
|
||||
<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>
|
||||
<button disabled={busy}>Enregistrer</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h3>Aide</h3>
|
||||
<p className="muted">{serviceHelp}</p>
|
||||
</section>
|
||||
|
||||
{message && <div className="toast">{message}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+640
-34
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
Reference in new issue
Block a user