From 45ab567355d924a3c0ba5c99893c63d34f40f523 Mon Sep 17 00:00:00 2001 From: Jose Lago Date: Wed, 21 Oct 2026 21:30:31 +0200 Subject: [PATCH] feat(admin): material column + inline material manager in the Sessions view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sessions table gains a Material column (uploaded pill with the clean filename in its tooltip, dash when none) - Expanded session row: shared MaterialPanel (open / download / delete with confirm) plus immediate upload/replace via MaterialUploadRow - Schedule session modal refactored onto the same MaterialPanel; its upload keeps the uploads-on-Save behavior - sessions-view e2e: new test pins the pill, panel buttons, clean filename, unlock hint and replace control Co-authored-by: Stephan Charles Co-authored-by: Amelia Hernandez Co-authored-by: Markus Franz Co-authored-by: Sabrina Hota Co-authored-by: Nilüfer Doğan --- apps/admin/src/components/MaterialPanel.tsx | 145 ++++++++++++++++++++ apps/admin/src/styles.css | 4 + apps/admin/src/views/Schedule.tsx | 80 +---------- apps/admin/src/views/Sessions.tsx | 27 +++- docs/frontend/admin-app.md | 8 +- e2e/tests/sessions-view.spec.ts | 23 +++- 6 files changed, 210 insertions(+), 77 deletions(-) create mode 100644 apps/admin/src/components/MaterialPanel.tsx diff --git a/apps/admin/src/components/MaterialPanel.tsx b/apps/admin/src/components/MaterialPanel.tsx new file mode 100644 index 0000000..6335fc1 --- /dev/null +++ b/apps/admin/src/components/MaterialPanel.tsx @@ -0,0 +1,145 @@ +import { useState } from 'react'; +import { + downloadSessionMaterial, + openSessionMaterial, + removeSessionMaterial, + sessionMaterialName, + uploadSessionMaterial, +} from '../lib/api'; + +/** + * See / open / download / delete a session's material file. Admins bypass the + * attendee time-lock in storage RLS (`can_read_session_material` / + * `can_write_session_material` allow `is_admin()`), so every action works at + * any time — the `unlocksAt` hint is only about when *attendees* get access. + * Shared by the Schedule session modal and the Sessions view's expanded row. + */ +export function MaterialPanel(props: { + session: { id: string; material_path: string | null }; + /** Human-readable unlock moment, e.g. "Thu, Oct 22, 16:30" — null falls back to a generic hint. */ + unlocksAt?: string | null; + /** Notified after a successful delete (reload / close). */ + onChanged: () => void; +}) { + const [busy, setBusy] = useState<'open' | 'download' | 'delete' | null>(null); + const [error, setError] = useState(null); + const path = props.session.material_path; + + if (!path) return

No material uploaded yet.

; + + const name = sessionMaterialName(path); + + async function run(action: 'open' | 'download' | 'delete', fn: () => Promise) { + setBusy(action); + setError(null); + try { + await fn(); + } catch (cause) { + setError(cause instanceof Error ? cause.message : 'Material action failed'); + } finally { + setBusy(null); + } + } + + return ( +
+
+ 📎 {name} +
+
+ + + +
+

+ {props.unlocksAt + ? `Attendees can download it once the session ends (${props.unlocksAt}).` + : 'Attendees can download it once the session ends.'} +

+ {error && ( +

+ {error} +

+ )} +
+ ); +} + +/** + * Immediate (not on-save) upload/replace of a session material — uploads the + * picked file and points the session at it in one go, removing the previous + * object. Used in the Sessions view's expanded row; the Schedule modal keeps + * its upload-on-save behavior instead. + */ +export function MaterialUploadRow(props: { + session: { id: string; material_path: string | null }; + onUploaded: (path: string) => void; +}) { + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + const [uploadedName, setUploadedName] = useState(null); + const previousPath = props.session.material_path; + + async function upload(file: File) { + setBusy(true); + setError(null); + setUploadedName(null); + try { + const path = await uploadSessionMaterial(props.session.id, file, previousPath); + setUploadedName(file.name); + props.onUploaded(path); + } catch (cause) { + setError(cause instanceof Error ? cause.message : 'Upload failed'); + } finally { + setBusy(false); + } + } + + return ( +
+ + {uploadedName && !busy && Uploaded “{uploadedName}”} + {error && ( + + {error} + + )} +
+ ); +} diff --git a/apps/admin/src/styles.css b/apps/admin/src/styles.css index c454d42..5d6ec1c 100644 --- a/apps/admin/src/styles.css +++ b/apps/admin/src/styles.css @@ -354,6 +354,10 @@ tr.row-detail > td { padding: 0; background: var(--surface-2); border-bottom: 1p .session-detail { padding: 16px 18px 20px; } .session-desc { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: var(--text); max-width: 80ch; white-space: pre-wrap; } .detail-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; align-items: start; } +.material-panel { display: flex; flex-direction: column; gap: 8px; } +.material-panel .material-file { font-size: 12.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; } +.material-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } +.material-upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; } .detail-cols h3 { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: #5a5555; margin: 0 0 9px; } .detail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; max-height: 280px; overflow-y: auto; } .detail-list li { display: flex; align-items: center; gap: 9px; font-size: 13px; } diff --git a/apps/admin/src/views/Schedule.tsx b/apps/admin/src/views/Schedule.tsx index 60d3a59..357599e 100644 --- a/apps/admin/src/views/Schedule.tsx +++ b/apps/admin/src/views/Schedule.tsx @@ -2,21 +2,18 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import { supabase } from '../lib/supabase'; import { deleteEventSchedule, - downloadSessionMaterial, getAllContacts, getAllSessionSpeakers, getActiveEvent, getSessions, getSlots, - removeSessionMaterial, - openSessionMaterial, - sessionMaterialName, setSessionSpeakers, uploadSessionMaterial, } from '../lib/api'; import type { Contact, Event, Session, SessionSpeaker, Slot, SlotType } from '../lib/types'; import { useSilentRefresh } from '../lib/useSilentRefresh'; import { useToast } from '../context/ToastContext'; +import { MaterialPanel } from '../components/MaterialPanel'; import { Empty, Modal, Spinner, TypeBadge } from '../components/ui'; const SLOT_TYPES: SlotType[] = ['session', 'service_session']; @@ -470,8 +467,6 @@ function SessionModal({ const [area, setArea] = useState(session?.area ?? ''); const [speakerEmails, setSpeakerEmails] = useState(currentSpeakers); const [material, setMaterial] = useState(null); - const [matBusy, setMatBusy] = useState(false); - const [matError, setMatError] = useState(null); const [busy, setBusy] = useState(false); async function save() { @@ -580,66 +575,11 @@ function SessionModal({ {session && (
- {session.material_path ? ( -
-
📎 {sessionMaterialName(session.material_path)}
-
- - - -
-
- ) : ( - No material uploaded yet. - )} + onSaved('Material removed')} + /> )} - {slot && ( - - {session.material_path - ? `Attendees can download it once the session ends (${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}).` - : `Once uploaded, attendees can download it when the session ends (${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}).`} - - )} - {matError && {matError}}
)} diff --git a/apps/admin/src/views/Sessions.tsx b/apps/admin/src/views/Sessions.tsx index 5640b02..c604d32 100644 --- a/apps/admin/src/views/Sessions.tsx +++ b/apps/admin/src/views/Sessions.tsx @@ -12,6 +12,7 @@ import { getLlmSettings, getSessions, getSlots, + sessionMaterialName, } from '../lib/api'; import type { Checkin, @@ -24,6 +25,7 @@ import type { Slot, } from '../lib/types'; import { Avatar, Empty, Spinner, Tooltip } from '../components/ui'; +import { MaterialPanel, MaterialUploadRow } from '../components/MaterialPanel'; import { useSilentRefresh } from '../lib/useSilentRefresh'; const timeLabel = (slot?: Slot) => (slot ? `${slot.start_time.slice(0, 5)}–${slot.end_time.slice(0, 5)}` : ''); @@ -429,6 +431,7 @@ export function Sessions() { When Session Speakers + Material Check-ins Feedback AI summary @@ -478,6 +481,19 @@ export function Sessions() { )} + + {s.material_path ? ( + + + uploaded + + + ) : ( + + — + + )} + 0 ? 'att-count' : 'muted'}>{att.length} {s.capacity ? / {s.capacity} : null} @@ -507,7 +523,7 @@ export function Sessions() { {open && ( - +
{s.description &&

{s.description}

}
@@ -568,6 +584,15 @@ export function Sessions() {

)} +
+

Material

+ void load(true)} + /> + void load(true)} /> +
diff --git a/docs/frontend/admin-app.md b/docs/frontend/admin-app.md index c33a271..9fb99da 100644 --- a/docs/frontend/admin-app.md +++ b/docs/frontend/admin-app.md @@ -19,7 +19,7 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container | **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. The **checked-in toggle is per-row and optimistic**: it patches that one row (and its points) in place — **no list reload**, so rows never jump or vanish mid-edit (the list is sorted by points) — while a small "Saving…" pulse marks the busy row and only that checkbox is disabled; other rows stay live and a second row can be toggled concurrently. A rejected write rolls the row back to the server's values. Changing the type behaves the same way. The toggle is what grants front-desk eligibility from the console (see [../backend/rpcs.md](../backend/rpcs.md)). Points moved here from Contacts: each point-earning row of the **active** event carries a **Points** button (`adjust_points` always targets the active event's pass, so on other events the button is disabled with an explanatory tooltip), opening a modal that applies the delta, patches the row in place — no reload, no reordering — and lets the silent refresher settle the truth. Rows excluded from points (the `_points_eligible` mirror: type staff, Admin contact, `@appe.at`) show the "no points" marker and no button. | | **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). | | **Schedule** | Slots (with a **type optionset** — `Session` / `Service Session`) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state and `average_feedback`), plus an admin-only **Delete current schedule** action for the active event. | -| **Sessions** | Everything about the **active event's sessions** in one place (nav sits between Schedule and Activity): one row per session with its slot date/time, room / level / area, **speakers**, **check-in count** (with capacity when set), **average rating and response count**, and whether an AI summary is stored, **out of date**, or impossible. Click a row to expand it: description, the full **speaker list**, the **roster of who checked in** (with time and which staff member scanned them), and the stored **AI summary**. A **search** box matches title, room, level, area or speaker, and the **attendee filter** answers "which sessions did this person actually attend?" — the list narrows to those sessions, the header states the count, and the expanded roster highlights that person. **Generate AI Feedback Summary** (see below) summarises every session with feedback in one click. Data comes from `sessions` ⨝ `slots` ⨝ `session_speakers` ⨝ `checkins` ⨝ `feedback`, joined in the client so the numbers match the other views exactly and no new RLS policy is needed. | +| **Sessions** | Everything about the **active event's sessions** in one place (nav sits between Schedule and Activity): one row per session with its slot date/time, room / level / area, **speakers**, **material** (an `uploaded` pill — see [Session material](#session-material)), **check-in count** (with capacity when set), **average rating and response count**, and whether an AI summary is stored, **out of date**, or impossible. Click a row to expand it: description, the full **speaker list**, the **roster of who checked in** (with time and which staff member scanned them), the stored **AI summary**, and the **material manager** (open / download / delete / upload on behalf of the speaker). A **search** box matches title, room, level, area or speaker, and the **attendee filter** answers "which sessions did this person actually attend?" — the list narrows to those sessions, the header states the count, and the expanded roster highlights that person. **Generate AI Feedback Summary** (see below) summarises every session with feedback in one click. Data comes from `sessions` ⨝ `slots` ⨝ `session_speakers` ⨝ `checkins` ⨝ `feedback`, joined in the client so the numbers match the other views exactly and no new RLS policy is needed. | | **Activity** | Tables of check-ins, connections, and feedback (per active event; staff auto-pairings — `connections.auto` — are hidden here too), with manual **Generate AI Summary** controls for the event and individual sessions. | | **Raffle** | Draws eligible attendees one at a time for the active event. Configure the number of picks (default 5), then **Spin** a roulette that decelerates onto a server-chosen winner; repeat until the pick count is reached. Excludes staff/Admin and the leaderboard top 3, and no one can win twice in a run. **New run** clears the current winners. See [../backend/rpcs.md#raffle](../backend/rpcs.md#raffle). | | **Badges** | A **per-event WYSIWYG badge / PDF layout editor** (modelled on pretix's PDF Editor). Pick the event, then design one or more named **layouts** (a **Default** per event, switchable / creatable / deletable). Add **text boxes**, **QR codes** and **images** to a millimetre canvas; drag to move, use the 8 resize handles + rotation handle, **Shift-click to multi-select**, and **press `Del`** to remove. While dragging, **PowerPoint-style smart guides** appear — dashed alignment lines (edges / centres, page and neighbouring items) plus equal-spacing lines — and the element **snaps** to them. A **Word-style align** toolbar (left / center / right, top / middle / bottom) plus **PowerPoint-style** object alignment — align to the **page** or to the **selection**, and **distribute** horizontally / vertically — with the same controls in the properties panel. Text binds to attendee fields (name, email, ticket type, QR token, event name, **company / organizer**, or static) with font, size, line-height, colour, bold/italic, a labelled **Align text in box** section (horizontal left / center / right and vertical top / middle / bottom, inside the element's own frame) and case transform; QR binds to the token / check-in URL / email / name / static. **Undo/redo** (`Ctrl`+`Z` / `Ctrl`+`Y`, also `Ctrl`+`Shift`+`Z`), a **Preview** mode (no handles), a **JSON** view of the layout, and **Save**. Previewed against a real sample registration. See [../backend/rpcs.md#badge-editor](../backend/rpcs.md#badge-editor). | @@ -303,6 +303,12 @@ the attendee time-lock): directly), the previous object is deleted, and a failed DB update rolls the fresh upload back. New sessions upload right after creation. +The **Sessions** view carries the same manager: a **Material** column shows an +`uploaded` pill (clean filename in its tooltip) or a dash, and the expanded +row exposes **Open / Download / Delete** plus an **immediate upload/replace** +input — handy for answering "my file is missing" tickets without hunting the +schedule grid. Both surfaces share `components/MaterialPanel.tsx`. + ### Feedback AI Summaries Configure the complete OpenAI-compatible HTTPS endpoint, model and optional key diff --git a/e2e/tests/sessions-view.spec.ts b/e2e/tests/sessions-view.spec.ts index 4b62156..b33c54b 100644 --- a/e2e/tests/sessions-view.spec.ts +++ b/e2e/tests/sessions-view.spec.ts @@ -29,7 +29,7 @@ type Harness = { }; const mkSessions = () => [ - { id: 's1', event_id: eventId, slot_id: 1, title: 'Opening Keynote', description: 'Why we are here.', room: 'Hall A', capacity: 200, level: 'all', area: 'keynote', average_feedback: null, ai_generated_feedback: null, material_path: null, created_at: 'x' }, + { id: 's1', event_id: eventId, slot_id: 1, title: 'Opening Keynote', description: 'Why we are here.', room: 'Hall A', capacity: 200, level: 'all', area: 'keynote', average_feedback: null, ai_generated_feedback: null, material_path: 'sessions/s1/1730000000000-keynote.pdf', created_at: 'x' }, { id: 's2', event_id: eventId, slot_id: 1, title: 'Power Apps Deep Dive', description: null, room: 'Room 2', capacity: 40, level: '200', area: 'power apps', average_feedback: null, ai_generated_feedback: null, material_path: null, created_at: 'x' }, { id: 's3', event_id: eventId, slot_id: 2, title: 'Copilot Workshop', description: null, room: 'Room 3', capacity: null, level: null, area: null, average_feedback: null, ai_generated_feedback: null, material_path: null, created_at: 'x' }, ]; @@ -164,6 +164,27 @@ test.describe('Sessions view', () => { await page.screenshot({ path: testInfo.outputPath('sessions-desktop.png'), fullPage: true }); }); + test('shows a Material column and lets staff manage the file from the expanded row', async ({ page }) => { + const h: Harness = { feedbackSessions: [], stored: [], summaryDelayMs: 0, failFor: [], summaryRequests: [] }; + await openAdmin(page, h); + + const keynote = sessionRows(page).filter({ hasText: 'Opening Keynote' }).first(); + const workshop = sessionRows(page).filter({ hasText: 'Copilot Workshop' }).first(); + await expect(keynote.getByTestId('material-yes-s1')).toHaveText('uploaded'); + await expect(workshop.getByTestId('material-none-s3')).toBeVisible(); + + await keynote.click(); + const detail = page.locator('tr.row-detail'); + await expect(detail.getByRole('heading', { name: 'Material' })).toBeVisible(); + // The clean filename is shown (storage timestamp prefix stripped). + await expect(detail.getByTestId('material-panel-s1')).toContainText('keynote.pdf'); + await expect(detail.getByRole('button', { name: 'Open' })).toBeVisible(); + await expect(detail.getByRole('button', { name: '⬇ Download' })).toBeVisible(); + await expect(detail.getByRole('button', { name: 'Delete' })).toBeVisible(); + await expect(detail.getByText('Attendees can download it once the session ends (Nov 01, 10:00).')).toBeVisible(); + await expect(detail.getByText('Replace file…')).toBeVisible(); + }); + test('the attendee filter narrows to the sessions that person checked into', async ({ page }) => { const h: Harness = { feedbackSessions: ['s1', 's2'], stored: [], summaryDelayMs: 0, failFor: [], summaryRequests: [] }; await openAdmin(page, h);