Merge v2.1-2.2.0 features onto SakaniUI base
Ports calendar, self-service, sorting, image descriptions, logo (2.1), filename search (2.1.1), statistics page, collab option and bundled invoice PDF delivery (2.2.0) onto the deployed SakaniUI portal. Also fixes the statistics daily series, which ended yesterday and so hid today's activity from the charts, and ignores Playwright test-results/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
c0c2425dda
106 files changed
+10000
-110
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { recordActivity } from "@/modules/activity/service";
|
||||
import { AlbumCatalogError, albumCatalog, PHOTO_PAGE_SIZE } from "@/modules/albums/catalog";
|
||||
import { AlbumContactSheet, formatCount, PageLinks, PhotoSearchForm } from "@/modules/albums/catalog-content";
|
||||
import { filterPhotos, paginatePhotos, type InAppPage } from "@/modules/albums/filter";
|
||||
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";
|
||||
@@ -15,12 +16,13 @@ import { requireEditorial } from "../access";
|
||||
// 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[] }> }) {
|
||||
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) {
|
||||
@@ -33,12 +35,14 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumCatalogError && error.code === "RATE_LIMITED") {
|
||||
return <SearchRateLimited query={query} format={format} jahr={jahr} />;
|
||||
return <SearchRateLimited query={query} format={format} jahr={jahr} sortierung={sortierung} />;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const filtered = filterPhotos(results.items, { format, jahr });
|
||||
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(
|
||||
@@ -52,7 +56,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
<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} withYear placeholder="Alle Alben durchsuchen …" />
|
||||
<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>
|
||||
@@ -63,7 +67,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
lightboxAssetIds={page.items.filter(({ id }) => lightboxAssetIds.has(id)).map(({ id }) => id)}
|
||||
showAlbumName
|
||||
/>
|
||||
<GlobalSearchPagination currentPage={currentPage} page={page} query={query} format={format} jahr={jahr} />
|
||||
<GlobalSearchPagination currentPage={currentPage} page={page} query={query} format={format} jahr={jahr} sortierung={sortierung} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -83,7 +87,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
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} withYear placeholder="Alle Alben durchsuchen …" />
|
||||
<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." />
|
||||
) : (
|
||||
@@ -93,17 +97,17 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
);
|
||||
}
|
||||
|
||||
function SearchRateLimited({ query, format, jahr }: { query: string; format?: string; jahr?: string }) {
|
||||
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} withYear placeholder="Alle Alben durchsuchen …" />
|
||||
<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 }: { currentPage: number; page: InAppPage; query: string; format?: string; jahr?: string }) {
|
||||
function GlobalSearchPagination({ currentPage, page, query, format, jahr, sortierung }: { currentPage: number; page: InAppPage; query: string; format?: string; jahr?: string; sortierung: PhotoSort }) {
|
||||
const hasPrev = currentPage > 1;
|
||||
const hasNext = page.nextPage !== null;
|
||||
if (!hasPrev && !hasNext) {
|
||||
@@ -112,16 +116,17 @@ function GlobalSearchPagination({ currentPage, page, query, format, jahr }: { cu
|
||||
|
||||
return (
|
||||
<PageLinks
|
||||
prevHref={hasPrev ? globalPageHref(currentPage - 1, query, format, jahr) : null}
|
||||
nextHref={hasNext ? globalPageHref(currentPage + 1, query, format, jahr) : null}
|
||||
prevHref={hasPrev ? globalPageHref(currentPage - 1, query, format, jahr, sortierung) : null}
|
||||
nextHref={hasNext ? globalPageHref(currentPage + 1, query, format, jahr, sortierung) : null}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function globalPageHref(page: number, query: string, format?: string, jahr?: string): string {
|
||||
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()}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user