feat: table series avec UUID PK — migration complète backend + frontend
Migration DB (0070 + 0071): - Backup automatique de book_reading_progress avant migration - Crée table series (fusion de series_metadata) avec UUID PK - Ajoute series_id FK à books, external_metadata_links, anilist_series_links, available_downloads, download_detection_results - Supprime les colonnes TEXT legacy et la table series_metadata Backend API + Indexer: - Toutes les queries SQL migrées vers series_id FK + JOIN series - Routes /series/:name → /series/:series_id (UUID) - Nouvel endpoint GET /series/by-name/:name pour lookup par nom - match_title_volumes() factorisé entre prowlarr.rs et download_detection.rs - Fix scheduler.rs: settings → app_settings - OpenAPI mis à jour avec les nouveaux endpoints Frontend: - Routes /libraries/[id]/series/[name] → /series/[seriesId] - Tous les composants (Edit, Delete, MarkRead, Prowlarr, Metadata, ReadingStatus) utilisent seriesId - compressVolumes() pour afficher T1→3 au lieu de T1 T2 T3 - Titre release en entier (plus de truncate) dans available downloads Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,8 +77,8 @@ export default async function AuthorDetailPage({
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4">
|
||||
{authorSeries.map((s) => (
|
||||
<Link
|
||||
key={`${s.library_id}-${s.name}`}
|
||||
href={`/libraries/${s.library_id}/series/${encodeURIComponent(s.name)}`}
|
||||
key={`${s.library_id}-${s.series_id}`}
|
||||
href={`/libraries/${s.library_id}/series/${s.series_id}`}
|
||||
className="group"
|
||||
>
|
||||
<div className="bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden hover:shadow-md hover:-translate-y-1 transition-all duration-200">
|
||||
|
||||
@@ -76,10 +76,10 @@ export default async function BookDetailPage({
|
||||
<span className="text-muted-foreground">/</span>
|
||||
</>
|
||||
)}
|
||||
{book.series && (
|
||||
{book.series && book.series_id && (
|
||||
<>
|
||||
<Link
|
||||
href={`/libraries/${book.library_id}/series/${encodeURIComponent(book.series)}`}
|
||||
href={`/libraries/${book.library_id}/series/${book.series_id}`}
|
||||
className="text-muted-foreground hover:text-primary transition-colors"
|
||||
>
|
||||
{book.series}
|
||||
@@ -116,9 +116,9 @@ export default async function BookDetailPage({
|
||||
{book.author && (
|
||||
<p className="text-base text-muted-foreground">{book.author}</p>
|
||||
)}
|
||||
{book.series && (
|
||||
{book.series && book.series_id && (
|
||||
<Link
|
||||
href={`/libraries/${book.library_id}/series/${encodeURIComponent(book.series)}`}
|
||||
href={`/libraries/${book.library_id}/series/${book.series_id}`}
|
||||
className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-primary/10 text-primary text-xs border border-primary/30 font-medium"
|
||||
>
|
||||
{book.series}
|
||||
|
||||
@@ -134,8 +134,8 @@ export default async function BooksPage({
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
||||
{seriesHits.map((s) => (
|
||||
<Link
|
||||
key={`${s.library_id}-${s.name}`}
|
||||
href={`/libraries/${s.library_id}/series/${encodeURIComponent(s.name)}`}
|
||||
key={`${s.library_id}-${s.series_id}`}
|
||||
href={`/libraries/${s.library_id}/series/${s.series_id}`}
|
||||
className="group"
|
||||
>
|
||||
<div className="bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden hover:shadow-md transition-shadow duration-200">
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TorrentDownloadDto, LatestFoundPerLibraryDto } from "@/lib/api";
|
||||
import { Card, CardContent, CardHeader, CardTitle, Button, Icon } from "@/app/components/ui";
|
||||
import { QbittorrentProvider, QbittorrentDownloadButton } from "@/app/components/QbittorrentDownloadButton";
|
||||
import { useTranslation } from "@/lib/i18n/context";
|
||||
import { compressVolumes } from "@/lib/volumeRanges";
|
||||
import type { TranslationKey } from "@/lib/i18n/fr";
|
||||
|
||||
type TFunction = (key: TranslationKey, vars?: Record<string, string | number>) => string;
|
||||
@@ -260,7 +261,7 @@ function DownloadRow({ dl, onDeleted }: { dl: TorrentDownloadDto; onDeleted: ()
|
||||
<div className="flex-1 min-w-0">
|
||||
{/* Desktop: single row */}
|
||||
<div className="hidden sm:flex items-center gap-2">
|
||||
<Link href={`/libraries/${dl.library_id}/series/${encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<Link href={`/libraries/${dl.library_id}/series/${dl.series_id ?? encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<span className={`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${statusClass(dl.status)}`}>
|
||||
{statusLabel(dl.status, t)}
|
||||
</span>
|
||||
@@ -275,7 +276,7 @@ function DownloadRow({ dl, onDeleted }: { dl: TorrentDownloadDto; onDeleted: ()
|
||||
{/* Mobile: stacked */}
|
||||
<div className="sm:hidden">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Link href={`/libraries/${dl.library_id}/series/${encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<Link href={`/libraries/${dl.library_id}/series/${dl.series_id ?? encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<span className={`text-[10px] font-medium px-1.5 py-0.5 rounded-full shrink-0 ${statusClass(dl.status)}`}>
|
||||
{statusLabel(dl.status, t)}
|
||||
</span>
|
||||
@@ -389,7 +390,7 @@ function AvailableLibraryCard({ lib, onDeleted }: { lib: LatestFoundPerLibraryDt
|
||||
<div key={r.id} className="rounded-lg border border-border/40 bg-background/60 p-2 sm:p-3">
|
||||
<div className="flex items-center justify-between gap-2 mb-1.5">
|
||||
<Link
|
||||
href={`/libraries/${lib.library_id}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${lib.library_id}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-semibold text-xs sm:text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -403,11 +404,11 @@ function AvailableLibraryCard({ lib, onDeleted }: { lib: LatestFoundPerLibraryDt
|
||||
{groupReleasesByTitle(r.available_releases).map((group) => (
|
||||
<div key={group.title} className="rounded bg-muted/30 overflow-hidden">
|
||||
{/* Title + matched volumes (shown once) */}
|
||||
<div className="flex items-center gap-2 py-1 px-2">
|
||||
<p className="text-[11px] sm:text-xs font-mono text-foreground truncate flex-1" title={group.title}>{group.title}</p>
|
||||
<div className="flex flex-wrap items-center gap-1 shrink-0">
|
||||
{group.items[0].matched_missing_volumes.map(vol => (
|
||||
<span key={vol} className="text-[10px] px-1 py-0.5 rounded-full bg-success/20 text-success font-medium">T{vol}</span>
|
||||
<div className="py-1 px-2">
|
||||
<p className="text-[11px] sm:text-xs font-mono text-foreground break-all">{group.title}</p>
|
||||
<div className="flex flex-wrap items-center gap-1 mt-1">
|
||||
{compressVolumes(group.items[0].matched_missing_volumes).map(range => (
|
||||
<span key={range} className="text-[10px] px-1 py-0.5 rounded-full bg-success/20 text-success font-medium">{range}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Card, CardHeader, CardTitle, CardDescription, CardContent, StatBox } fr
|
||||
import { QbittorrentProvider, QbittorrentDownloadButton } from "@/app/components/QbittorrentDownloadButton";
|
||||
import type { DownloadDetectionReportDto, DownloadDetectionResultDto } from "@/lib/api";
|
||||
import type { TranslateFunction } from "@/lib/i18n/dictionaries";
|
||||
import { compressVolumes } from "@/lib/volumeRanges";
|
||||
|
||||
export function DownloadDetectionReportCard({ report, t }: { report: DownloadDetectionReportDto; t: TranslateFunction }) {
|
||||
return (
|
||||
@@ -69,7 +70,7 @@ export function DownloadDetectionResultsCard({ results, libraryId, qbConfigured,
|
||||
<div className="flex items-center justify-between gap-2 mb-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-semibold text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -97,10 +98,10 @@ export function DownloadDetectionResultsCard({ results, libraryId, qbConfigured,
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
{(release.size / 1024 / 1024).toFixed(0)} MB
|
||||
</span>
|
||||
<div className="flex items-center gap-1">
|
||||
{release.matched_missing_volumes.map((vol) => (
|
||||
<span key={vol} className="text-[10px] px-1.5 py-0.5 rounded-full bg-success/20 text-success font-medium">
|
||||
T.{vol}
|
||||
<div className="flex flex-wrap items-center gap-1">
|
||||
{compressVolumes(release.matched_missing_volumes).map((range) => (
|
||||
<span key={range} className="text-[10px] px-1.5 py-0.5 rounded-full bg-success/20 text-success font-medium">
|
||||
{range}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -51,7 +51,7 @@ export function MetadataBatchResultsCard({ results, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -157,7 +157,7 @@ export function MetadataRefreshChangesCard({ report, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
|
||||
@@ -51,7 +51,7 @@ export function ReadingStatusMatchResultsCard({ results, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -146,7 +146,7 @@ export function ReadingStatusPushResultsCard({ results, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
|
||||
@@ -33,28 +33,20 @@ export default async function SeriesDetailPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ id: string; name: string }>;
|
||||
params: Promise<{ id: string; seriesId: string }>;
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}) {
|
||||
const { id, name } = await params;
|
||||
const { id, seriesId } = await params;
|
||||
const { t } = await getServerTranslations();
|
||||
const searchParamsAwaited = await searchParams;
|
||||
const page = typeof searchParamsAwaited.page === "string" ? parseInt(searchParamsAwaited.page) : 1;
|
||||
const limit = typeof searchParamsAwaited.limit === "string" ? parseInt(searchParamsAwaited.limit) : 50;
|
||||
|
||||
const seriesName = decodeURIComponent(name);
|
||||
|
||||
const [library, booksPage, seriesMeta, metadataLinks, readingStatusLink, prowlarrConfigured, qbConfigured, metadataProviders] = await Promise.all([
|
||||
const [library, seriesMeta, metadataLinks, readingStatusLink, prowlarrConfigured, qbConfigured, metadataProviders] = await Promise.all([
|
||||
fetchLibraries().then((libs) => libs.find((l) => l.id === id)),
|
||||
fetchBooks(id, seriesName, page, limit).catch(() => ({
|
||||
items: [] as BookDto[],
|
||||
total: 0,
|
||||
page: 1,
|
||||
limit,
|
||||
})),
|
||||
fetchSeriesMetadata(id, seriesName).catch(() => null as SeriesMetadataDto | null),
|
||||
getMetadataLink(id, seriesName).catch(() => [] as ExternalMetadataLinkDto[]),
|
||||
getReadingStatusLink(id, seriesName).catch(() => null as AnilistSeriesLinkDto | null),
|
||||
fetchSeriesMetadata(id, seriesId).catch(() => null as SeriesMetadataDto | null),
|
||||
getMetadataLink(id, seriesId).catch(() => [] as ExternalMetadataLinkDto[]),
|
||||
getReadingStatusLink(id, seriesId).catch(() => null as AnilistSeriesLinkDto | null),
|
||||
apiFetch<{ api_key?: string }>("/settings/prowlarr")
|
||||
.then(d => !!(d?.api_key?.trim()))
|
||||
.catch(() => false),
|
||||
@@ -64,6 +56,17 @@ export default async function SeriesDetailPage({
|
||||
apiFetch<{ comicvine?: { api_key?: string } }>("/settings/metadata_providers").catch(() => null),
|
||||
]);
|
||||
|
||||
// Get series name from metadata for display
|
||||
const seriesName = seriesMeta?.series_name ?? "";
|
||||
|
||||
// Fetch books using seriesId for the filter query
|
||||
const booksPage = await fetchBooks(id, seriesId, page, limit).catch(() => ({
|
||||
items: [] as BookDto[],
|
||||
total: 0,
|
||||
page: 1,
|
||||
limit,
|
||||
}));
|
||||
|
||||
const hiddenProviders: string[] = [];
|
||||
if (!metadataProviders?.comicvine?.api_key) hiddenProviders.push("comicvine");
|
||||
|
||||
@@ -228,12 +231,14 @@ export default async function SeriesDetailPage({
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<MarkSeriesReadButton
|
||||
seriesId={seriesId}
|
||||
seriesName={seriesName}
|
||||
bookCount={booksPage.total}
|
||||
booksReadCount={booksReadCount}
|
||||
/>
|
||||
<EditSeriesForm
|
||||
libraryId={id}
|
||||
seriesId={seriesId}
|
||||
seriesName={seriesName}
|
||||
currentAuthors={seriesMeta?.authors ?? []}
|
||||
currentPublishers={seriesMeta?.publishers ?? []}
|
||||
@@ -261,13 +266,14 @@ export default async function SeriesDetailPage({
|
||||
/>
|
||||
<ReadingStatusModal
|
||||
libraryId={id}
|
||||
seriesId={seriesId}
|
||||
seriesName={seriesName}
|
||||
readingStatusProvider={library.reading_status_provider ?? null}
|
||||
existingLink={readingStatusLink}
|
||||
/>
|
||||
<DeleteSeriesButton
|
||||
libraryId={id}
|
||||
seriesName={seriesName}
|
||||
seriesId={seriesId}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,8 +75,8 @@ export default async function LibrarySeriesPage({
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-6">
|
||||
{series.map((s) => (
|
||||
<Link
|
||||
key={s.name}
|
||||
href={`/libraries/${id}/series/${encodeURIComponent(s.name)}`}
|
||||
key={s.series_id}
|
||||
href={`/libraries/${id}/series/${s.series_id}`}
|
||||
className="group"
|
||||
>
|
||||
<div className={`bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden hover:shadow-md transition-shadow duration-200 ${s.books_read_count >= s.book_count ? "opacity-50" : ""}`}>
|
||||
@@ -98,6 +98,7 @@ export default async function LibrarySeriesPage({
|
||||
{t("series.readCount", { read: String(s.books_read_count), total: String(s.book_count), plural: s.book_count !== 1 ? "s" : "" })}
|
||||
</p>
|
||||
<MarkSeriesReadButton
|
||||
seriesId={s.series_id}
|
||||
seriesName={s.name}
|
||||
bookCount={s.book_count}
|
||||
booksReadCount={s.books_read_count}
|
||||
|
||||
@@ -124,7 +124,7 @@ export default async function SeriesPage({
|
||||
<>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4">
|
||||
{series.map((s) => (
|
||||
<div key={s.name} className="group relative">
|
||||
<div key={s.series_id} className="group relative">
|
||||
<div
|
||||
className={`bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden group-hover:shadow-md group-hover:-translate-y-1 transition-all duration-200 ${
|
||||
s.books_read_count >= s.book_count ? "opacity-50" : ""
|
||||
@@ -149,6 +149,7 @@ export default async function SeriesPage({
|
||||
</p>
|
||||
<div className="relative z-20">
|
||||
<MarkSeriesReadButton
|
||||
seriesId={s.series_id}
|
||||
seriesName={s.name}
|
||||
bookCount={s.book_count}
|
||||
booksReadCount={s.books_read_count}
|
||||
@@ -190,7 +191,7 @@ export default async function SeriesPage({
|
||||
</div>
|
||||
{/* Link overlay covering the full card — below interactive elements */}
|
||||
<Link
|
||||
href={`/libraries/${s.library_id}/series/${encodeURIComponent(s.name)}`}
|
||||
href={`/libraries/${s.library_id}/series/${s.series_id}`}
|
||||
className="absolute inset-0 z-10 rounded-xl"
|
||||
aria-label={s.name === "unclassified" ? t("books.unclassified") : s.name}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user