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
@@ -333,7 +333,16 @@ export function BillingSelection({
|
||||
</span>
|
||||
</div>
|
||||
{report.status === "final" && (
|
||||
<CancelReportForm reportId={report.id} reportNumber={report.reportNumber} />
|
||||
<>
|
||||
<CancelReportForm reportId={report.id} reportNumber={report.reportNumber} />
|
||||
<a
|
||||
href={`/api/billing-reports/${encodeURIComponent(report.id)}`}
|
||||
className="billing-report-download"
|
||||
download
|
||||
>
|
||||
PDF herunterladen
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { requireAdmin } from "@/modules/auth/principal";
|
||||
import { editorialService } from "@/modules/editorials/service";
|
||||
|
||||
export async function archiveEditorialAction(editorialId: string): Promise<void> {
|
||||
const admin = await requireAdmin(new Headers(await headers()));
|
||||
await editorialService.archiveEditorial({
|
||||
editorialId,
|
||||
adminUserId: admin.userId,
|
||||
});
|
||||
revalidatePath(`/admin/redaktionen/${editorialId}`);
|
||||
revalidatePath('/admin/redaktionen');
|
||||
redirect('/admin/redaktionen');
|
||||
}
|
||||
|
||||
export async function suspendEditorialAction(editorialId: string): Promise<void> {
|
||||
const admin = await requireAdmin(new Headers(await headers()));
|
||||
await editorialService.transitionEditorialStatus({
|
||||
editorialId,
|
||||
from: 'active',
|
||||
to: 'suspended',
|
||||
adminUserId: admin.userId,
|
||||
});
|
||||
revalidatePath(`/admin/redaktionen/${editorialId}`);
|
||||
}
|
||||
|
||||
export async function reactivateEditorialAction(editorialId: string): Promise<void> {
|
||||
const admin = await requireAdmin(new Headers(await headers()));
|
||||
await editorialService.transitionEditorialStatus({
|
||||
editorialId,
|
||||
from: 'suspended',
|
||||
to: 'active',
|
||||
adminUserId: admin.userId,
|
||||
});
|
||||
revalidatePath(`/admin/redaktionen/${editorialId}`);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ const editorial = {
|
||||
loginEmail: "mara@example.com",
|
||||
status: "pending_approval" as const,
|
||||
emailVerifiedAt: null,
|
||||
currentPriceCents: null,
|
||||
currentPriceCents: null, archivedAt: null,
|
||||
};
|
||||
|
||||
test("the editorial detail links admins to its album-assignment page", () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { albumGrantService } from "@/modules/albums/grants";
|
||||
|
||||
import { grantAlbumAction, revokeAlbumAction } from "./actions";
|
||||
import { loadAssignableAlbums } from "./page-content";
|
||||
import { AlbumGrid } from "./AlbumGrid";
|
||||
|
||||
export default async function EditorialAlbumsPage({
|
||||
params,
|
||||
@@ -50,45 +51,19 @@ export default async function EditorialAlbumsPage({
|
||||
</p>
|
||||
<p>
|
||||
<Link href={`/admin/redaktionen/${editorial.id}`}>Zurück zur Redaktion</Link>
|
||||
{" · "}
|
||||
<Link href={`/admin/redaktionen/${editorial.id}/auto-regeln`}>Auto-Zuweisungsregeln verwalten</Link>
|
||||
</p>
|
||||
|
||||
{albumResult.albums.length === 0 ? (
|
||||
<p>Derzeit sind keine zuweisbaren Alben vorhanden.</p>
|
||||
) : (
|
||||
<ul aria-label="Zuweisbare Immich-Alben">
|
||||
{albumResult.albums.map((album) => {
|
||||
const action = album.isGranted ? revokeAlbumAction : grantAlbumAction;
|
||||
return (
|
||||
<li key={album.id}>
|
||||
<article aria-labelledby={`album-${album.id}`}>
|
||||
{album.albumThumbnailAssetId ? (
|
||||
<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" role="img">
|
||||
Kein Cover
|
||||
</div>
|
||||
)}
|
||||
<h2 id={`album-${album.id}`}>{album.albumName}</h2>
|
||||
<p>{album.assetCount} Fotos</p>
|
||||
<p>
|
||||
Status: <strong>{album.isGranted ? "Zugewiesen" : "Nicht zugewiesen"}</strong>
|
||||
</p>
|
||||
<form action={action.bind(null, editorial.id)}>
|
||||
<input name="immichAlbumId" type="hidden" value={album.id} />
|
||||
<button type="submit">
|
||||
{album.isGranted ? "Zuweisung aufheben" : "Album zuweisen"}
|
||||
</button>
|
||||
</form>
|
||||
</article>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<AlbumGrid
|
||||
albums={albumResult.albums}
|
||||
editorialId={editorial.id}
|
||||
grantAction={grantAlbumAction}
|
||||
revokeAction={revokeAlbumAction}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { headers } from "next/headers";
|
||||
|
||||
import { autoRuleService } from "@/modules/albums/auto-rules";
|
||||
import { requireAdmin } from "@/modules/auth/principal";
|
||||
|
||||
async function getAdminPrincipal() {
|
||||
return requireAdmin(new Headers(await headers()));
|
||||
}
|
||||
|
||||
function requiredId(value: unknown): string {
|
||||
if (
|
||||
typeof value !== "string" ||
|
||||
!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)
|
||||
) {
|
||||
throw new Error("INVALID_ID");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export async function createAutoRuleAction(editorialId: string, formData: FormData): Promise<void> {
|
||||
const principal = await getAdminPrincipal();
|
||||
const safeEditorialId = requiredId(editorialId);
|
||||
const keyword = formData.get("keyword");
|
||||
|
||||
if (typeof keyword !== "string" || !keyword.trim()) {
|
||||
throw new Error("INVALID_KEYWORD");
|
||||
}
|
||||
|
||||
await autoRuleService.createRule({
|
||||
editorialId: safeEditorialId,
|
||||
keyword: keyword.trim(),
|
||||
adminUserId: principal.userId,
|
||||
});
|
||||
|
||||
revalidatePath(`/admin/redaktionen/${safeEditorialId}/auto-regeln`);
|
||||
}
|
||||
|
||||
export async function deleteAutoRuleAction(editorialId: string, ruleId: string): Promise<void> {
|
||||
const principal = await getAdminPrincipal();
|
||||
const safeEditorialId = requiredId(editorialId);
|
||||
const safeRuleId = requiredId(ruleId);
|
||||
|
||||
await autoRuleService.deleteRule({
|
||||
ruleId: safeRuleId,
|
||||
adminUserId: principal.userId,
|
||||
});
|
||||
|
||||
revalidatePath(`/admin/redaktionen/${safeEditorialId}/auto-regeln`);
|
||||
}
|
||||
|
||||
export async function applyAutoRulesAction(editorialId: string): Promise<void> {
|
||||
const principal = await getAdminPrincipal();
|
||||
const safeEditorialId = requiredId(editorialId);
|
||||
|
||||
await autoRuleService.applyRules(safeEditorialId, principal.userId);
|
||||
|
||||
revalidatePath(`/admin/redaktionen/${safeEditorialId}/auto-regeln`);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { headers } from "next/headers";
|
||||
import { requireAdmin } from "@/modules/auth/principal";
|
||||
import { autoRuleService } from "@/modules/albums/auto-rules";
|
||||
import { db } from "@/db/client";
|
||||
import { editorialAccounts } from "@/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { applyAutoRulesAction, createAutoRuleAction, deleteAutoRuleAction } from "./actions";
|
||||
|
||||
type AutoRulesPageProps = Readonly<{
|
||||
params: Promise<{ id: string }>;
|
||||
}>;
|
||||
|
||||
export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
|
||||
await requireAdmin(new Headers(await headers()));
|
||||
const { id } = await params;
|
||||
|
||||
const [editorial] = await db
|
||||
.select()
|
||||
.from(editorialAccounts)
|
||||
.where(eq(editorialAccounts.id, id));
|
||||
|
||||
if (!editorial) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const rules = await autoRuleService.listRules(id);
|
||||
|
||||
return (
|
||||
<section className="content-section" aria-labelledby="auto-rules-title">
|
||||
<p className="eyebrow">Redaktion · Auto-Zuweisungsregeln</p>
|
||||
<h1 id="auto-rules-title">Auto-Regeln für {editorial.name}</h1>
|
||||
<p>
|
||||
Alben, deren Name eines der folgenden Schlüsselwörter enthält, werden automatisch zugewiesen.
|
||||
</p>
|
||||
<p>
|
||||
<Link href={`/admin/redaktionen/${editorial.id}/alben`}>Zurück zu Albumrechte</Link>
|
||||
</p>
|
||||
|
||||
<form action={createAutoRuleAction.bind(null, editorial.id)}>
|
||||
<label>
|
||||
<span>Neues Schlüsselwort</span>
|
||||
<input name="keyword" type="text" required placeholder="z.B. FC Bayern" />
|
||||
</label>
|
||||
<button type="submit">Regel hinzufügen</button>
|
||||
</form>
|
||||
|
||||
<form action={applyAutoRulesAction.bind(null, editorial.id)}>
|
||||
<button type="submit">Regeln jetzt anwenden</button>
|
||||
</form>
|
||||
|
||||
{rules.length === 0 ? (
|
||||
<p>Noch keine Auto-Regeln angelegt.</p>
|
||||
) : (
|
||||
<ul className="auto-rules-list">
|
||||
{rules.map((rule) => (
|
||||
<li key={rule.id} className="auto-rule-item">
|
||||
<span className="auto-rule-keyword">{rule.keyword}</span>
|
||||
<span className="auto-rule-date">
|
||||
{rule.createdAt.toLocaleDateString('de-DE')}
|
||||
</span>
|
||||
<form action={deleteAutoRuleAction.bind(null, editorial.id, rule.id)}>
|
||||
<button type="submit" className="auto-rule-delete">Entfernen</button>
|
||||
</form>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ export default async function EditorialDetailPage({
|
||||
status: editorialAccounts.status,
|
||||
emailVerifiedAt: editorialAccounts.emailVerifiedAt,
|
||||
currentPriceCents: editorialAccounts.currentPriceCents,
|
||||
archivedAt: editorialAccounts.archivedAt,
|
||||
})
|
||||
.from(editorialAccounts)
|
||||
.where(eq(editorialAccounts.id, id))
|
||||
|
||||
@@ -13,19 +13,23 @@ export default async function EditorialsPage() {
|
||||
status: editorialAccounts.status,
|
||||
currentPriceCents: editorialAccounts.currentPriceCents,
|
||||
createdAt: editorialAccounts.createdAt,
|
||||
archivedAt: editorialAccounts.archivedAt,
|
||||
})
|
||||
.from(editorialAccounts)
|
||||
.orderBy(desc(editorialAccounts.createdAt));
|
||||
|
||||
const activeEditorials = editorials.filter((e) => !e.archivedAt);
|
||||
const archivedEditorials = editorials.filter((e) => e.archivedAt);
|
||||
|
||||
return (
|
||||
<section className="content-section" aria-labelledby="editorials-title">
|
||||
<p className="eyebrow">Kontoverwaltung</p>
|
||||
<h1 id="editorials-title">Redaktionen</h1>
|
||||
{editorials.length === 0 ? (
|
||||
<p>Noch keine Redaktionen registriert.</p>
|
||||
{activeEditorials.length === 0 ? (
|
||||
<p>Noch keine aktiven Redaktionen registriert.</p>
|
||||
) : (
|
||||
<ul>
|
||||
{editorials.map((editorial) => (
|
||||
{activeEditorials.map((editorial) => (
|
||||
<li key={editorial.id}>
|
||||
<a href={`/admin/redaktionen/${editorial.id}`}>{editorial.name}</a>
|
||||
<p>
|
||||
@@ -38,6 +42,27 @@ export default async function EditorialsPage() {
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{archivedEditorials.length > 0 && (
|
||||
<details className="mt-8">
|
||||
<summary className="cursor-pointer text-sm font-semibold text-gray-500 uppercase tracking-widest">
|
||||
Archivierte Redaktionen ({archivedEditorials.length})
|
||||
</summary>
|
||||
<ul className="mt-4 opacity-75">
|
||||
{archivedEditorials.map((editorial) => (
|
||||
<li key={editorial.id}>
|
||||
<a href={`/admin/redaktionen/${editorial.id}`} className="text-gray-600">
|
||||
{editorial.name}
|
||||
</a>
|
||||
<p className="text-gray-500">
|
||||
{editorial.contactName} · {editorial.loginEmail} · Archiviert am:{" "}
|
||||
{editorial.archivedAt?.toLocaleDateString("de-DE")}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1492,3 +1492,321 @@ a {
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Admin Album Grid */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
.album-grid-search {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 24rem;
|
||||
margin-bottom: 2rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid var(--ink);
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
font-size: 0.875rem;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.album-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
|
||||
gap: 1rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.album-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--paper);
|
||||
border: 1px solid var(--line);
|
||||
transition: background-color 150ms ease;
|
||||
}
|
||||
|
||||
.album-card[data-granted="true"] {
|
||||
border-left: 3px solid var(--ink);
|
||||
}
|
||||
|
||||
.album-card-image-container {
|
||||
aspect-ratio: 4/3;
|
||||
width: 100%;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.album-card-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.album-card-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--contact-sheet);
|
||||
color: var(--metadata);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.album-card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.album-card-name {
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.album-card-count {
|
||||
margin: 0 0 0.75rem 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.album-card-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0 0 1.25rem 0;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.album-card-status::before {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--line);
|
||||
}
|
||||
|
||||
.album-card-status--granted::before {
|
||||
background: var(--ink);
|
||||
}
|
||||
|
||||
.album-card-action {
|
||||
margin-top: auto;
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
font: inherit;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--ink);
|
||||
border-radius: 0;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.album-card-action:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.album-card-action--grant {
|
||||
background: var(--ink);
|
||||
color: var(--paper);
|
||||
}
|
||||
|
||||
.album-card-action--grant:hover:not(:disabled) {
|
||||
background: var(--graphite);
|
||||
}
|
||||
|
||||
.album-card-action--revoke {
|
||||
background: transparent;
|
||||
color: var(--metadata);
|
||||
border-color: var(--line);
|
||||
}
|
||||
|
||||
.album-card-action--revoke:hover:not(:disabled) {
|
||||
border-color: var(--ink);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
@media (max-width: 639px) {
|
||||
.album-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
.billing-report-download {
|
||||
display: inline-block;
|
||||
margin-top: 1rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--line);
|
||||
background: transparent;
|
||||
color: var(--ink);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 650;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.billing-report-download:hover {
|
||||
border-color: var(--ink);
|
||||
background: var(--soft);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Danger Zone & Status Actions */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
.danger-banner {
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid #c44;
|
||||
color: #922;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
padding: 0.5rem 1.25rem;
|
||||
background: var(--ink);
|
||||
color: var(--paper);
|
||||
border: 1px solid var(--ink);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.action-button:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.action-button:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.action-button--warning {
|
||||
background: #b45309;
|
||||
border-color: #b45309;
|
||||
}
|
||||
|
||||
.action-button--danger {
|
||||
background: #b91c1c;
|
||||
border-color: #b91c1c;
|
||||
}
|
||||
|
||||
.danger-zone {
|
||||
margin-top: 3rem;
|
||||
padding-top: 2rem;
|
||||
border-top: 2px solid #b91c1c;
|
||||
}
|
||||
|
||||
.danger-zone h2 {
|
||||
color: #b91c1c;
|
||||
font-size: 1rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
.danger-zone p {
|
||||
color: var(--metadata);
|
||||
font-size: 0.875rem;
|
||||
margin: 0.5rem 0 1rem;
|
||||
}
|
||||
|
||||
.danger-zone label {
|
||||
display: block;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.danger-zone label span {
|
||||
display: block;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--metadata);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.danger-zone-input {
|
||||
width: 100%;
|
||||
max-width: 24rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--line);
|
||||
font-family: inherit;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.danger-zone-input:focus {
|
||||
border-color: #b91c1c;
|
||||
outline: 2px solid #b91c1c;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
/* Global search form on album overview */
|
||||
.global-search-form {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 2rem;
|
||||
max-width: 36rem;
|
||||
}
|
||||
|
||||
.global-search-form input[type="search"] {
|
||||
flex: 1;
|
||||
padding: 0.625rem 0.875rem;
|
||||
border: 1px solid var(--line);
|
||||
font-size: 0.875rem;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.global-search-form button {
|
||||
padding: 0.625rem 1.25rem;
|
||||
background: var(--ink);
|
||||
color: var(--paper);
|
||||
border: 1px solid var(--ink);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.auto-rules-list { list-style: none; padding: 0; margin: 1.5rem 0; }
|
||||
.auto-rule-item {
|
||||
display: flex; align-items: center; gap: 1rem;
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.auto-rule-keyword {
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
}
|
||||
.auto-rule-date {
|
||||
color: var(--muted);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
.auto-rule-delete {
|
||||
background: transparent;
|
||||
border: 1px solid var(--line);
|
||||
padding: 0.25rem 0.75rem;
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
color: var(--metadata);
|
||||
font-family: inherit;
|
||||
}
|
||||
.auto-rule-delete:hover {
|
||||
border-color: var(--ink);
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -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 };
|
||||
|
||||
Reference in new issue
Block a user