feat: redesign photo overview (masonry + lightbox) and fix hoch/quer search
The album search could not distinguish portrait from landscape: the format filter ran client-side over a single 60-item page and relied on exifInfo that Immich never returned (no withExif flag), so the orientation guard fell through and every photo matched every filter. Pagination links also dropped format/jahr on the next page. - immich/client: send withExif: true on /search/metadata so exifImageWidth/Height are populated for orientation filtering and masonry aspect ratios. - albums/filter (new): filter + paginate across the full fetched set so total, page slice and has-more-pages stay consistent with active filters; both the album detail and the cross-album search pages use it. - albums/photo-gallery (new client component): masonry grid with native EXIF aspect ratios (object-fit: cover, no more 3:2 letterboxing), hover overlay with filename/date + merken/lizenzieren/vergrößern, and a full-screen lightbox with keyboard nav (Esc/arrow keys). - catalog-content: drop the old PhotoContactSheet; keep AlbumContactSheet and thread format/jahr through PhotoPagination links. - Album detail search form restyled to the editorial design system (sharp ink borders) instead of the shadcn rounded card. - Tests: filter.test.ts covers the orientation/year/pagination logic; catalog-content.test.tsx updated to the gallery + lightbox structure; immich client test expects withExif: true. Skipped: global search form still uses shadcn styling (visually inconsistent but functionally fixed); albums > 1000 photos lose tail items (noted with a ponytail ceiling comment). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
b81cd7c3e2
commit
a3ec068cac
11 files changed
+949
-267
No files matched your search
+386
-28
@@ -569,40 +569,25 @@ a {
|
||||
text-underline-offset: 0.2em;
|
||||
}
|
||||
|
||||
.album-contact-sheet,
|
||||
.photo-contact-sheet {
|
||||
.album-contact-sheet {
|
||||
display: grid;
|
||||
gap: clamp(1.25rem, 2.25vw, 2.5rem);
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.album-contact-sheet {
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
|
||||
}
|
||||
|
||||
.photo-contact-sheet {
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr));
|
||||
}
|
||||
|
||||
.contact-sheet-link {
|
||||
display: block;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.album-contact-frame,
|
||||
.photo-contact-frame {
|
||||
.album-contact-frame {
|
||||
margin: 0;
|
||||
background: var(--contact-sheet);
|
||||
}
|
||||
|
||||
.album-contact-frame {
|
||||
border: 1px solid var(--ink);
|
||||
}
|
||||
|
||||
.photo-contact-frame {
|
||||
border-top: 1px solid var(--ink);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.contact-sheet-image,
|
||||
@@ -615,10 +600,6 @@ a {
|
||||
transition: transform 150ms ease-out;
|
||||
}
|
||||
|
||||
.photo-contact-frame .contact-sheet-image {
|
||||
aspect-ratio: 3 / 2;
|
||||
}
|
||||
|
||||
.missing-contact-image {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
@@ -633,11 +614,6 @@ a {
|
||||
transform: scale(1.015);
|
||||
}
|
||||
|
||||
.album-contact-frame,
|
||||
.photo-contact-frame {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.contact-strip {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
@@ -662,6 +638,191 @@ a {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* --- Photo overview: masonry grid + hover overlay + lightbox --------------
|
||||
Replaces the old contact-sheet (forced 3:2 tiles, object-fit: contain,
|
||||
permanent monospace caption strips). Each photo keeps its native aspect
|
||||
ratio via an inline `aspect-ratio` set from EXIF dimensions; the grid uses
|
||||
CSS columns for a dense masonry layout. Captions and actions appear on
|
||||
hover/focus, and a full-screen lightbox opens on click. */
|
||||
.photo-gallery {
|
||||
columns: 4 17rem;
|
||||
column-gap: clamp(0.75rem, 1.5vw, 1.25rem);
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@media (max-width: 64rem) {
|
||||
.photo-gallery { columns: 3 14rem; }
|
||||
}
|
||||
@media (max-width: 48rem) {
|
||||
.photo-gallery { columns: 2 9rem; }
|
||||
}
|
||||
|
||||
.photo-tile {
|
||||
break-inside: avoid;
|
||||
margin: 0 0 clamp(0.75rem, 1.5vw, 1.25rem);
|
||||
}
|
||||
|
||||
.photo-tile-frame {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: var(--contact-sheet);
|
||||
}
|
||||
|
||||
.photo-tile-trigger {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: var(--contact-sheet);
|
||||
cursor: zoom-in;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.photo-tile-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
min-height: 6rem;
|
||||
object-fit: cover;
|
||||
background: var(--contact-sheet);
|
||||
transition: transform 200ms ease-out;
|
||||
}
|
||||
|
||||
.photo-tile-trigger:hover .photo-tile-image,
|
||||
.photo-tile-trigger:focus-visible .photo-tile-image {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.photo-tile-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem;
|
||||
background: linear-gradient(
|
||||
to top,
|
||||
rgb(0 0 0 / 78%) 0%,
|
||||
rgb(0 0 0 / 38%) 40%,
|
||||
rgb(0 0 0 / 0%) 70%
|
||||
);
|
||||
opacity: 0;
|
||||
transition: opacity 160ms ease-out;
|
||||
pointer-events: none; /* let clicks reach the image; buttons re-enable below */
|
||||
}
|
||||
|
||||
.photo-tile-frame:hover .photo-tile-overlay,
|
||||
.photo-tile-frame:focus-within .photo-tile-overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.photo-tile-caption {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.photo-tile-name {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.photo-tile-album {
|
||||
font-size: 0.65rem;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.photo-tile-date {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.625rem;
|
||||
letter-spacing: 0.03em;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.photo-tile-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* Compact the full-width `.download-trigger` so it fits in the overlay row. */
|
||||
.photo-tile-actions .download-trigger,
|
||||
.lightbox-actions .download-trigger {
|
||||
width: auto;
|
||||
min-height: 2rem;
|
||||
padding: 0 0.75rem;
|
||||
border: 1px solid #fff;
|
||||
border-top: 1px solid #fff;
|
||||
background: rgb(255 255 255 / 12%);
|
||||
color: #fff;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.photo-tile-actions .download-trigger:hover,
|
||||
.lightbox-actions .download-trigger:hover {
|
||||
background: #fff;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* Base icon-button shape for the merken toggle (no base style existed). */
|
||||
.lightbox-toggle-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
padding: 0;
|
||||
border: 1px solid var(--ink);
|
||||
border-radius: 0;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.lightbox-toggle-btn:hover {
|
||||
background: var(--ink);
|
||||
color: var(--paper);
|
||||
}
|
||||
|
||||
.lightbox-toggle-btn.in-lightbox {
|
||||
background: var(--ink);
|
||||
color: var(--paper);
|
||||
}
|
||||
|
||||
.lightbox-toggle-btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: progress;
|
||||
}
|
||||
|
||||
/* Recolor the lightbox toggle for dark overlays. */
|
||||
.photo-tile-actions .lightbox-toggle-btn,
|
||||
.lightbox-actions .lightbox-toggle-btn {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 12%);
|
||||
border: 1px solid #fff;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.photo-tile-actions .lightbox-toggle-btn:hover,
|
||||
.lightbox-actions .lightbox-toggle-btn:hover {
|
||||
background: #fff;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.photo-search {
|
||||
display: grid;
|
||||
gap: 0.55rem;
|
||||
@@ -736,6 +897,201 @@ a {
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
/* Album search form — editorial styling (sharp ink borders, paper ground),
|
||||
aligned with the portal's browsing surface instead of the shadcn rounded
|
||||
card used elsewhere. */
|
||||
.album-search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 1rem;
|
||||
margin: 0 0 1.5rem;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--ink);
|
||||
background: var(--paper);
|
||||
}
|
||||
|
||||
.album-search-input {
|
||||
flex: 1 1 20rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.album-search-label {
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--metadata);
|
||||
}
|
||||
|
||||
.album-search-input input[type="search"] {
|
||||
width: 100%;
|
||||
min-height: 2.75rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--ink);
|
||||
border-radius: 0;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.album-search-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.album-search-select {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--metadata);
|
||||
}
|
||||
|
||||
.album-search-select select {
|
||||
min-height: 2.75rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--ink);
|
||||
border-radius: 0;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
font-size: 0.9rem;
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.album-search-form button[type="submit"] {
|
||||
min-height: 2.75rem;
|
||||
padding: 0 1.25rem;
|
||||
border: 1px solid var(--ink);
|
||||
border-radius: 0;
|
||||
background: var(--ink);
|
||||
color: var(--paper);
|
||||
font: inherit;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.album-search-form button[type="submit"]:hover {
|
||||
background: var(--graphite);
|
||||
}
|
||||
|
||||
/* Full-screen photo lightbox. */
|
||||
.photo-lightbox {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 100;
|
||||
display: grid;
|
||||
grid-template-rows: 1fr auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
gap: 1rem;
|
||||
padding: clamp(1rem, 4vw, 3rem);
|
||||
background: rgb(0 0 0 / 92%);
|
||||
backdrop-filter: blur(6px);
|
||||
animation: lightbox-fade-in 160ms ease-out;
|
||||
}
|
||||
|
||||
@keyframes lightbox-fade-in {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.lightbox-figure {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.lightbox-image {
|
||||
max-height: 84vh;
|
||||
max-width: 90vw;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
background: rgb(255 255 255 / 4%);
|
||||
}
|
||||
|
||||
.lightbox-caption {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 0.75rem;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.lightbox-caption .photo-tile-name {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.lightbox-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.lightbox-close {
|
||||
position: absolute;
|
||||
top: clamp(0.75rem, 2vw, 1.5rem);
|
||||
right: clamp(0.75rem, 2vw, 1.5rem);
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 0;
|
||||
background: rgb(255 255 255 / 12%);
|
||||
color: #fff;
|
||||
font-size: 1.1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.lightbox-close:hover {
|
||||
background: #fff;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.lightbox-nav {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 0;
|
||||
background: rgb(255 255 255 / 12%);
|
||||
color: #fff;
|
||||
font-size: 1.75rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.lightbox-nav:hover {
|
||||
background: #fff;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.lightbox-prev { left: clamp(0.5rem, 2vw, 1.5rem); }
|
||||
.lightbox-next { right: clamp(0.5rem, 2vw, 1.5rem); }
|
||||
|
||||
@media (max-width: 48rem) {
|
||||
.lightbox-nav { width: 2.5rem; height: 2.5rem; font-size: 1.4rem; }
|
||||
}
|
||||
|
||||
.editorial-section dl {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr);
|
||||
@@ -796,7 +1152,9 @@ a {
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.contact-sheet-image {
|
||||
.contact-sheet-image,
|
||||
.photo-tile-image,
|
||||
.photo-tile-overlay {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { AlbumCatalogError, albumCatalog, normalizePage } from "@/modules/albums/catalog";
|
||||
import { PhotoContactSheet } from "@/modules/albums/catalog-content";
|
||||
import { AlbumCatalogError, albumCatalog, PHOTO_PAGE_SIZE } from "@/modules/albums/catalog";
|
||||
import { formatCount, PhotoPagination } from "@/modules/albums/catalog-content";
|
||||
import { filterPhotos, paginatePhotos } from "@/modules/albums/filter";
|
||||
import { PhotoGallery } from "@/modules/albums/photo-gallery";
|
||||
import { loadEditorialDownloadOptions } from "@/modules/downloads/stream";
|
||||
import { lightboxService } from "@/modules/lightbox/service";
|
||||
|
||||
import { requireEditorial } from "../../access";
|
||||
import { PageHeader } from "@/components/ui/page-header";
|
||||
|
||||
// ponytail: fetch the whole album in one request so hoch/quer and jahr filters
|
||||
// can be applied across the full set before paginating, instead of over a
|
||||
// single 60-item page. Ceiling: albums > 1000 photos lose tail items; raise
|
||||
// here (and the Immich size cap) if a sport album ever exceeds it.
|
||||
const ALBUM_FETCH_SIZE = 1000;
|
||||
|
||||
type AlbumPageProps = Readonly<{
|
||||
params: Promise<{ albumId: string }>;
|
||||
searchParams: Promise<{ page?: string | string[]; suche?: string | string[]; format?: string | string[]; jahr?: string | string[] }>;
|
||||
@@ -21,7 +29,6 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps
|
||||
requireEditorial(),
|
||||
]);
|
||||
const query = normalizedQuery(singleValue(rawSearchParams.suche));
|
||||
const currentPage = normalizePage(singleValue(rawSearchParams.page));
|
||||
const format = singleValue(rawSearchParams.format);
|
||||
const jahr = singleValue(rawSearchParams.jahr);
|
||||
const result = await loadAlbumPage({
|
||||
@@ -52,14 +59,23 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps
|
||||
</Link>
|
||||
</PageHeader>
|
||||
<AlbumSearchForm albumId={result.album.id} query={query} format={format} jahr={jahr} />
|
||||
<PhotoContactSheet
|
||||
<p aria-live="polite" className="result-summary" role="status">
|
||||
{formatCount(result.page.total, "Foto")} gefunden
|
||||
</p>
|
||||
<PhotoGallery
|
||||
albumId={result.album.id}
|
||||
albumName={result.album.albumName}
|
||||
currentPage={currentPage}
|
||||
items={result.page.items}
|
||||
downloadOptions={result.downloadOptions}
|
||||
lightboxAssetIds={[...result.lightboxAssetIds]}
|
||||
/>
|
||||
<PhotoPagination
|
||||
albumId={result.album.id}
|
||||
currentPage={result.currentPage}
|
||||
page={result.page}
|
||||
query={query}
|
||||
lightboxAssetIds={result.lightboxAssetIds}
|
||||
format={format}
|
||||
jahr={jahr}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
@@ -70,29 +86,41 @@ function AlbumSearchForm({ albumId, query, format, jahr }: { albumId: string; qu
|
||||
const years = Array.from({ length: 10 }, (_, i) => currentYear - i);
|
||||
|
||||
return (
|
||||
<form action={`/redaktion/alben/${albumId}`} className="global-search-form flex flex-wrap gap-4 items-center mb-8 bg-gray-50 p-4 rounded-xl border border-gray-200" role="search">
|
||||
<div className="flex-grow">
|
||||
<input
|
||||
type="search"
|
||||
name="suche"
|
||||
defaultValue={query}
|
||||
<form
|
||||
action={`/redaktion/alben/${albumId}`}
|
||||
className="album-search-form"
|
||||
role="search"
|
||||
aria-label={`Fotos in diesem Album durchsuchen`}
|
||||
>
|
||||
<div className="album-search-input">
|
||||
<label className="album-search-label" htmlFor="album-search-suche">Suchbegriff</label>
|
||||
<input
|
||||
id="album-search-suche"
|
||||
type="search"
|
||||
name="suche"
|
||||
defaultValue={query}
|
||||
placeholder="Dieses Album durchsuchen..."
|
||||
aria-label="Dieses Album durchsuchen"
|
||||
className="w-full"
|
||||
aria-label="Suchbegriff"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
<select name="format" defaultValue={format || ""} className="px-3 py-2 border border-gray-300 rounded-md">
|
||||
<option value="">Alle Formate</option>
|
||||
<option value="quer">Querformat</option>
|
||||
<option value="hoch">Hochformat</option>
|
||||
</select>
|
||||
<select name="jahr" defaultValue={jahr || ""} className="px-3 py-2 border border-gray-300 rounded-md">
|
||||
<option value="">Alle Jahre</option>
|
||||
{years.map(y => (
|
||||
<option key={y} value={y.toString()}>{y}</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="album-search-filters">
|
||||
<label className="album-search-select">
|
||||
<span>Format</span>
|
||||
<select name="format" defaultValue={format || ""}>
|
||||
<option value="">Alle Formate</option>
|
||||
<option value="quer">Querformat</option>
|
||||
<option value="hoch">Hochformat</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="album-search-select">
|
||||
<span>Jahr</span>
|
||||
<select name="jahr" defaultValue={jahr || ""}>
|
||||
<option value="">Alle Jahre</option>
|
||||
{years.map((y) => (
|
||||
<option key={y} value={y.toString()}>{y}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button type="submit">Suchen</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -118,50 +146,32 @@ async function loadAlbumPage({
|
||||
const albums = await albumCatalog.getVisibleAlbums(editorialId);
|
||||
const album = albums.find((candidate) => candidate.id === albumId);
|
||||
if (!album) {
|
||||
return { album: null, page: null, unavailable: false as const };
|
||||
return { album: null, page: null, currentPage: 1, downloadOptions: undefined, lightboxAssetIds: new Set<string>(), unavailable: false as const };
|
||||
}
|
||||
const results = await albumCatalog.searchVisiblePhotos(editorialId, {
|
||||
requestedAlbumId: album.id,
|
||||
description: query,
|
||||
page,
|
||||
page: 1,
|
||||
size: ALBUM_FETCH_SIZE,
|
||||
});
|
||||
|
||||
// Client-side filtering for format and year
|
||||
if (format || jahr) {
|
||||
results.items = results.items.filter(asset => {
|
||||
let matches = true;
|
||||
|
||||
if (format) {
|
||||
const width = asset.exifInfo?.exifImageWidth ?? 0;
|
||||
const height = asset.exifInfo?.exifImageHeight ?? 0;
|
||||
if (width > 0 && height > 0) {
|
||||
const isLandscape = width >= height;
|
||||
if (format === 'quer' && !isLandscape) matches = false;
|
||||
if (format === 'hoch' && isLandscape) matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jahr && matches) {
|
||||
const dateStr = asset.localDateTime ?? asset.fileCreatedAt;
|
||||
if (!dateStr || !dateStr.startsWith(jahr)) {
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
});
|
||||
}
|
||||
|
||||
// Filter format + jahr across the full album set BEFORE paginating, so the
|
||||
// total, the page slice, and the has-more-pages signal all reflect the
|
||||
// active filters. The old code filtered a single 60-item page client-side,
|
||||
// which silently dropped matching photos and reported the unfiltered total.
|
||||
const filtered = filterPhotos(results.items, { format, jahr });
|
||||
const { result: resultPage, currentPage } = paginatePhotos(filtered, page, PHOTO_PAGE_SIZE);
|
||||
|
||||
const downloadOptions = await loadEditorialDownloadOptions(
|
||||
editorialId,
|
||||
results.items.map((asset) => asset.id),
|
||||
resultPage.items.map((asset) => asset.id),
|
||||
);
|
||||
const lightboxItems = await lightboxService.getLightboxItems(editorialId);
|
||||
const lightboxAssetIds = new Set(lightboxItems.map(i => i.assetId));
|
||||
return { album, page: results, downloadOptions, lightboxAssetIds, unavailable: false as const };
|
||||
const lightboxAssetIds = new Set(lightboxItems.map((i) => i.assetId));
|
||||
return { album, page: resultPage, currentPage, downloadOptions, lightboxAssetIds, unavailable: false as const };
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") {
|
||||
return { album: null, page: null, unavailable: true as const };
|
||||
return { album: null, page: null, currentPage: 1, downloadOptions: undefined, lightboxAssetIds: new Set<string>(), unavailable: true as const };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@@ -192,4 +202,4 @@ function ImmichUnavailable() {
|
||||
</PageHeader>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
|
||||
import { AlbumContactSheet, PhotoContactSheet } from "@/modules/albums/catalog-content";
|
||||
import { AlbumCatalogError, albumCatalog, PHOTO_PAGE_SIZE } from "@/modules/albums/catalog";
|
||||
import { AlbumContactSheet, formatCount } from "@/modules/albums/catalog-content";
|
||||
import { filterPhotos, paginatePhotos, type InAppPage } from "@/modules/albums/filter";
|
||||
import { PhotoGallery } from "@/modules/albums/photo-gallery";
|
||||
import { loadEditorialDownloadOptions } from "@/modules/downloads/stream";
|
||||
import { lightboxService } from "@/modules/lightbox/service";
|
||||
import type { ImmichSearchPage } from "@/modules/immich/types";
|
||||
import Link from "next/link";
|
||||
import { PageHeader } from "@/components/ui/page-header";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -10,6 +11,10 @@ import { Button } from "@/components/ui/button";
|
||||
|
||||
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[] }> }) {
|
||||
const principal = await requireEditorial();
|
||||
const rawSearchParams = await searchParams;
|
||||
@@ -20,37 +25,16 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
if (query) {
|
||||
const results = await albumCatalog.searchVisiblePhotos(principal.editorialId, {
|
||||
description: query,
|
||||
page: singleValue(rawSearchParams.page),
|
||||
page: 1,
|
||||
size: SEARCH_FETCH_SIZE,
|
||||
});
|
||||
|
||||
if (format || jahr) {
|
||||
results.items = results.items.filter(asset => {
|
||||
let matches = true;
|
||||
|
||||
if (format) {
|
||||
const width = asset.exifInfo?.exifImageWidth ?? 0;
|
||||
const height = asset.exifInfo?.exifImageHeight ?? 0;
|
||||
if (width > 0 && height > 0) {
|
||||
const isLandscape = width >= height;
|
||||
if (format === 'quer' && !isLandscape) matches = false;
|
||||
if (format === 'hoch' && isLandscape) matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jahr && matches) {
|
||||
const dateStr = asset.localDateTime ?? asset.fileCreatedAt;
|
||||
if (!dateStr || !dateStr.startsWith(jahr)) {
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
});
|
||||
}
|
||||
const filtered = filterPhotos(results.items, { format, jahr });
|
||||
const { result: page, currentPage } = paginatePhotos(filtered, singleValue(rawSearchParams.page), PHOTO_PAGE_SIZE);
|
||||
|
||||
const downloadOptions = await loadEditorialDownloadOptions(
|
||||
principal.editorialId,
|
||||
results.items.map((asset) => asset.id),
|
||||
page.items.map((asset) => asset.id),
|
||||
);
|
||||
const lightboxItems = await lightboxService.getLightboxItems(principal.editorialId);
|
||||
const lightboxAssetIds = new Set(lightboxItems.map(i => i.assetId));
|
||||
@@ -63,15 +47,17 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
titleId="albums-title"
|
||||
/>
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
<PhotoContactSheet
|
||||
<p aria-live="polite" className="result-summary" role="status">
|
||||
{formatCount(page.total, "Foto")} gefunden
|
||||
</p>
|
||||
<PhotoGallery
|
||||
albumName="Alle Alben"
|
||||
items={page.items}
|
||||
downloadOptions={downloadOptions}
|
||||
page={results}
|
||||
query={query}
|
||||
lightboxAssetIds={[...lightboxAssetIds]}
|
||||
showAlbumName
|
||||
lightboxAssetIds={lightboxAssetIds}
|
||||
/>
|
||||
<GlobalSearchPagination page={results} query={query} />
|
||||
<GlobalSearchPagination currentPage={currentPage} page={page} query={query} format={format} jahr={jahr} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -133,23 +119,32 @@ function GlobalSearchForm({ query, format, jahr }: { query: string; format?: str
|
||||
);
|
||||
}
|
||||
|
||||
function GlobalSearchPagination({ page, query }: { page: ImmichSearchPage; query: string }) {
|
||||
if (page.previousPage === null && page.nextPage === null) {
|
||||
function GlobalSearchPagination({ currentPage, page, query, format, jahr }: { currentPage: number; page: InAppPage; query: string; format?: string; jahr?: string }) {
|
||||
const hasPrev = currentPage > 1;
|
||||
const hasNext = page.nextPage !== null;
|
||||
if (!hasPrev && !hasNext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<nav aria-label="Suchergebnisseiten" className="flex justify-between items-center mt-8 pt-4 border-t border-border text-sm font-medium">
|
||||
{page.previousPage === null ? <div /> : (
|
||||
<Link className="text-primary-600 hover:underline" href={`/redaktion/alben?suche=${encodeURIComponent(query)}&page=${page.previousPage}`}>Vorherige Seite</Link>
|
||||
)}
|
||||
{page.nextPage === null ? <div /> : (
|
||||
<Link className="text-primary-600 hover:underline" href={`/redaktion/alben?suche=${encodeURIComponent(query)}&page=${page.nextPage}`}>Nächste Seite</Link>
|
||||
)}
|
||||
{hasPrev ? (
|
||||
<Link className="text-primary-600 hover:underline" href={globalPageHref(currentPage - 1, query, format, jahr)}>Vorherige Seite</Link>
|
||||
) : <div />}
|
||||
{hasNext ? (
|
||||
<Link className="text-primary-600 hover:underline" href={globalPageHref(currentPage + 1, query, format, jahr)}>Nächste Seite</Link>
|
||||
) : <div />}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function globalPageHref(page: number, query: string, format?: string, jahr?: string): string {
|
||||
const parameters = new URLSearchParams({ suche: query, page: String(page) });
|
||||
if (format) parameters.set("format", format);
|
||||
if (jahr) parameters.set("jahr", jahr);
|
||||
return `/redaktion/alben?${parameters.toString()}`;
|
||||
}
|
||||
|
||||
function singleValue(value: string | string[] | undefined): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user