feat(printer): badge print queue, Pi worker, captive-portal setup, admin printing view
- migration 20261018170000: pgmq badge_print/badge_print_dlq, print_stations, token-gated printer RPCs (claim/complete/fail/heartbeat), admin RPCs, welcome_checkin enqueue; badge_print_tests.sql (101 assertions) - apps/printer: Python worker (Playwright render -> brother_ql via pyusb), comitup captive-portal (Wi-Fi + HTTPS endpoint + anon key + token), arm64 image build + idempotent Pi setup/install scripts, 77 pytest - apps/admin: Printing view, station management/DLQ, global printer status pill, Print button on Registrations, standalone print renderer entry (print.html -> dist-print) with bundled fonts - docs: printing.md + architecture/schema/rpcs/tests/admin-app updates, apps/printer/AGENT.md operating manual - e2e: printing.spec.ts Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
0f3720d48a
commit
00c89c1b48
55 files changed
+7406
-29
No files matched your search
@@ -16,12 +16,13 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
|
||||
|---|---|
|
||||
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points + recent activity. |
|
||||
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`). Edit, toggle `is_admin`, set visibility, adjust points. (No QR token here — it lives on the registration.) A general search matches **first name, last name or email address**; the **LinkedIn**, **Visibility** and **Admin** columns each have an Excel-style **multi-select filter** with live counts. |
|
||||
| **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). 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. |
|
||||
| **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. |
|
||||
| **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. |
|
||||
| **Activity** | Tables of check-ins, connections, and feedback (per active event), 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). |
|
||||
| **Printing** | Badge-print control center: printer stations (add / inline **rename** / **revoke**, the `cvp_…` token shown **once** on creation), live station cards with state + staff hints, queue counters (pending / in flight / dead letters / completed), the last completed jobs with **Reprint**, and dead letters with **Requeue** / **Discard**. Backed by `get_print_overview` (polled every 5 s) — see [../backend/printing.md](../backend/printing.md). |
|
||||
| **Settings** | Global LLM endpoint, model and optional API key for feedback summaries. |
|
||||
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
|
||||
| **Interfaces** | Manages the Sessionize sync **sidecar**: status (online / running / last run), a **Run sync** control (event picker + blocking run + result modal), an **Import Excel** control (upload the Sessionize "Sessions and speakers (advanced)" `.xlsx` + a "How to get this file" tooltip), and a **Recent runs** table from `sync_runs`. See [../backend/sidecar.md](../backend/sidecar.md). |
|
||||
@@ -109,11 +110,16 @@ apps/admin/src/
|
||||
│ └─ ToastContext.tsx # transient toasts
|
||||
├─ lib/
|
||||
│ ├─ supabase.ts # createClient (same-origin)
|
||||
│ ├─ api.ts # typed wrapper: reads + writes (contacts, registrations, sponsors, schedule, points)
|
||||
│ └─ types.ts # TS types mirroring the DB
|
||||
│ ├─ api.ts # typed wrapper: reads + writes (contacts, registrations, sponsors, schedule, points, printing)
|
||||
│ ├─ printStatus.tsx # PrintStatusProvider (5 s get_print_overview poll) + pill/hint helpers
|
||||
│ └─ types.ts # TS types mirroring the DB (incl. BadgePrintPayload, PrintOverview)
|
||||
├─ components/
|
||||
│ ├─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, TypeBadge, Toggle, Tooltip, ColumnFilter
|
||||
│ └─ BadgeRender.tsx # shared badge renderer: resolveText/resolveQr, BadgeElementBody, BadgePagePreview, fitScale
|
||||
│ ├─ BadgeRender.tsx # shared badge renderer: resolveText/resolveQr, BadgeElementBody, BadgePagePreview, fitScale
|
||||
│ ├─ badge-render.css # badge rules + bundled @fontsource fonts aliased to the editor family names
|
||||
│ └─ PrinterStatusPill.tsx # always-visible sidebar pill (aggregated station state)
|
||||
├─ print/
|
||||
│ └─ main.tsx # standalone print renderer entry: window.renderBadge(payload, opts)
|
||||
├─ screens/
|
||||
│ └─ Login.tsx # email-only magic-link login (admin-only)
|
||||
└─ views/
|
||||
@@ -143,8 +149,11 @@ key. Everything it can do is allowed by RLS:
|
||||
(admin-only policies).
|
||||
- **RPCs** — `adjust_points` (manual, audited as `admin`), `upsert_contact`,
|
||||
`create_registration`, `set_registration_type`,
|
||||
`set_session_material` (attach uploaded material), and
|
||||
`delete_event_schedule` (clear the active event's slots/sessions). The
|
||||
`set_session_material` (attach uploaded material),
|
||||
`delete_event_schedule` (clear the active event's slots/sessions), and the
|
||||
badge-print admin RPCs (`get_print_overview`, `enqueue_badge_print`,
|
||||
`create_print_station`, `rename_print_station`, `revoke_print_station`,
|
||||
`requeue_dead_badge_print`, `discard_dead_badge_print`). The
|
||||
`reset_registration_qr_token` RPC still exists but the admin UI no longer
|
||||
exposes a token reset. See
|
||||
[../backend/rpcs.md](../backend/rpcs.md).
|
||||
@@ -180,6 +189,62 @@ portal so it is never clipped by the table's `overflow: hidden`. The shared badg
|
||||
renderer lives in `components/BadgeRender.tsx`, used by both the editor and this
|
||||
preview.
|
||||
|
||||
### Printing
|
||||
|
||||
The **Printing** view is the badge-print control center; the queue, stations and
|
||||
RPCs behind it are documented in [../backend/printing.md](../backend/printing.md).
|
||||
|
||||
- **Status pill** — `PrinterStatusPill` sits in the sidebar on **every** view
|
||||
(desktop and mobile): the Pi has no screen, so staff must see the printer
|
||||
state from anywhere. It aggregates the active stations by worst state
|
||||
(error > offline > printing > ready), shows a shortened error / "offline · 2
|
||||
min" text, and a tooltip lists every station (roll, network, last seen, hint).
|
||||
Clicking it navigates to the Printing view.
|
||||
- **Shared poller** — `PrintStatusProvider` (`lib/printStatus.tsx`) calls
|
||||
`get_print_overview` once every **5 s** while the tab is visible (immediate
|
||||
refresh on `visibilitychange`, one request in flight at a time, last data kept
|
||||
on failure). The pill, the Printing view and the Registrations Print button
|
||||
all read from it.
|
||||
- **Stations** — **Add station** opens a modal that shows the generated
|
||||
`cvp_…` token **once** (copy button; it is gone after Done — only its digest
|
||||
is stored). Each card shows the derived state, roll, network, uptime and a
|
||||
plain-language **hint** for staff (e.g. the offline hint points to the open
|
||||
`Convivo-Printer-XXXX` Wi-Fi and http://10.41.0.1). Inline **rename** (Save
|
||||
disabled while blank, Escape cancels) and **Revoke** (confirm; the token stops
|
||||
working immediately).
|
||||
- **Queue** — counters for pending / in flight / dead letters / completed, the
|
||||
last 20 completed jobs each with **Reprint** (calls `enqueue_badge_print` for
|
||||
that registration), and dead letters with **Requeue** / **Discard**.
|
||||
- **Registrations Print** — every row has a **Print** button that queues the
|
||||
badge and toasts the result (when every station is offline the toast says the
|
||||
job is queued and will print when the station returns). With **no badge
|
||||
layout** configured, the button is disabled with the same configure-first
|
||||
tooltip as the Badge preview.
|
||||
|
||||
### Print renderer entry (`print.html`)
|
||||
|
||||
The badge image the Pi prints is produced by the **same React renderer** as the
|
||||
previews, in a standalone bundle: `apps/admin/print.html` +
|
||||
`src/print/main.tsx`, built by `npm run build:print`
|
||||
([`vite.print.config.ts`](../../apps/admin/vite.print.config.ts) →
|
||||
`dist-print/`). The bundle exposes `window.renderBadge(payload, {checkinOrigin})`,
|
||||
which validates the `convivo.badge-print/v1` payload, renders the layout through
|
||||
the shared `BadgePagePreview` at exact millimetre scale, waits for fonts and
|
||||
images, and resolves with the badge's CSS-pixel size. The worker serves the
|
||||
static files in a headless Chromium and screenshots the page — see
|
||||
[../backend/printing.md](../backend/printing.md#7-the-pi-worker-appsprinterworker).
|
||||
Fonts are **bundled** via `@fontsource` in `components/badge-render.css`,
|
||||
aliased to the editor's family names, so rendering never depends on fonts
|
||||
installed on the viewer's OS (admin laptop vs. the Pi).
|
||||
|
||||
Browser coverage (API-mocked, no real printer):
|
||||
|
||||
```bash
|
||||
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- printing.spec.ts --project=chromium
|
||||
```
|
||||
|
||||
See [Badge Print Queue Regression](../backend/tests.md#badge-print-queue-regression).
|
||||
|
||||
### Sponsor lookup (in-place)
|
||||
|
||||
Setting a registration's type to **Sponsor** requires a sponsor lookup. If none
|
||||
|
||||
Reference in new issue
Block a user