feat: add cross-album search, auto-rules, album UI redesign, editorial archiving and pdf download
This commit is contained in:
1 parent
9c0d43b1ec
commit
375e5b8b7d
23 files changed
+1153
-43
No files matched your search
@@ -0,0 +1,117 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import Image from "next/image";
|
||||
|
||||
type AlbumGridProps = {
|
||||
albums: Array<{
|
||||
id: string;
|
||||
albumName: string;
|
||||
albumThumbnailAssetId: string | null;
|
||||
assetCount: number;
|
||||
isGranted: boolean;
|
||||
}>;
|
||||
editorialId: string;
|
||||
grantAction: (editorialId: string, formData: FormData) => Promise<void>;
|
||||
revokeAction: (editorialId: string, formData: FormData) => Promise<void>;
|
||||
};
|
||||
|
||||
function AlbumCard({
|
||||
album,
|
||||
editorialId,
|
||||
grantAction,
|
||||
revokeAction,
|
||||
}: {
|
||||
album: AlbumGridProps["albums"][0];
|
||||
editorialId: string;
|
||||
grantAction: AlbumGridProps["grantAction"];
|
||||
revokeAction: AlbumGridProps["revokeAction"];
|
||||
}) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const handleAction = (formData: FormData) => {
|
||||
startTransition(async () => {
|
||||
if (album.isGranted) {
|
||||
await revokeAction(editorialId, formData);
|
||||
} else {
|
||||
await grantAction(editorialId, formData);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<li className="album-card" data-granted={album.isGranted}>
|
||||
<div className="album-card-image-container">
|
||||
{album.albumThumbnailAssetId ? (
|
||||
<Image
|
||||
className="album-card-image"
|
||||
alt={`Titelbild von ${album.albumName}`}
|
||||
height={120}
|
||||
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
|
||||
width={160}
|
||||
/>
|
||||
) : (
|
||||
<div aria-label="Kein Albumcover verfügbar" className="album-card-placeholder" role="img">
|
||||
Kein Cover
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="album-card-body">
|
||||
<h2 className="album-card-name" id={`album-${album.id}`} title={album.albumName}>
|
||||
{album.albumName}
|
||||
</h2>
|
||||
<p className="album-card-count">{album.assetCount} Fotos</p>
|
||||
<p className={`album-card-status ${album.isGranted ? "album-card-status--granted" : ""}`}>
|
||||
{album.isGranted ? "Zugewiesen" : "Nicht zugewiesen"}
|
||||
</p>
|
||||
<form action={handleAction}>
|
||||
<input name="immichAlbumId" type="hidden" value={album.id} />
|
||||
<button
|
||||
type="submit"
|
||||
className={`album-card-action ${album.isGranted ? "album-card-action--revoke" : "album-card-action--grant"}`}
|
||||
disabled={isPending}
|
||||
>
|
||||
{isPending ? "Lädt..." : album.isGranted ? "Zuweisung aufheben" : "Album zuweisen"}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
export function AlbumGrid({ albums, editorialId, grantAction, revokeAction }: AlbumGridProps) {
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const filteredAlbums = albums.filter((album) =>
|
||||
album.albumName.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<input
|
||||
type="search"
|
||||
className="album-grid-search"
|
||||
placeholder="Alben suchen..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
aria-label="Alben durchsuchen"
|
||||
/>
|
||||
|
||||
{filteredAlbums.length === 0 ? (
|
||||
<p>Keine Alben gefunden.</p>
|
||||
) : (
|
||||
<ul className="album-grid" aria-label="Zuweisbare Immich-Alben">
|
||||
{filteredAlbums.map((album) => (
|
||||
<AlbumCard
|
||||
key={album.id}
|
||||
album={album}
|
||||
editorialId={editorialId}
|
||||
grantAction={grantAction}
|
||||
revokeAction={revokeAction}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user