feat: batched auto-rules emails, thumbnail fallback, and approve form

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 12:52:01 +02:00
1 parent 4667615ed0
commit 9fdd76645c
8 files changed
+196 -61

No files matched your search

@@ -1,11 +1,19 @@
import Link from "next/link";
import { Plus, Play, Trash2, ArrowLeft } from "lucide-react";
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 { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
import { PageHeader } from "@/components/ui/page-header";
import { applyAutoRulesAction, createAutoRuleAction, deleteAutoRuleAction } from "./actions";
type AutoRulesPageProps = Readonly<{
@@ -28,45 +36,95 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
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>
<div className="space-y-8 max-w-4xl animate-in fade-in slide-in-from-bottom-4 duration-500">
<PageHeader
kicker="Redaktion · Auto-Zuweisungsregeln"
title={`Auto-Regeln für ${editorial.name}`}
/>
<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>
<div className="flex gap-4 mb-6">
<Link
href={`/admin/redaktionen/${editorial.id}/alben`}
className="inline-flex items-center text-sm font-medium text-primary-600 hover:underline"
>
<ArrowLeft className="w-4 h-4 mr-1" />
Zurück zur Album-Verwaltung
</Link>
</div>
<form action={applyAutoRulesAction.bind(null, editorial.id)}>
<button type="submit">Regeln jetzt anwenden</button>
</form>
<div className="grid gap-6">
<Card>
<CardHeader>
<CardTitle>Neue Regel hinzufügen</CardTitle>
<CardDescription>
Alben, deren Name eines der folgenden Schlüsselwörter enthält, werden dieser Redaktion automatisch zugewiesen, sobald sie von Immich synchronisiert werden.
</CardDescription>
</CardHeader>
<CardContent>
<form action={createAutoRuleAction.bind(null, editorial.id)} className="flex gap-4 items-end">
<div className="grid gap-2 flex-grow">
<label className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
Schlüsselwort
</label>
<Input
name="keyword"
type="text"
required
placeholder="z.B. FC Bayern"
className="max-w-md"
/>
</div>
<Button type="submit">
<Plus className="w-4 h-4 mr-2" />
Regel hinzufügen
</Button>
</form>
</CardContent>
</Card>
{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">
{new 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>
<Card>
<CardHeader>
<div className="flex items-start justify-between">
<div>
<CardTitle>Bestehende Regeln</CardTitle>
<CardDescription>
Alle derzeit aktiven automatischen Zuweisungen.
</CardDescription>
</div>
<form action={applyAutoRulesAction.bind(null, editorial.id)}>
<Button type="submit" variant="secondary">
<Play className="w-4 h-4 mr-2" />
Regeln jetzt anwenden
</Button>
</form>
</li>
))}
</ul>
)}
</section>
</div>
</CardHeader>
<CardContent>
{rules.length === 0 ? (
<p className="text-muted-foreground text-sm">Noch keine Auto-Regeln angelegt.</p>
) : (
<ul className="divide-y divide-border border rounded-md">
{rules.map((rule) => (
<li key={rule.id} className="flex items-center justify-between p-4">
<div className="flex flex-col">
<span className="font-medium">{rule.keyword}</span>
<span className="text-xs text-muted-foreground mt-1">
Erstellt am {new Date(rule.createdAt).toLocaleDateString('de-DE')}
</span>
</div>
<form action={deleteAutoRuleAction.bind(null, editorial.id, rule.id)}>
<Button type="submit" variant="ghost" size="sm" className="text-destructive hover:bg-destructive/10 hover:text-destructive">
<Trash2 className="w-4 h-4 mr-2" />
Entfernen
</Button>
</form>
</li>
))}
</ul>
)}
</CardContent>
</Card>
</div>
</div>
);
}
+1
View File
@@ -150,6 +150,7 @@ a {
}
.primary-action {
display: inline-block;
width: fit-content;
margin-top: 2.25rem;
padding: 0.9rem 1.25rem;