- ZIP download from the Merkzettel: every photo is a new usage by default; only already downloaded photos offer "Neu / Bereits genutzt" (SegmentedControl), with thumbnails and a cost summary. "Bild auslassen" is gone. - Toasts (Sakani Toaster) for admin saves, deletes and errors; billing errors are readable and use router.refresh instead of reloads. Errors inside modal dialogs stay inline (a toast would sit behind the backdrop). - Album overview in blog-listing style, Sakani Pagination for albums, search and usage history, skeleton loading states. - Registration stepper; verification mail lands on step 3. - Editorials as a searchable, filterable table; audit log with event picker, German labels and collapsible details. - Release notes 2.4.0 seeded (migration 0009). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
7.1 KiB
TypeScript
157 lines
7.1 KiB
TypeScript
import { recordActivity } from "@/modules/activity/service";
|
|
import { AlbumCatalogError, albumCatalog, PHOTO_PAGE_SIZE } from "@/modules/albums/catalog";
|
|
import { UrlPagination } from "@/components/ui/url-pagination";
|
|
import { AlbumContactSheet, formatCount, PhotoSearchForm } from "@/modules/albums/catalog-content";
|
|
import { filterPhotos, normalizeSort, paginatePhotos, sortPhotos, type InAppPage, type PhotoSort } from "@/modules/albums/filter";
|
|
import { PhotoGallery } from "@/modules/albums/photo-gallery";
|
|
import { AnnouncementBanner } from "@/modules/announcements/announcement-banner";
|
|
import { announcementService } from "@/modules/announcements/service";
|
|
import { loadEditorialDownloadOptions } from "@/modules/downloads/stream";
|
|
import { lightboxService } from "@/modules/lightbox/service";
|
|
import { PageHeader } from "@/components/ui/page-header";
|
|
import { Alert, EmptyState } from "@/components/ui/sakani";
|
|
|
|
import { requireEditorial } from "../access";
|
|
|
|
// ponytail: same ceiling as the album detail page — cross-album search fetches
|
|
// up to 1000 matching photos, then filters/paginates in-app.
|
|
const SEARCH_FETCH_SIZE = 1000;
|
|
|
|
export default async function AlbumsPage({ searchParams }: { searchParams: Promise<{ suche?: string | string[]; page?: string | string[]; format?: string | string[]; jahr?: string | string[]; sortierung?: string | string[] }> }) {
|
|
const principal = await requireEditorial();
|
|
const rawSearchParams = await searchParams;
|
|
const query = normalizedQuery(singleValue(rawSearchParams.suche));
|
|
const format = singleValue(rawSearchParams.format);
|
|
const jahr = singleValue(rawSearchParams.jahr);
|
|
const sortierung = normalizeSort(singleValue(rawSearchParams.sortierung));
|
|
const hints = await announcementService.listActiveAnnouncements(new Date());
|
|
|
|
if (query) {
|
|
let results;
|
|
try {
|
|
results = await albumCatalog.searchVisiblePhotos(principal.editorialId, {
|
|
description: query,
|
|
page: 1,
|
|
size: SEARCH_FETCH_SIZE,
|
|
});
|
|
} catch (error) {
|
|
if (error instanceof AlbumCatalogError && error.code === "RATE_LIMITED") {
|
|
return <SearchRateLimited query={query} format={format} jahr={jahr} sortierung={sortierung} />;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
await recordActivity({ editorialId: principal.editorialId, type: "search", query });
|
|
|
|
const filtered = sortPhotos(filterPhotos(results.items, { format, jahr }), sortierung);
|
|
const { result: page, currentPage } = paginatePhotos(filtered, singleValue(rawSearchParams.page), PHOTO_PAGE_SIZE);
|
|
|
|
const downloadOptions = await loadEditorialDownloadOptions(
|
|
principal.editorialId,
|
|
page.items.map((asset) => asset.id),
|
|
);
|
|
const lightboxItems = await lightboxService.getLightboxItems(principal.editorialId);
|
|
const lightboxAssetIds = new Set(lightboxItems.map(i => i.assetId));
|
|
|
|
return (
|
|
<section className="flex flex-col gap-6" aria-labelledby="albums-title">
|
|
<PageHeader kicker="Bildarchiv · Suche" title="Suchergebnisse" titleId="albums-title" />
|
|
<AnnouncementBanner items={hints} />
|
|
<PhotoSearchForm action="/redaktion/alben" query={query} format={format} jahr={jahr} sortierung={sortierung} withYear placeholder="Alle Alben durchsuchen …" />
|
|
<p aria-live="polite" className="text-sm text-[var(--color-fg-muted)]" role="status">
|
|
{formatCount(page.total, "Foto")} gefunden
|
|
</p>
|
|
<PhotoGallery
|
|
albumName="Alle Alben"
|
|
items={page.items}
|
|
downloadOptions={downloadOptions}
|
|
lightboxAssetIds={page.items.filter(({ id }) => lightboxAssetIds.has(id)).map(({ id }) => id)}
|
|
showAlbumName
|
|
/>
|
|
<GlobalSearchPagination currentPage={currentPage} page={page} query={query} format={format} jahr={jahr} sortierung={sortierung} />
|
|
</section>
|
|
);
|
|
}
|
|
|
|
const result = await loadAlbums(principal.editorialId);
|
|
|
|
if (result.unavailable) {
|
|
return <ImmichUnavailable />;
|
|
}
|
|
|
|
return (
|
|
<section className="flex flex-col gap-8" aria-labelledby="albums-title">
|
|
<PageHeader
|
|
kicker="Bildarchiv · Freigaben"
|
|
title="Ihre Alben"
|
|
titleId="albums-title"
|
|
description="Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen."
|
|
/>
|
|
<AnnouncementBanner items={hints} />
|
|
<PhotoSearchForm action="/redaktion/alben" query={query} format={format} jahr={jahr} sortierung={sortierung} withYear placeholder="Alle Alben durchsuchen …" />
|
|
{result.albums.length === 0 ? (
|
|
<EmptyState title="Noch keine Alben" description="Für Ihre Redaktion sind noch keine Fotoalben freigegeben." />
|
|
) : (
|
|
<AlbumContactSheet albums={result.albums} />
|
|
)}
|
|
</section>
|
|
);
|
|
}
|
|
|
|
function SearchRateLimited({ query, format, jahr, sortierung }: { query: string; format?: string; jahr?: string; sortierung: PhotoSort }) {
|
|
return (
|
|
<section className="flex flex-col gap-6" aria-labelledby="albums-title">
|
|
<PageHeader kicker="Bildarchiv · Suche" title="Bitte kurz warten" titleId="albums-title" />
|
|
<PhotoSearchForm action="/redaktion/alben" query={query} format={format} jahr={jahr} sortierung={sortierung} withYear placeholder="Alle Alben durchsuchen …" />
|
|
<Alert color="warning" description="Es wurden sehr viele Suchanfragen gestellt. Bitte versuchen Sie es in Kürze erneut." />
|
|
</section>
|
|
);
|
|
}
|
|
|
|
function GlobalSearchPagination({ currentPage, page, query, format, jahr, sortierung }: { currentPage: number; page: InAppPage; query: string; format?: string; jahr?: string; sortierung: PhotoSort }) {
|
|
return (
|
|
<UrlPagination
|
|
ariaLabel="Suchergebnisseiten"
|
|
hasNext={page.nextPage !== null}
|
|
href={globalPageHref(currentPage, query, format, jahr, sortierung)}
|
|
page={currentPage}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function globalPageHref(page: number, query: string, format?: string, jahr?: string, sortierung?: PhotoSort): string {
|
|
const parameters = new URLSearchParams({ suche: query, page: String(page) });
|
|
if (format) parameters.set("format", format);
|
|
if (jahr) parameters.set("jahr", jahr);
|
|
if (sortierung === "aelteste") parameters.set("sortierung", "aelteste");
|
|
return `/redaktion/alben?${parameters.toString()}`;
|
|
}
|
|
|
|
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 };
|
|
} catch (error) {
|
|
if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") {
|
|
return { albums: [], unavailable: true as const };
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
function ImmichUnavailable() {
|
|
return (
|
|
<section className="flex flex-col gap-6" aria-labelledby="albums-title">
|
|
<PageHeader kicker="Bildarchiv" title="Alben momentan nicht erreichbar" titleId="albums-title" />
|
|
<Alert color="danger" description="Bitte laden Sie diese Seite in wenigen Minuten erneut. Ihre Freigaben bleiben unverändert." />
|
|
</section>
|
|
);
|
|
}
|