feat(dashboard): complete frontend redesign for Issue #271
Some checks failed
CI / OCR Service Tests (push) Successful in 29s
CI / Backend Unit Tests (push) Failing after 1m21s
CI / Unit & Component Tests (push) Failing after 2m37s
CI / Unit & Component Tests (pull_request) Failing after 2m27s
CI / OCR Service Tests (pull_request) Successful in 30s
CI / Backend Unit Tests (pull_request) Failing after 1m21s

- +layout.svelte: Upload button in header (authenticated users only)
- +page.server.ts: call /api/dashboard/resume, /pulse, /activity;
  remove deprecated /api/documents/incomplete and /recent-activity
- +page.svelte: 2-col grid layout (main + 320px sidebar), greeting,
  DashboardFamilyPulse + DashboardActivityFeed in sidebar
- DashboardResumeStrip: refactored to use server data (resumeDoc prop),
  SVG thumbnail, progress bar with aria-*, empty state, CTA
- DashboardFamilyPulse: new component — weekly stats from audit_log
- DashboardActivityFeed: new component — activity feed with "für dich" badge
- Update specs for new data shapes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-19 17:44:08 +02:00
parent 99247ed58d
commit 10dbce1c70
10 changed files with 488 additions and 157 deletions

View File

@@ -0,0 +1,81 @@
<script lang="ts">
import * as m from '$lib/paraglide/messages.js';
import type { ActivityFeedItemDTO } from '$lib/generated/api';
interface Props {
feed: ActivityFeedItemDTO[];
}
const { feed }: Props = $props();
const verbMap: Record<string, string> = {
TEXT_SAVED: m.audit_action_text_saved(),
FILE_UPLOADED: m.audit_action_file_uploaded(),
ANNOTATION_CREATED: m.audit_action_annotation_created(),
COMMENT_ADDED: m.audit_action_comment_added(),
MENTION_CREATED: m.audit_action_mention_created()
};
function verb(kind: string): string {
return verbMap[kind] ?? kind;
}
function formatDate(iso: string): string {
return new Intl.DateTimeFormat('de-DE', {
day: 'numeric',
month: 'short',
year: 'numeric'
}).format(new Date(iso));
}
</script>
<section class="rounded-sm border border-line bg-surface p-5">
<div class="mb-3 flex items-center justify-between">
<h2 class="font-sans text-xs font-bold tracking-widest text-ink-3 uppercase">
{m.feed_caption()}
</h2>
<a href="/documents" class="font-sans text-xs text-ink-3 transition-colors hover:text-ink"
>Alle →</a
>
</div>
{#if feed.length > 0}
<ul class="flex flex-col gap-3">
{#each feed as item (item.happenedAt + item.documentId + item.kind)}
<li class="flex items-start gap-3">
{#if item.actor}
<span
class="mt-0.5 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full font-sans text-sm font-bold text-white"
style="background:{item.actor.color}">{item.actor.initials}</span
>
{:else}
<span
class="mt-0.5 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-line font-sans text-sm text-ink-3"
>?</span
>
{/if}
<div class="min-w-0 flex-1">
<p class="font-sans text-sm leading-snug text-ink">
{#if item.actor}
<strong>{item.actor.name ?? item.actor.initials}</strong>
{/if}
{verb(item.kind)}
<a href="/documents/{item.documentId}" class="underline hover:text-accent">
{item.documentTitle}
</a>
{#if item.youMentioned}
<span
class="ml-1.5 inline-block rounded-full border border-accent px-2 py-px font-sans text-[10px] font-bold text-accent"
>
{m.feed_for_you()}
</span>
{/if}
</p>
<p class="mt-0.5 font-sans text-xs text-ink-3">{formatDate(item.happenedAt)}</p>
</div>
</li>
{/each}
</ul>
{/if}
</section>

View File

@@ -0,0 +1,42 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import DashboardActivityFeed from './DashboardActivityFeed.svelte';
import type { components } from '$lib/generated/api';
type ActivityFeedItemDTO = components['schemas']['ActivityFeedItemDTO'];
afterEach(() => {
cleanup();
});
const baseItem: ActivityFeedItemDTO = {
kind: 'TEXT_SAVED',
actor: { initials: 'MR', color: '#7a4f9a', name: 'Max Raddatz' },
documentId: 'doc-1',
documentTitle: 'Brief 1920',
happenedAt: '2026-04-19T10:00:00Z',
youMentioned: false
};
describe('DashboardActivityFeed', () => {
it('renders "für dich" badge when youMentioned is true', async () => {
const item: ActivityFeedItemDTO = { ...baseItem, kind: 'MENTION_CREATED', youMentioned: true };
render(DashboardActivityFeed, { feed: [item] });
const badge = page.getByText('für dich');
await expect.element(badge).toBeInTheDocument();
});
it('does not render "für dich" badge when youMentioned is false', async () => {
render(DashboardActivityFeed, { feed: [baseItem] });
const badge = page.getByText('für dich');
await expect.element(badge).not.toBeInTheDocument();
});
it('renders empty state when feed is empty', async () => {
render(DashboardActivityFeed, { feed: [] });
const section = page.getByText('Kommentare & Aktivität');
await expect.element(section).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,70 @@
<script lang="ts">
import * as m from '$lib/paraglide/messages.js';
import type { DashboardPulseDTO } from '$lib/generated/api';
interface Props {
pulse: DashboardPulseDTO | null;
}
const { pulse }: Props = $props();
</script>
{#if pulse !== null}
<section class="rounded-sm border border-line bg-surface p-5">
<p class="font-sans text-[11px] font-bold tracking-[.12em] text-ink-3 uppercase">
{m.pulse_eyebrow()}
</p>
{#if pulse.pages > 0}
<h2 class="mt-1 font-serif text-[1.375rem] leading-snug text-ink">
Ihr habt <strong>{pulse.pages}</strong> Seiten bearbeitet.
</h2>
{/if}
{#if pulse.yourPages > 0}
<p class="font-serif text-sm text-ink-2">
Du selbst hast {pulse.yourPages} davon bearbeitet.
</p>
{/if}
{#if pulse.contributors.length > 0}
<div class="mt-3 flex items-center gap-1">
<p class="mr-1 font-sans text-[11px] text-ink-3">{m.pulse_contributors()}</p>
{#each pulse.contributors as c (c.initials)}
<span
class="-ml-2 inline-flex h-7 w-7 items-center justify-center rounded-full font-sans text-[11px] font-bold text-white ring-2 ring-white first:ml-0"
style="background:{c.color}"
title={c.name ?? ''}>{c.initials}</span
>
{/each}
</div>
{/if}
<div class="mt-4 grid grid-cols-3 gap-2">
<div class="flex flex-col gap-0.5">
<span class="font-serif text-[1.875rem] leading-none font-bold text-ink"
>{pulse.annotated}</span
>
<span class="flex items-center gap-1 font-sans text-[11px] text-ink-3">
<span class="text-[8px]" style="color:#00c7b1"></span>{m.pulse_transcribed()}
</span>
</div>
<div class="flex flex-col gap-0.5">
<span class="font-serif text-[1.875rem] leading-none font-bold text-ink"
>{pulse.transcribed}</span
>
<span class="flex items-center gap-1 font-sans text-[11px] text-ink-3">
<span class="text-[8px]" style="color:#5a8a6a"></span>{m.pulse_reviewed()}
</span>
</div>
<div class="flex flex-col gap-0.5">
<span class="font-serif text-[1.875rem] leading-none font-bold text-ink"
>{pulse.uploaded}</span
>
<span class="flex items-center gap-1 font-sans text-[11px] text-ink-3">
<span class="text-[8px]" style="color:#3060b0"></span>{m.pulse_uploaded()}
</span>
</div>
</div>
</section>
{/if}

View File

@@ -1,37 +1,115 @@
<script lang="ts">
import { onMount } from 'svelte';
import * as m from '$lib/paraglide/messages.js';
import type { DashboardResumeDTO } from '$lib/generated/api';
interface LastVisited {
id: string;
title: string;
interface Props {
resumeDoc: DashboardResumeDTO | null;
}
let lastVisited = $state<LastVisited | null>(null);
onMount(() => {
try {
const raw = localStorage.getItem('familienarchiv.lastVisited');
if (raw) {
const parsed = JSON.parse(raw) as LastVisited;
if (parsed?.id) {
lastVisited = parsed;
}
}
} catch {
// ignore malformed JSON
}
});
const { resumeDoc }: Props = $props();
</script>
{#if lastVisited}
{#if resumeDoc === null}
<div
data-testid="resume-strip"
class="flex items-center gap-2 rounded-sm border border-line bg-surface px-4 py-3 font-sans text-sm"
data-testid="resume-strip-empty"
class="rounded-sm border border-line bg-surface p-8 text-center"
>
<span class="text-ink-2">{m.dashboard_resume_label()}</span>
<a href="/documents/{lastVisited.id}" class="font-medium text-ink hover:underline">
{lastVisited.title || m.dashboard_resume_fallback()}
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="mx-auto text-ink-3"
>
<rect width="20" height="16" x="2" y="4" rx="2" />
<path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" />
</svg>
<h2 class="mt-3 font-serif text-xl text-ink">{m.dashboard_empty_title()}</h2>
<p class="mt-1 font-sans text-sm text-ink-2">{m.dashboard_empty_body()}</p>
<a
href="/documents"
class="mt-4 inline-block font-sans text-sm font-bold text-accent hover:underline"
>
{m.dashboard_empty_cta()}
</a>
</div>
{:else}
<div data-testid="resume-strip" class="flex gap-4 rounded-sm border border-line bg-surface p-5">
<svg
xmlns="http://www.w3.org/2000/svg"
width="180"
height="246"
viewBox="0 0 180 246"
aria-hidden="true"
class="shrink-0"
>
<defs>
<linearGradient id="parchment" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#f5f0e8" />
<stop offset="100%" stop-color="#ede8d5" />
</linearGradient>
</defs>
<rect width="180" height="246" fill="url(#parchment)" />
<line x1="30" y1="40" x2="150" y2="40" stroke="#b0a898" stroke-width="1" />
<line x1="30" y1="70" x2="150" y2="70" stroke="#b0a898" stroke-width="1" />
<line x1="30" y1="100" x2="150" y2="100" stroke="#b0a898" stroke-width="1" />
<line x1="30" y1="130" x2="150" y2="130" stroke="#b0a898" stroke-width="1" />
<line x1="30" y1="160" x2="150" y2="160" stroke="#b0a898" stroke-width="1" />
</svg>
<div class="flex flex-1 flex-col gap-2">
<p class="flex items-center gap-1.5 font-sans text-xs text-ink-3">
<span class="text-[#A6DAD8]"></span>
{m.dashboard_resume_label()}
·
{m.dashboard_page_of({ page: resumeDoc.page, pages: resumeDoc.pages })}
</p>
<h2 class="font-serif text-[1.75rem] leading-tight text-ink">{resumeDoc.title}</h2>
<p class="font-sans text-sm text-ink-2 italic">{resumeDoc.caption}</p>
<blockquote
class="border-l-[3px] border-accent pl-3 font-serif text-[1.0625rem] leading-relaxed text-ink-2"
>
{resumeDoc.excerpt}
</blockquote>
<div class="mt-auto flex items-center gap-3 pt-2">
<span class="font-sans text-xs font-bold text-ink">{resumeDoc.pct}%</span>
<div
role="progressbar"
aria-valuenow={resumeDoc.pct}
aria-valuemin={0}
aria-valuemax={100}
class="h-1.5 flex-1 overflow-hidden rounded-full bg-line"
>
<div class="h-full rounded-full bg-accent" style="width:{resumeDoc.pct}%"></div>
</div>
{#each resumeDoc.collaborators.slice(0, 3) as collab (collab.initials)}
<span
class="-ml-1 inline-flex h-6 w-6 items-center justify-center rounded-full font-sans text-[10px] font-bold text-white ring-2 ring-white"
style="background:{collab.color}">{collab.initials}</span
>
{/each}
</div>
<div class="mt-1 flex items-center gap-4">
<a
href="/documents/{resumeDoc.documentId}"
class="inline-block rounded-sm bg-accent px-4 py-1.5 font-sans text-sm font-bold text-white transition-opacity hover:opacity-90"
>
{m.dashboard_resume_cta()}
</a>
<a href="/documents" class="font-sans text-xs text-ink-3 transition-colors hover:text-ink">
{m.dashboard_resume_other()}
</a>
</div>
</div>
</div>
{/if}

View File

@@ -3,48 +3,48 @@ import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import DashboardResumeStrip from './DashboardResumeStrip.svelte';
import type { components } from '$lib/generated/api';
type DashboardResumeDTO = components['schemas']['DashboardResumeDTO'];
afterEach(() => {
cleanup();
localStorage.clear();
});
const mockResume: DashboardResumeDTO = {
documentId: 'doc-123',
title: 'Geburtsurkunde 1920',
caption: 'Max Mustermann · 1920-01-01',
excerpt: 'Hiermit wird beurkundet…',
page: 1,
pages: 4,
pct: 75,
collaborators: []
};
describe('DashboardResumeStrip', () => {
it('renders nothing when no last-visited document in localStorage', async () => {
render(DashboardResumeStrip, {});
const strip = page.getByTestId('resume-strip');
await expect.element(strip).not.toBeInTheDocument();
it('renders empty state heading when resumeDoc is null', async () => {
render(DashboardResumeStrip, { resumeDoc: null });
const heading = page.getByRole('heading', { name: /Noch kein Dokument begonnen/i });
await expect.element(heading).toBeInTheDocument();
});
it('shows the strip with link when localStorage has a document', async () => {
localStorage.setItem(
'familienarchiv.lastVisited',
JSON.stringify({ id: 'doc-123', title: 'Geburtsurkunde 1920' })
);
render(DashboardResumeStrip, {});
const strip = page.getByTestId('resume-strip');
await expect.element(strip).toBeInTheDocument();
const link = page.getByRole('link', { name: /Geburtsurkunde 1920/ });
await expect.element(link).toBeInTheDocument();
it('renders progressbar with correct aria-valuenow when resumeDoc is provided', async () => {
render(DashboardResumeStrip, { resumeDoc: mockResume });
const bar = page.getByRole('progressbar');
await expect.element(bar).toBeInTheDocument();
await expect.element(bar).toHaveAttribute('aria-valuenow', '75');
});
it('shows document title when resumeDoc is provided', async () => {
render(DashboardResumeStrip, { resumeDoc: mockResume });
const title = page.getByRole('heading', { name: /Geburtsurkunde 1920/i });
await expect.element(title).toBeInTheDocument();
});
it('links to the document for the CTA', async () => {
render(DashboardResumeStrip, { resumeDoc: mockResume });
const link = page.getByRole('link', { name: /Weitertranskribieren/i });
await expect.element(link).toHaveAttribute('href', '/documents/doc-123');
});
it('uses title fallback text when title is empty', async () => {
localStorage.setItem(
'familienarchiv.lastVisited',
JSON.stringify({ id: 'doc-456', title: '' })
);
render(DashboardResumeStrip, {});
const strip = page.getByTestId('resume-strip');
await expect.element(strip).toBeInTheDocument();
const link = page.getByRole('link');
await expect.element(link).toHaveAttribute('href', '/documents/doc-456');
});
it('renders nothing when localStorage contains malformed JSON', async () => {
localStorage.setItem('familienarchiv.lastVisited', '{not valid json');
render(DashboardResumeStrip, {});
const strip = page.getByTestId('resume-strip');
await expect.element(strip).not.toBeInTheDocument();
});
});