feat: add cross-album search, auto-rules, album UI redesign, editorial archiving and pdf download

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 02:53:15 +02:00
1 parent 9c0d43b1ec
commit 375e5b8b7d
23 files changed
+1153 -43

No files matched your search

+77 -2
View File
@@ -1,10 +1,44 @@
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
import { AlbumContactSheet } from "@/modules/albums/catalog-content";
import { AlbumContactSheet, PhotoContactSheet } from "@/modules/albums/catalog-content";
import { loadEditorialDownloadOptions } from "@/modules/downloads/stream";
import type { ImmichSearchPage } from "@/modules/immich/types";
import Link from "next/link";
import { requireEditorial } from "../access";
export default async function AlbumsPage() {
export default async function AlbumsPage({ searchParams }: { searchParams: Promise<{ suche?: string | string[]; page?: string | string[] }> }) {
const principal = await requireEditorial();
const rawSearchParams = await searchParams;
const query = normalizedQuery(singleValue(rawSearchParams.suche));
if (query) {
const results = await albumCatalog.searchVisiblePhotos(principal.editorialId, {
description: query,
page: singleValue(rawSearchParams.page),
});
const downloadOptions = await loadEditorialDownloadOptions(
principal.editorialId,
results.items.map((asset) => asset.id),
);
return (
<section className="editorial-section" aria-labelledby="albums-title">
<p className="editorial-kicker">Bildarchiv · Suche</p>
<div className="editorial-title-row">
<h1 id="albums-title">Suchergebnisse</h1>
</div>
<GlobalSearchForm query={query} />
<PhotoContactSheet
albumName="Alle Alben"
downloadOptions={downloadOptions}
page={results}
query={query}
showAlbumName
/>
<GlobalSearchPagination page={results} query={query} />
</section>
);
}
const result = await loadAlbums(principal.editorialId);
if (result.unavailable) {
@@ -18,6 +52,7 @@ export default async function AlbumsPage() {
<h1 id="albums-title">Ihre Alben</h1>
<p>Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen.</p>
</div>
<GlobalSearchForm query={query} />
{result.albums.length === 0 ? (
<p className="catalog-empty">Für Ihre Redaktion sind noch keine Fotoalben freigegeben.</p>
) : (
@@ -27,6 +62,46 @@ export default async function AlbumsPage() {
);
}
function GlobalSearchForm({ query }: { query: string }) {
return (
<form action="/redaktion/alben" className="global-search-form" role="search">
<input
type="search"
name="suche"
defaultValue={query}
placeholder="Alle Alben durchsuchen..."
aria-label="Alle Alben durchsuchen"
/>
<button type="submit">Suchen</button>
</form>
);
}
function GlobalSearchPagination({ page, query }: { page: ImmichSearchPage; query: string }) {
if (page.previousPage === null && page.nextPage === null) {
return null;
}
return (
<nav aria-label="Suchergebnisseiten" className="photo-pagination">
{page.previousPage === null ? null : (
<Link href={`/redaktion/alben?suche=${encodeURIComponent(query)}&page=${page.previousPage}`}>Vorherige Seite</Link>
)}
{page.nextPage === null ? null : (
<Link href={`/redaktion/alben?suche=${encodeURIComponent(query)}&page=${page.nextPage}`}>Nächste Seite</Link>
)}
</nav>
);
}
function singleValue(value: string | string[] | undefined): string | undefined {
return typeof value === "string" ? value : undefined;
}
function normalizedQuery(value: string | undefined): string {
return (value ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
}
async function loadAlbums(editorialId: string) {
try {
return { albums: await albumCatalog.getVisibleAlbums(editorialId), unavailable: false as const };