Compare commits
3
Commits
e90c2f4f8f
...
152388321e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
152388321e | ||
|
|
4d63216167 | ||
|
|
314e9c2457 |
+2
-1
@@ -48,7 +48,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r
|
|||||||
| `local_backend/routers/fees.py` | The venue's online ordering settings (`connect_orders.ordering`: services, hours, slots, ASAP; `reservations`: bookings, food ahead, fire minutes), delivery areas and fee rules, the fee line's name/VAT, and the venue's links (`links.order`, `links.menu` from the cloud's `apps_url`). Everything here travels to the cloud in the menu snapshot (contract C-2) |
|
| `local_backend/routers/fees.py` | The venue's online ordering settings (`connect_orders.ordering`: services, hours, slots, ASAP; `reservations`: bookings, food ahead, fire minutes), delivery areas and fee rules, the fee line's name/VAT, and the venue's links (`links.order`, `links.menu` from the cloud's `apps_url`). Everything here travels to the cloud in the menu snapshot (contract C-2) |
|
||||||
| `local_backend/routers/customer_display.py`, `models/display_look.py`, `terminal/src/apps/customer-display/` | The customer display (3.4, 5.3): the counter POS pushes `POST /api/display/state` (`useDisplay()` in `apps/pos/usePos.js`: the sale cart, the payment dialog's bill, then "paid"); only displays whose `linked_device_id` is that POS get `display.state`. The idle screen is a **look** (`display_looks`: name, `is_default`, config = style, message, theme, QR, pictures as media library ids; looks register their media usage). One look is the venue's default; a display shows the look in its device config `look` (a `ref` to `display_looks`, also set from Settings → Customer display through `PUT /api/display/displays/{id}/look`) or the default. A look's change sends `display.settings` only to the displays showing it. Pictures are served from the library (`full` for image / slides, `card` for the logo). The POS's last state lives in memory |
|
| `local_backend/routers/customer_display.py`, `models/display_look.py`, `terminal/src/apps/customer-display/` | The customer display (3.4, 5.3): the counter POS pushes `POST /api/display/state` (`useDisplay()` in `apps/pos/usePos.js`: the sale cart, the payment dialog's bill, then "paid"); only displays whose `linked_device_id` is that POS get `display.state`. The idle screen is a **look** (`display_looks`: name, `is_default`, config = style, message, theme, QR, pictures as media library ids; looks register their media usage). One look is the venue's default; a display shows the look in its device config `look` (a `ref` to `display_looks`, also set from Settings → Customer display through `PUT /api/display/displays/{id}/look`) or the default. A look's change sends `display.settings` only to the displays showing it. Pictures are served from the library (`full` for image / slides, `card` for the logo). The POS's last state lives in memory |
|
||||||
| `local_backend/routers/media.py`, `services/media.py`, `models/media.py`; manager `src/pages/media/` | The media library (5.1, 5.2): every picture and video once, by sha256, under `/app/data/media/<sha[:2]>/<sha>/` (the untouched original + `thumb` 200 / `card` 600 / `full` 1920 WebP for pictures, AVIF accepted; videos kept as uploaded). Served public by hash at `/api/media/file/<sha>/<variant>` with year-long `immutable` caching (a different file is a different URL; byte ranges for video). The display name is only for people; files on disk are named by the backend. Whoever manages the menu, customer display, signage or menu tablets manages it. **What points at media has a `media_id` column and registers `register_usage(kind, fn)`** (products and categories in `routers/products.py`) so delete is refused (`media.in_use`) while it's used. APIs give `image` = `{id, name, thumb, card, full}` (`services.media.image_of`); a product's `image_url` is its card size. Manager: the Media page (batch upload, details) and `MediaField` (upload on the spot / pick from the library / "Name it after" with `latin()` from `@xenia/i18n`) for any form that takes a picture. The waiter fetches the menu's photos ahead (`services/photoCache.js`; PWA: workbox `xenia-media` cache-first) so they show offline. Upload limits: 20 MB pictures, 200 MB videos; every nginx config sets `client_max_body_size 250m` |
|
| `local_backend/routers/media.py`, `services/media.py`, `models/media.py`; manager `src/pages/media/` | The media library (5.1, 5.2): every picture and video once, by sha256, under `/app/data/media/<sha[:2]>/<sha>/` (the untouched original + `thumb` 200 / `card` 600 / `full` 1920 WebP for pictures, AVIF accepted; videos kept as uploaded). Served public by hash at `/api/media/file/<sha>/<variant>` with year-long `immutable` caching (a different file is a different URL; byte ranges for video). The display name is only for people; files on disk are named by the backend. Whoever manages the menu, customer display, signage or menu tablets manages it. **What points at media has a `media_id` column and registers `register_usage(kind, fn)`** (products and categories in `routers/products.py`) so delete is refused (`media.in_use`) while it's used. APIs give `image` = `{id, name, thumb, card, full}` (`services.media.image_of`); a product's `image_url` is its card size. Manager: the Media page (batch upload, details) and `MediaField` (upload on the spot / pick from the library / "Name it after" with `latin()` from `@xenia/i18n`) for any form that takes a picture. The waiter fetches the menu's photos ahead (`services/photoCache.js`; PWA: workbox `xenia-media` cache-first) so they show offline. Upload limits: 20 MB pictures, 200 MB videos; every nginx config sets `client_max_body_size 250m` |
|
||||||
| `local_backend/routers/signage.py`, `models/signage.py`, `assets/builtin_media/` | Digital signage (5.4a): **playlists** (name, orientation, default transition) of **slides** (kind menu / image / video / text, position, duration, transition, video to its end, on / off, days / hours / dates window, `content` typed per kind in the router: extra fields refused, pictures and videos as media ids, walked by `media_ids()` for the library's usage check). A screen's device config: `playlist` (ref `signage_playlists`), `orientation`, `rotation`; `GET /api/signage/screen` gives it the playlist resolved (enabled slides, media addresses, a `version` hash); changes send `signage.changed` only to the screens playing that playlist. **Built-in pictures:** files in `assets/builtin_media/` are imported at start (`services.media.import_builtin`, `media.builtin`), listed as their own collection, never deleted or renamed. **Menu boards (5.4b):** `services/signage_menu.py` resolves a menu slide (all / whole categories incl. sub-categories, live / single products, minus exclusions; the board's own `category_order` / `product_order`; prices from `pos_cart.unit_prices` of its sales point; customer-facing names); every request that changes the menu (`cloud_sync.menu_changed` paths) also sends `signage.changed` to the screens with a menu board (`main._signage_menu_changed`). **Widgets (5.4c):** `Widget` on text and menu slides (logo, name, date, clock, message, QR, weather; position, size); the screen also gets `venue` = name, the message of the day (`signage.message`, `PUT /api/signage/message` tells every screen) and the weather (`services/weather.py`: Open-Meteo, no key, every 30 min by the signage worker, kept in memory; `null` when there is no place, no internet or it is older than 3 h, so the player hides the widget). **Schedules (5.4d):** `signage_schedules` (entries {playlist, days, hours that may pass midnight, dates, priority} + a fallback); a screen's `schedule` (ref) wins over its `playlist`; `services/signage_schedule.pick` chooses in venue time (highest priority, then dates > days > hours, then the later entry); `/screen` then carries the schedule (with the venue's time zone) and every playlist in it so the player switches offline; `schedule_worker` (30 s) tells a screen when its pick changes. **The player (5.5a):** `terminal/src/apps/signage/` (`logic.js`: the schedule pick ported from Python with the same test cases, slide windows, next slide, frame rotation; `SignageApp.jsx`: the last `/screen` answer in localStorage, every picture / video (≤ 120 MB) as an in-memory blob copy, so it plays with the server down; reads again on `signage.changed`, `device.updated`, a reconnect and every 5 min). Signage is in `QUIET_OFFLINE` (`apps/registry.js`): no offline banner, a small mark. The terminal is plain HTTP (no service worker), so a TV that restarts while the server is down waits for it. Menu boards page by themselves (`boardPages`: rows that fit from the frame's shape, text size, photos / descriptions, title and widget bars; `page_size` overrides) and go round while the slide lasts (at least its pages × `page_seconds`); widgets in `Slides.jsx` (`Widgets`), a widget with nothing to show (no weather, no message) is left out |
|
| `local_backend/routers/signage.py`, `models/signage.py`, `assets/builtin_media/` | Digital signage (5.4a): **playlists** (name, orientation, default transition) of **slides** (kind menu / image / video / text, position, duration, transition, video to its end, on / off, days / hours / dates window, `content` typed per kind in the router: extra fields refused, pictures and videos as media ids, walked by `media_ids()` for the library's usage check). A screen's device config: `playlist` (ref `signage_playlists`), `orientation`, `rotation`; `GET /api/signage/screen` gives it the playlist resolved (enabled slides, media addresses, a `version` hash); changes send `signage.changed` only to the screens playing that playlist. **Built-in pictures:** files in `assets/builtin_media/` are imported at start (`services.media.import_builtin`, `media.builtin`), listed as their own collection, never deleted or renamed. **Menu boards (5.4b):** `services/signage_menu.py` resolves a menu slide (all / whole categories incl. sub-categories, live / single products, minus exclusions; the board's own `category_order` / `product_order`; prices from `pos_cart.unit_prices` of its sales point; customer-facing names); every request that changes the menu (`cloud_sync.menu_changed` paths) also sends `signage.changed` to the screens with a menu board (`main._signage_menu_changed`). **The editor (5.6a):** manager `src/pages/signage/` (Management → Signage): playlists, the timeline (drag / arrows, duplicate, remove), a slide's settings with a live preview (`SlidePreview`), templates (`signageLogic.TEMPLATES`), the orientation warning; `GET /api/signage/venue` and `POST /api/signage/preview/menu` feed the previews. **Widgets (5.4c):** `Widget` on text and menu slides (logo, name, date, clock, message, QR, weather; position, size); the screen also gets `venue` = name, the message of the day (`signage.message`, `PUT /api/signage/message` tells every screen) and the weather (`services/weather.py`: Open-Meteo, no key, every 30 min by the signage worker, kept in memory; `null` when there is no place, no internet or it is older than 3 h, so the player hides the widget). **Schedules (5.4d):** `signage_schedules` (entries {playlist, days, hours that may pass midnight, dates, priority} + a fallback); a screen's `schedule` (ref) wins over its `playlist`; `services/signage_schedule.pick` chooses in venue time (highest priority, then dates > days > hours, then the later entry); `/screen` then carries the schedule (with the venue's time zone) and every playlist in it so the player switches offline; `schedule_worker` (30 s) tells a screen when its pick changes. **The player (5.5a):** `terminal/src/apps/signage/` (the logic and slides moved to `packages/signage` in 5.6a; the schedule pick ported from Python with the same test cases, slide windows, next slide, frame rotation; `SignageApp.jsx`: the last `/screen` answer in localStorage, every picture / video (≤ 120 MB) as an in-memory blob copy, so it plays with the server down; reads again on `signage.changed`, `device.updated`, a reconnect and every 5 min). Signage is in `QUIET_OFFLINE` (`apps/registry.js`): no offline banner, a small mark. The terminal is plain HTTP (no service worker), so a TV that restarts while the server is down waits for it. Menu boards page by themselves (`boardPages`: rows that fit from the frame's shape, text size, photos / descriptions, title and widget bars; `page_size` overrides) and go round while the slide lasts (at least its pages × `page_seconds`); widgets in `Slides.jsx` (`Widgets`), a widget with nothing to show (no weather, no message) is left out |
|
||||||
| `local_backend/routers/phone.py`, `services/caller_id.py` | Caller ID (3.5): the UCM's `GET /api/phone/call-event` is public but **LAN-only in the proxy** (the same `location ~ ^/api/(devices/pair-request|phone/call-event)` block in `nginx-proxy/nginx.conf` and `install.sh`) with an optional `caller_id.secret`; calls are logged (`phone_calls`), matched on the server (Greek number rules) and published as `call_incoming` to users with `caller_id.use` and to the counter screens. There is no public call socket any more |
|
| `local_backend/routers/phone.py`, `services/caller_id.py` | Caller ID (3.5): the UCM's `GET /api/phone/call-event` is public but **LAN-only in the proxy** (the same `location ~ ^/api/(devices/pair-request|phone/call-event)` block in `nginx-proxy/nginx.conf` and `install.sh`) with an optional `caller_id.secret`; calls are logged (`phone_calls`), matched on the server (Greek number rules) and published as `call_incoming` to users with `caller_id.use` and to the counter screens. There is no public call socket any more |
|
||||||
| `local_backend/routers/ws.py` | Real-time event stream (seq + cursor replay) |
|
| `local_backend/routers/ws.py` | Real-time event stream (seq + cursor replay) |
|
||||||
| `waiter_pwa/src/config/server.js` | **Where the backend is**: active venue, `apiBase()`, `wsUrl()`, `assetUrl()`, `storageKey()`, `dbName()`, `deliveryMode()` |
|
| `waiter_pwa/src/config/server.js` | **Where the backend is**: active venue, `apiBase()`, `wsUrl()`, `assetUrl()`, `storageKey()`, `dbName()`, `deliveryMode()` |
|
||||||
@@ -66,6 +66,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r
|
|||||||
| `terminal/` | The terminal app (phase 3): `src/device/DeviceProvider.jsx` (the device's `/me`, who is signed in, the live connection with credentials in the first frame, offline; apps listen with `useLiveEvent`), `src/device/flow.js` (which screen shows when: pairing → sign-in → app / blocked; pure, unit-tested), `src/screens/` (pairing, sign-in per mode, blocked, app + bar), `src/apps/registry.js` (which apps a screen runs, lazy chunks), `src/device/storage.js` (device + session tokens), `src/api/client.js` (`X-Xenia-Device` on every request; 401 / unreachable listeners). The screen follows the device, not the URL. Lint covers all of `src` |
|
| `terminal/` | The terminal app (phase 3): `src/device/DeviceProvider.jsx` (the device's `/me`, who is signed in, the live connection with credentials in the first frame, offline; apps listen with `useLiveEvent`), `src/device/flow.js` (which screen shows when: pairing → sign-in → app / blocked; pure, unit-tested), `src/screens/` (pairing, sign-in per mode, blocked, app + bar), `src/apps/registry.js` (which apps a screen runs, lazy chunks), `src/device/storage.js` (device + session tokens), `src/api/client.js` (`X-Xenia-Device` on every request; 401 / unreachable listeners). The screen follows the device, not the URL. Lint covers all of `src` |
|
||||||
| `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` |
|
| `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` |
|
||||||
| `packages/api/` | Shared HTTP client (`createApiClient`: session/device headers, `err.xenia` codes, the manager-approval retry) and the live WebSocket client with cursor replay (`createLiveClient`, used by the waiter's `useWebSocket`) (CS-18) |
|
| `packages/api/` | Shared HTTP client (`createApiClient`: session/device headers, `err.xenia` codes, the manager-approval retry) and the live WebSocket client with cursor replay (`createLiveClient`, used by the waiter's `useWebSocket`) (CS-18) |
|
||||||
|
| `packages/signage/` | `@xenia/signage` (5.6a): signage slides as the TVs draw them (`SlideView`, `TextSlide`, `MenuSlide`, `Widgets`) and the player's pure logic (schedule pick, slide windows, menu pages; tests in `tests/`), shared by the terminal's player and the manager's previews. Sizes are container units (`cqmin`): a slide needs a parent with `container-type: size` (`frameStyle()`; the manager's `SlidePreview` lays it out at 1920 × 1080 and scales it down, so previews match a TV). Both apps' Tailwind `content` include it |
|
||||||
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (CS-18) |
|
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (CS-18) |
|
||||||
| `packages/i18n/` | Translations (`locales/<lang>/<ns>.json`), language resolution, venue-time / money / number formatting, the comma-or-dot number parser, and the guard `scripts/check-i18n.mjs` (CS-17). Sample: `/i18n-sample` (dev) |
|
| `packages/i18n/` | Translations (`locales/<lang>/<ns>.json`), language resolution, venue-time / money / number formatting, the comma-or-dot number parser, and the guard `scripts/check-i18n.mjs` (CS-17). Sample: `/i18n-sample` (dev) |
|
||||||
| `.dockerignore` | The frontend images build with **`client-services/` as context** (`-f waiter_pwa/Dockerfile .`), so this file decides what Docker sees. The backend still builds from `local_backend/`. |
|
| `.dockerignore` | The frontend images build with **`client-services/` as context** (`-f waiter_pwa/Dockerfile .`), so this file decides what Docker sees. The backend still builds from `local_backend/`. |
|
||||||
|
|||||||
@@ -390,7 +390,11 @@ def _playlist_out(db, p: SignagePlaylist, slides: bool = False) -> dict:
|
|||||||
out = {"id": p.id, "name": p.name, "orientation": p.orientation, "transition": p.transition,
|
out = {"id": p.id, "name": p.name, "orientation": p.orientation, "transition": p.transition,
|
||||||
"slide_count": len(p.slides), "screens": [{"id": d.id, "name": d.name} for d in _screens(db) if d.id in playing]}
|
"slide_count": len(p.slides), "screens": [{"id": d.id, "name": d.name} for d in _screens(db) if d.id in playing]}
|
||||||
if slides:
|
if slides:
|
||||||
|
from services.signage_menu import resolve
|
||||||
out["slides"] = [_slide_out(s) for s in p.slides]
|
out["slides"] = [_slide_out(s) for s in p.slides]
|
||||||
|
for s in out["slides"]:
|
||||||
|
if s["kind"] == "menu":
|
||||||
|
s["menu"] = resolve(db, s["content"]) # the editor's preview (5.6a)
|
||||||
out["media"] = _media_map(db, [i for s in p.slides for i in media_ids(s.content or {})])
|
out["media"] = _media_map(db, [i for s in p.slides for i in media_ids(s.content or {})])
|
||||||
return out
|
return out
|
||||||
|
|
||||||
@@ -811,3 +815,24 @@ async def weather_places(q: str, language: str = "en", user=Depends(require(KEY)
|
|||||||
return await weather.search(q.strip(), language if language in ("en", "el") else "en")
|
return await weather.search(q.strip(), language if language in ("en", "el") else "en")
|
||||||
except Exception:
|
except Exception:
|
||||||
raise XeniaError("signage.weather_offline")
|
raise XeniaError("signage.weather_offline")
|
||||||
|
|
||||||
|
|
||||||
|
# ── for the editor's previews (5.6a) ───────────────────────────────────────────
|
||||||
|
|
||||||
|
class MenuPreviewBody(BaseModel):
|
||||||
|
content: dict = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/venue")
|
||||||
|
def preview_venue(db: Session = Depends(get_db), user=Depends(require(KEY))):
|
||||||
|
"""What the widgets show (the same as a screen gets), for the editor's previews."""
|
||||||
|
from services import weather
|
||||||
|
return {"name": _setting(db, "venue.name") or None, "message": _setting(db, MESSAGE) or None, "weather": weather.current(db)}
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/preview/menu")
|
||||||
|
def preview_menu(body: MenuPreviewBody, db: Session = Depends(get_db), user=Depends(require(KEY))):
|
||||||
|
"""A menu board not saved yet, resolved like a screen gets it (the editor's live preview)."""
|
||||||
|
from services.signage_menu import resolve
|
||||||
|
content = _content(db, "menu", body.content)
|
||||||
|
return {"content": content, "menu": resolve(db, content)}
|
||||||
|
|||||||
@@ -138,3 +138,14 @@ def test_menu_settings_are_checked(client, owner_h, tv):
|
|||||||
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": {"badges": {"x": "new"}}})) == "signage.content_invalid"
|
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": {"badges": {"x": "new"}}})) == "signage.content_invalid"
|
||||||
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": {"badges": {"3": "shiny"}}})) == "signage.content_invalid"
|
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": {"badges": {"3": "shiny"}}})) == "signage.content_invalid"
|
||||||
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": {"columns": 4}})) == "signage.content_invalid"
|
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": {"columns": 4}})) == "signage.content_invalid"
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_editor_previews(client, owner_h, tv, menu):
|
||||||
|
s, _ = board(client, owner_h, tv, category_ids=[menu["cats"]["drinks"]])
|
||||||
|
got = client.get(f"/api/signage/playlists/{tv['playlist']}", headers=owner_h).json()
|
||||||
|
assert names(next(x for x in got["slides"] if x["id"] == s["id"])["menu"]) == [["Drinks", ["Beer"]]] # Wine: delivery only
|
||||||
|
draft = client.post("/api/signage/preview/menu", headers=owner_h, json={"content": {"product_ids": [menu["steak"].id], "sales_point": None}}).json()
|
||||||
|
assert names(draft["menu"]) == [["Grill", ["Steak"]]] and draft["content"]["columns"] == 2
|
||||||
|
assert err(client.post("/api/signage/preview/menu", headers=owner_h, json={"content": {"columns": 9}})) == "signage.content_invalid"
|
||||||
|
client.put("/api/signage/message", headers=owner_h, json={"text": "Hello"})
|
||||||
|
assert client.get("/api/signage/venue", headers=owner_h).json() == {"name": None, "message": "Hello", "weather": None}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ COPY packages/ui/package.json packages/ui/
|
|||||||
COPY packages/i18n/package.json packages/i18n/
|
COPY packages/i18n/package.json packages/i18n/
|
||||||
COPY packages/api/package.json packages/api/
|
COPY packages/api/package.json packages/api/
|
||||||
COPY packages/access/package.json packages/access/
|
COPY packages/access/package.json packages/access/
|
||||||
|
COPY packages/signage/package.json packages/signage/
|
||||||
COPY waiter_pwa/package.json waiter_pwa/
|
COPY waiter_pwa/package.json waiter_pwa/
|
||||||
COPY manager_dashboard/package.json manager_dashboard/
|
COPY manager_dashboard/package.json manager_dashboard/
|
||||||
COPY terminal/package.json terminal/
|
COPY terminal/package.json terminal/
|
||||||
|
|||||||
@@ -8,13 +8,14 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "node --test \"tests/*.test.mjs\"",
|
"test": "node --test \"tests/*.test.mjs\"",
|
||||||
"lint": "eslint eslint.config.js tests src/shell src/live src/pages/platform src/pages/online src/pages/media src/pages/staff src/pages/Settings/sections src/pages/LoginPage.jsx src/components/NotificationBell.jsx src/components/PhoneListener.jsx src/pages/PhonePage.jsx src/store/phoneStore.js src/components/UserMenuButton.jsx src/pages/reports/operations/LogsPanel.jsx src/api/client.js src/store/authStore.js src/main.jsx"
|
"lint": "eslint eslint.config.js tests src/shell src/live src/pages/platform src/pages/online src/pages/media src/pages/signage src/pages/staff src/pages/Settings/sections src/pages/LoginPage.jsx src/components/NotificationBell.jsx src/components/PhoneListener.jsx src/pages/PhonePage.jsx src/store/phoneStore.js src/components/UserMenuButton.jsx src/pages/reports/operations/LogsPanel.jsx src/api/client.js src/store/authStore.js src/main.jsx"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.107.1",
|
"@tanstack/react-query": "^5.107.1",
|
||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import TabsPage from './pages/financials/TabsPage'
|
|||||||
// Management
|
// Management
|
||||||
import ProductsPage from './pages/Management/ProductsPage'
|
import ProductsPage from './pages/Management/ProductsPage'
|
||||||
import MediaPage from './pages/media/MediaPage'
|
import MediaPage from './pages/media/MediaPage'
|
||||||
|
import SignagePage from './pages/signage/SignagePage'
|
||||||
import TablesConfigPage from './pages/Management/TablesConfigPage'
|
import TablesConfigPage from './pages/Management/TablesConfigPage'
|
||||||
import StaffPage from './pages/Management/StaffPage'
|
import StaffPage from './pages/Management/StaffPage'
|
||||||
import SessionsPage from './pages/staff/SessionsPage'
|
import SessionsPage from './pages/staff/SessionsPage'
|
||||||
@@ -163,6 +164,7 @@ export default function App() {
|
|||||||
{/* ── Management (Headquarters) ── */}
|
{/* ── Management (Headquarters) ── */}
|
||||||
<Route path="management/products" element={<ProductsPage />} />
|
<Route path="management/products" element={<ProductsPage />} />
|
||||||
<Route path="management/media" element={<MediaPage />} />
|
<Route path="management/media" element={<MediaPage />} />
|
||||||
|
<Route path="management/signage" element={<SignagePage />} />
|
||||||
<Route path="management/tables" element={<TablesConfigPage />} />
|
<Route path="management/tables" element={<TablesConfigPage />} />
|
||||||
<Route path="management/staff" element={<StaffPage />} />
|
<Route path="management/staff" element={<StaffPage />} />
|
||||||
<Route path="management/sessions" element={<SessionsPage />} />
|
<Route path="management/sessions" element={<SessionsPage />} />
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// A menu board's settings (plan steps 5.6a, 5.6b): its title, look and background. Which products
|
||||||
|
// it lists and in what order: step 5.6b.
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Field, Input, Select } from '@xenia/ui'
|
||||||
|
import { BackgroundField, ColourField } from './SignageFields'
|
||||||
|
import { TextLook } from './SlideEditor'
|
||||||
|
|
||||||
|
export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const c = slide.content || {}
|
||||||
|
const setC = patch => onChange({ ...slide, content: { ...c, ...patch } })
|
||||||
|
return (
|
||||||
|
<div className="grid gap-3" data-testid="signage-menu-editor">
|
||||||
|
<Field label={t('signage.title')}><Input value={c.title || ''} maxLength={120} onChange={e => setC({ title: e.target.value })} data-testid="signage-menu-title" /></Field>
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
|
<Field label={t('signage.columns')}>
|
||||||
|
<Select value={String(c.columns || 2)} onChange={e => setC({ columns: Number(e.target.value) })}
|
||||||
|
options={[1, 2, 3].map(n => ({ value: String(n), label: String(n) }))} data-testid="signage-columns" />
|
||||||
|
</Field>
|
||||||
|
<ColourField label={t('signage.accent')} value={c.accent_colour || '#f59e0b'} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
||||||
|
</div>
|
||||||
|
<TextLook c={c} setC={setC} align={false} />
|
||||||
|
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
||||||
|
misfit={misfit.includes(c.background?.media_id)} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
// One playlist (plan step 5.6a): its name, orientation and default transition; the timeline of
|
||||||
|
// slides (drag or arrows to reorder, duplicate, remove, on / off); a slide's settings with a live
|
||||||
|
// preview at the playlist's shape; new slides blank or from a template; a warning on slides whose
|
||||||
|
// picture or video doesn't fit the orientation.
|
||||||
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { AlertTriangle, ArrowDown, ArrowUp, Copy, Film, GripVertical, ImageIcon, LayoutList, Plus, Trash2, Type } from 'lucide-react'
|
||||||
|
import { errorMessage } from '@xenia/api'
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, Dialog, Field, IconButton, Input, Select, Spinner } from '@xenia/ui'
|
||||||
|
import * as api from './signageApi'
|
||||||
|
import { mediaEntry, mediaLookup, misfits, moved, slideBody, slideFromTemplate, TEMPLATES, totalSeconds, TRANSITIONS, windowParts } from './signageLogic'
|
||||||
|
import SlideEditor from './SlideEditor'
|
||||||
|
import SlidePreview from './SlidePreview'
|
||||||
|
|
||||||
|
const KIND_ICON = { image: ImageIcon, video: Film, text: Type, menu: LayoutList }
|
||||||
|
|
||||||
|
export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [pl, setPl] = useState(null)
|
||||||
|
const [media, setMedia] = useState({})
|
||||||
|
const [venue, setVenue] = useState(null)
|
||||||
|
const [selected, setSelected] = useState(null)
|
||||||
|
const [draft, setDraft] = useState(null)
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
const [adding, setAdding] = useState(false)
|
||||||
|
const [confirmDelete, setConfirmDelete] = useState(false)
|
||||||
|
const [dragFrom, setDragFrom] = useState(null)
|
||||||
|
const [name, setName] = useState('')
|
||||||
|
|
||||||
|
const load = useCallback(async (select) => {
|
||||||
|
try {
|
||||||
|
const p = await api.getPlaylist(playlistId)
|
||||||
|
setPl(p)
|
||||||
|
setName(p.name)
|
||||||
|
setMedia(m => ({ ...m, ...p.media }))
|
||||||
|
const want = p.slides.find(s => s.id === select) || null
|
||||||
|
if (select !== undefined) { setSelected(want?.id ?? null); setDraft(want ? structuredClone(want) : null) }
|
||||||
|
return p
|
||||||
|
} catch (err) { toast.error(errorMessage(err, t)); return null }
|
||||||
|
}, [playlistId, t])
|
||||||
|
useEffect(() => {
|
||||||
|
load().then(p => { if (p?.slides?.length) { setSelected(p.slides[0].id); setDraft(structuredClone(p.slides[0])) } })
|
||||||
|
api.previewVenue().then(setVenue).catch(() => {})
|
||||||
|
}, [load])
|
||||||
|
|
||||||
|
const saved = pl?.slides.find(s => s.id === selected)
|
||||||
|
const dirty = useMemo(() => !!(draft && saved && JSON.stringify(slideBody(draft)) !== JSON.stringify(slideBody(saved))), [draft, saved])
|
||||||
|
// a menu board's draft: its products resolved by the server for the preview
|
||||||
|
const menuKey = draft?.kind === 'menu' ? JSON.stringify(draft.content) : null
|
||||||
|
useEffect(() => {
|
||||||
|
if (!menuKey) return undefined
|
||||||
|
const h = setTimeout(() => {
|
||||||
|
api.previewMenu(JSON.parse(menuKey)).then(r => setDraft(d => (d && d.kind === 'menu' ? { ...d, menu: r.menu } : d))).catch(() => {})
|
||||||
|
}, 400)
|
||||||
|
return () => clearTimeout(h)
|
||||||
|
}, [menuKey])
|
||||||
|
|
||||||
|
const bad = useMemo(() => misfits(pl?.slides, media, pl?.orientation), [pl, media])
|
||||||
|
const draftBad = useMemo(() => (draft ? misfits([draft], media, pl?.orientation)[draft.id] || [] : []), [draft, media, pl])
|
||||||
|
if (!pl) return <div className="flex justify-center p-8"><Spinner /></div>
|
||||||
|
|
||||||
|
const run = async (fn, done, select) => {
|
||||||
|
setBusy(true)
|
||||||
|
try { const r = await fn(); if (done) toast.success(done); await load(select === undefined ? selected : select); onChanged?.(); return r }
|
||||||
|
catch (err) { toast.error(errorMessage(err, t)); return null }
|
||||||
|
finally { setBusy(false) }
|
||||||
|
}
|
||||||
|
const pick = s => {
|
||||||
|
if (dirty && !window.confirm(t('signage.discard'))) return
|
||||||
|
setSelected(s.id)
|
||||||
|
setDraft(structuredClone(s))
|
||||||
|
}
|
||||||
|
const reorder = (from, to) => {
|
||||||
|
const ids = moved(pl.slides.map(s => s.id), from, to)
|
||||||
|
setPl(p => ({ ...p, slides: ids.map(id => p.slides.find(s => s.id === id)) }))
|
||||||
|
run(() => api.orderSlides(pl.id, ids))
|
||||||
|
}
|
||||||
|
const savePlaylist = patch => run(() => api.updatePlaylist(pl.id, patch), t('settings.saved'))
|
||||||
|
const addFrom = async tpl => {
|
||||||
|
setAdding(false)
|
||||||
|
const made = await run(() => api.addSlide(pl.id, slideFromTemplate(tpl, t)), t('signage.added'))
|
||||||
|
if (made) { await load(made.id) }
|
||||||
|
}
|
||||||
|
const total = totalSeconds(pl.slides, media)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid gap-4" data-testid="signage-playlist" data-id={pl.id}>
|
||||||
|
<header className="flex flex-wrap items-end gap-2">
|
||||||
|
<Field label={t('signage.playlistName')} className="flex-1 min-w-[12rem]">
|
||||||
|
<Input value={name} maxLength={80} onChange={e => setName(e.target.value)} data-testid="signage-playlist-name"
|
||||||
|
onBlur={() => name.trim() && name.trim() !== pl.name && savePlaylist({ name: name.trim() })}
|
||||||
|
onKeyDown={e => { if (e.key === 'Enter') e.currentTarget.blur() }} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.orientation')}>
|
||||||
|
<Select value={pl.orientation} onChange={e => savePlaylist({ orientation: e.target.value })} data-testid="signage-orientation"
|
||||||
|
options={['landscape', 'portrait'].map(o => ({ value: o, label: t(`signage.orientations.${o}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.defaultTransition')}>
|
||||||
|
<Select value={pl.transition} onChange={e => savePlaylist({ transition: e.target.value })}
|
||||||
|
options={TRANSITIONS.map(x => ({ value: x, label: t(`signage.transitions.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<IconButton variant="secondary" label={t('signage.duplicatePlaylist')} disabled={busy}
|
||||||
|
onClick={() => run(() => api.duplicatePlaylist(pl.id), t('signage.duplicated')).then(() => onChanged?.())}><Copy size={16} /></IconButton>
|
||||||
|
<IconButton variant="ghost" label={t('fees.delete')} disabled={busy} onClick={() => setConfirmDelete(true)} data-testid="signage-playlist-delete"><Trash2 size={16} /></IconButton>
|
||||||
|
</header>
|
||||||
|
<p className="text-label text-ink-3">
|
||||||
|
{t('signage.summary', { count: pl.slides.length, minutes: Math.floor(total / 60), seconds: String(total % 60).padStart(2, '0') })}
|
||||||
|
{pl.screens.length > 0 && <> · {t('signage.playingOn', { names: pl.screens.map(s => s.name).join(', ') })}</>}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="grid gap-4 lg:grid-cols-[minmax(16rem,22rem)_1fr]">
|
||||||
|
{/* the timeline */}
|
||||||
|
<section className="grid gap-2 content-start" aria-label={t('signage.timeline')}>
|
||||||
|
<ol className="grid gap-2" data-testid="signage-timeline">
|
||||||
|
{pl.slides.map((s, i) => {
|
||||||
|
const Icon = KIND_ICON[s.kind] || ImageIcon
|
||||||
|
const parts = windowParts(s)
|
||||||
|
return (
|
||||||
|
<li key={s.id} draggable onDragStart={() => setDragFrom(i)} onDragOver={e => e.preventDefault()}
|
||||||
|
onDrop={() => { if (dragFrom != null) reorder(dragFrom, i); setDragFrom(null) }}
|
||||||
|
data-testid="signage-slide-card" data-id={s.id} data-kind={s.kind}
|
||||||
|
className={`rounded-card border bg-surface flex gap-2 p-2 items-center cursor-pointer transition-colors duration-fast
|
||||||
|
${s.id === selected ? 'border-accent ring-2 ring-accent' : 'border-line hover:border-line-strong'} ${s.enabled ? '' : 'opacity-60'}`}
|
||||||
|
onClick={() => pick(s)}>
|
||||||
|
<GripVertical size={16} className="text-ink-3 shrink-0 cursor-grab" aria-hidden="true" />
|
||||||
|
<div className="w-24 shrink-0 pointer-events-none">
|
||||||
|
<SlidePreview slide={s} media={mediaLookup(media)} venue={venue} orientation={pl.orientation} testid="signage-card-preview" />
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-0.5 min-w-0 flex-1">
|
||||||
|
<span className="text-label font-medium text-ink truncate flex items-center gap-1.5">
|
||||||
|
<Icon size={14} className="text-ink-2 shrink-0" aria-hidden="true" />{s.name || t(`signage.kinds.${s.kind}`)}
|
||||||
|
{bad[s.id] && <AlertTriangle size={14} className="text-warning-ink" aria-label={t('signage.misfit')} data-testid="signage-card-misfit" />}
|
||||||
|
</span>
|
||||||
|
<span className="text-caption text-ink-3">
|
||||||
|
{s.kind === 'video' && s.video_to_end ? t('signage.toTheEnd') : t('signage.seconds', { count: s.duration_s })}
|
||||||
|
{!s.enabled && <> · {t('signage.off')}</>}
|
||||||
|
{parts.map(p => <span key={p.key}> · {p.key === 'days' ? p.params.days.map(d => t(`signage.weekdays.${d}`)).join(' ') : t(`signage.window.${p.key}`, p.params)}</span>)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col" onClick={e => e.stopPropagation()}>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={i === 0 || busy} onClick={() => reorder(i, i - 1)} data-testid="signage-up"><ArrowUp size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={i === pl.slides.length - 1 || busy} onClick={() => reorder(i, i + 1)} data-testid="signage-down"><ArrowDown size={14} /></IconButton>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col" onClick={e => e.stopPropagation()}>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.duplicateSlide')} disabled={busy}
|
||||||
|
onClick={() => run(() => api.duplicateSlide(s.id), t('signage.duplicated'))}><Copy size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('fees.delete')} disabled={busy} data-testid="signage-slide-delete"
|
||||||
|
onClick={() => window.confirm(t('signage.deleteSlide')) && run(() => api.deleteSlide(s.id), t('signage.removed'), s.id === selected ? null : selected)}><Trash2 size={14} /></IconButton>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</ol>
|
||||||
|
<Button variant="secondary" icon={<Plus size={16} />} onClick={() => setAdding(true)} data-testid="signage-add-slide">{t('signage.addSlide')}</Button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* the slide being edited */}
|
||||||
|
<section className="grid gap-4 content-start">
|
||||||
|
{draft ? <>
|
||||||
|
<SlidePreview slide={draft} media={mediaLookup(media)} venue={venue} orientation={pl.orientation} playing
|
||||||
|
className={pl.orientation === 'portrait' ? 'max-w-xs mx-auto w-full' : 'w-full'} />
|
||||||
|
<SlideEditor slide={draft} onChange={setDraft} media={media} onMedia={item => setMedia(m => ({ ...m, [String(item.id)]: mediaEntry(item) }))}
|
||||||
|
misfit={draftBad} />
|
||||||
|
<div className="flex gap-2 items-center sticky bottom-0 bg-canvas py-2">
|
||||||
|
<Button loading={busy} disabled={!dirty} onClick={() => run(() => api.updateSlide(draft.id, slideBody(draft)), t('settings.saved'))}
|
||||||
|
data-testid="signage-slide-save">{t('fees.save')}</Button>
|
||||||
|
<Button variant="secondary" disabled={!dirty || busy} onClick={() => setDraft(structuredClone(saved))}>{t('signage.undo')}</Button>
|
||||||
|
{dirty && <span className="text-label text-ink-3">{t('display.looks.unsaved')}</span>}
|
||||||
|
</div>
|
||||||
|
</> : <p className="text-body text-ink-3 p-6 text-center">{t(pl.slides.length ? 'signage.pickSlide' : 'signage.noSlides')}</p>}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{adding && (
|
||||||
|
<Dialog open size="lg" title={t('signage.addSlide')} onClose={() => setAdding(false)}
|
||||||
|
footer={<Button variant="secondary" onClick={() => setAdding(false)}>{t('fees.cancel')}</Button>}>
|
||||||
|
<div className="grid gap-4" data-testid="signage-add-dialog">
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<span className="text-label font-medium text-ink-2">{t('signage.blank')}</span>
|
||||||
|
<div className="grid gap-2 grid-cols-2 sm:grid-cols-4">
|
||||||
|
{['image', 'video', 'text', 'menu'].map(k => {
|
||||||
|
const Icon = KIND_ICON[k]
|
||||||
|
return (
|
||||||
|
<button key={k} type="button" onClick={() => addFrom({ key: k, kind: k, content: {} })} data-testid={`signage-new-${k}`}
|
||||||
|
className="p-3 rounded-control border border-line bg-surface-2 hover:bg-surface-3 text-left grid gap-1">
|
||||||
|
<Icon size={18} className="text-ink-2" aria-hidden="true" />
|
||||||
|
<span className="text-label font-medium text-ink">{t(`signage.kinds.${k}`)}</span>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<span className="text-label font-medium text-ink-2">{t('signage.templatesTitle')}</span>
|
||||||
|
<div className="grid gap-3 grid-cols-2 sm:grid-cols-3">
|
||||||
|
{TEMPLATES.map(tpl => {
|
||||||
|
const sample = { id: 0, ...slideFromTemplate(tpl, t), enabled: true, menu: { groups: [] } }
|
||||||
|
return (
|
||||||
|
<button key={tpl.key} type="button" onClick={() => addFrom(tpl)} data-testid={`signage-template-${tpl.key}`}
|
||||||
|
className="rounded-control border border-line bg-surface-2 hover:bg-surface-3 text-left overflow-hidden grid">
|
||||||
|
<div className="pointer-events-none"><SlidePreview slide={sample} media={() => null} venue={venue} orientation={pl.orientation} testid="signage-template-preview" /></div>
|
||||||
|
<span className="text-label font-medium text-ink px-2 py-1.5">{t(`signage.templates.${tpl.key}.name`)}</span>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{confirmDelete && (
|
||||||
|
<Dialog open size="sm" title={t('signage.deletePlaylistTitle', { name: pl.name })} onClose={() => setConfirmDelete(false)}
|
||||||
|
footer={<>
|
||||||
|
<Button variant="secondary" onClick={() => setConfirmDelete(false)}>{t('fees.cancel')}</Button>
|
||||||
|
<Button variant="danger" loading={busy} data-testid="signage-playlist-delete-confirm"
|
||||||
|
onClick={async () => { try { await api.deletePlaylist(pl.id); setConfirmDelete(false); onDeleted?.() } catch (err) { toast.error(errorMessage(err, t)) } }}>{t('fees.delete')}</Button>
|
||||||
|
</>}>
|
||||||
|
<p className="text-body text-ink-2">{t(pl.screens.length ? 'signage.deletePlaylistUsed' : 'signage.deletePlaylistBody', { names: pl.screens.map(s => s.name).join(', ') })}</p>
|
||||||
|
</Dialog>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
// Small editors the signage slide editor is built from (plan step 5.6a): a picture / video from the
|
||||||
|
// library, a colour, a background (colour or photo with darkening).
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { AlertTriangle, Film, ImageIcon, X } from 'lucide-react'
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, IconButton, Select } from '@xenia/ui'
|
||||||
|
import MediaPicker from '../media/MediaPicker'
|
||||||
|
|
||||||
|
/** Pick a picture or a video from the library; `entry` is the media map's item for `value`. */
|
||||||
|
export function MediaPick({ kind = 'image', value, entry, onChange, onRemove, misfit, label, testid }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
return (
|
||||||
|
<div className="grid gap-1.5" data-testid={testid}>
|
||||||
|
{label && <span className="text-label font-medium text-ink-2">{label}</span>}
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="w-24 h-14 rounded-control border border-line bg-surface-3 overflow-hidden flex items-center justify-center shrink-0">
|
||||||
|
{entry?.thumb ? <img src={entry.thumb} alt="" className="w-full h-full object-cover" />
|
||||||
|
: kind === 'video' ? <Film size={20} className="text-ink-3" aria-hidden="true" /> : <ImageIcon size={20} className="text-ink-3" aria-hidden="true" />}
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-1 min-w-0">
|
||||||
|
{entry && <span className="text-label text-ink truncate" title={entry.name}>{entry.name}</span>}
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button size="sm" variant="secondary" onClick={() => setOpen(true)} data-testid={`${testid}-pick`}>
|
||||||
|
{t(value ? 'signage.change' : (kind === 'video' ? 'signage.pickVideo' : 'signage.pickPicture'))}</Button>
|
||||||
|
{value && onRemove && <IconButton size="sm" variant="ghost" label={t('media.removePhoto')} onClick={onRemove}><X size={14} /></IconButton>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{misfit && (
|
||||||
|
<p className="text-caption text-warning-ink flex items-center gap-1.5" data-testid={`${testid}-misfit`}>
|
||||||
|
<AlertTriangle size={14} aria-hidden="true" />{t('signage.misfit')}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{open && <MediaPicker open kind={kind} selectedId={value} onClose={() => setOpen(false)}
|
||||||
|
onPick={item => { onChange(item); setOpen(false) }} />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A colour the venue chooses for its TV (stored as #rrggbb: data, not a theme colour). */
|
||||||
|
export function ColourField({ label, value, onChange, testid }) {
|
||||||
|
return (
|
||||||
|
<label className="grid gap-1.5 text-label font-medium text-ink-2">
|
||||||
|
{label}
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<input type="color" value={value || '#000000'} onChange={e => onChange(e.target.value)} data-testid={testid}
|
||||||
|
className="w-10 h-10 rounded-control border border-line bg-surface cursor-pointer p-0.5" />
|
||||||
|
<span className="text-caption text-ink-3 font-mono">{value}</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A slide's background: a colour, or a photo (built-in or the venue's) with a darkening slider. */
|
||||||
|
export function BackgroundField({ value, onChange, media, onMedia, misfit, testid = 'signage-bg' }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const bg = value || { kind: 'colour', colour: '#111827', media_id: null, dim: 0, fit: 'cover' }
|
||||||
|
const set = patch => onChange({ ...bg, ...patch })
|
||||||
|
return (
|
||||||
|
<fieldset className="grid gap-3 rounded-control border border-line p-3" data-testid={testid}>
|
||||||
|
<legend className="px-1 text-label font-medium text-ink-2">{t('signage.background')}</legend>
|
||||||
|
<Select value={bg.kind} onChange={e => set({ kind: e.target.value })} aria-label={t('signage.background')} data-testid={`${testid}-kind`}
|
||||||
|
options={[{ value: 'colour', label: t('signage.bgColour') }, { value: 'media', label: t('signage.bgPhoto') }]} />
|
||||||
|
{bg.kind === 'colour'
|
||||||
|
? <ColourField label={t('signage.colour')} value={bg.colour} onChange={colour => set({ colour })} testid={`${testid}-colour`} />
|
||||||
|
: <>
|
||||||
|
<MediaPick kind="image" value={bg.media_id} entry={media?.[String(bg.media_id)]} misfit={misfit} testid={`${testid}-photo`}
|
||||||
|
onChange={item => { onMedia(item); set({ media_id: item.id }) }} onRemove={() => set({ media_id: null })} />
|
||||||
|
<label className="grid gap-1 text-label text-ink-2">
|
||||||
|
{t('signage.dim', { value: bg.dim })}
|
||||||
|
<input type="range" min={0} max={80} step={5} value={bg.dim} onChange={e => set({ dim: Number(e.target.value) })} data-testid={`${testid}-dim`} />
|
||||||
|
</label>
|
||||||
|
<Select value={bg.fit} onChange={e => set({ fit: e.target.value })} aria-label={t('signage.fit')}
|
||||||
|
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
|
||||||
|
</>}
|
||||||
|
</fieldset>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// Signage (plan steps 5.6a-c): the venue's playlists for its TVs. Pick one to edit its timeline
|
||||||
|
// and slides; make a new one for a landscape or a portrait screen. Which screen plays what, the
|
||||||
|
// schedules, the message of the day and the weather's place: the other tabs (5.6c).
|
||||||
|
// Backend: /api/signage (routers/signage.py).
|
||||||
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { Monitor, Plus, Smartphone } from 'lucide-react'
|
||||||
|
import { errorMessage } from '@xenia/api'
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, Dialog, EmptyState, Field, Input, Select, Spinner } from '@xenia/ui'
|
||||||
|
import * as api from './signageApi'
|
||||||
|
import PlaylistEditor from './PlaylistEditor'
|
||||||
|
|
||||||
|
export default function SignagePage() {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [list, setList] = useState(null)
|
||||||
|
const [current, setCurrent] = useState(null)
|
||||||
|
const [creating, setCreating] = useState(false)
|
||||||
|
|
||||||
|
const load = useCallback(async () => {
|
||||||
|
try { const l = await api.listPlaylists(); setList(l); return l } catch (err) { toast.error(errorMessage(err, t)); return null }
|
||||||
|
}, [t])
|
||||||
|
useEffect(() => { load().then(l => { if (l?.length) setCurrent(c => c ?? l[0].id) }) }, [load])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-4 md:p-6 grid gap-5 max-w-7xl" data-testid="signage-page">
|
||||||
|
<header className="grid gap-1">
|
||||||
|
<h1 className="text-heading font-semibold text-ink">{t('signage.pageTitle')}</h1>
|
||||||
|
<p className="text-body text-ink-2 max-w-3xl">{t('signage.intro')}</p>
|
||||||
|
</header>
|
||||||
|
{!list ? <div className="flex justify-center p-6"><Spinner /></div> : (
|
||||||
|
<div className="grid gap-5 xl:grid-cols-[14rem_1fr]">
|
||||||
|
<nav className="grid gap-2 content-start" aria-label={t('signage.playlists')}>
|
||||||
|
<span className="text-label font-medium text-ink-2">{t('signage.playlists')}</span>
|
||||||
|
<ul className="grid gap-1.5" data-testid="signage-playlists">
|
||||||
|
{list.map(p => {
|
||||||
|
const Icon = p.orientation === 'portrait' ? Smartphone : Monitor
|
||||||
|
return (
|
||||||
|
<li key={p.id}>
|
||||||
|
<button type="button" onClick={() => setCurrent(p.id)} aria-current={p.id === current ? 'true' : undefined}
|
||||||
|
data-testid="signage-playlist-item" data-name={p.name}
|
||||||
|
className={`w-full text-left px-3 py-2 rounded-control border flex items-center gap-2 transition-colors duration-fast
|
||||||
|
${p.id === current ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface hover:bg-surface-2 text-ink'}`}>
|
||||||
|
<Icon size={16} aria-label={t(`signage.orientations.${p.orientation}`)} />
|
||||||
|
<span className="flex-1 min-w-0 truncate text-label font-medium">{p.name}</span>
|
||||||
|
<span className="text-caption text-ink-3">{p.slide_count}</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
<Button variant="secondary" icon={<Plus size={16} />} onClick={() => setCreating(true)} data-testid="signage-new-playlist">{t('signage.newPlaylist')}</Button>
|
||||||
|
</nav>
|
||||||
|
<main className="min-w-0">
|
||||||
|
{current ? <PlaylistEditor key={current} playlistId={current} onChanged={load}
|
||||||
|
onDeleted={() => load().then(l => setCurrent(l?.[0]?.id ?? null))} />
|
||||||
|
: <EmptyState title={t('signage.noPlaylists')} description={t('signage.noPlaylistsHint')} />}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{creating && <NewPlaylist onClose={() => setCreating(false)} onCreate={async body => {
|
||||||
|
try { const p = await api.createPlaylist(body); setCreating(false); await load(); setCurrent(p.id) } catch (err) { toast.error(errorMessage(err, t)) }
|
||||||
|
}} />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function NewPlaylist({ onClose, onCreate }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [name, setName] = useState('')
|
||||||
|
const [orientation, setOrientation] = useState('landscape')
|
||||||
|
return (
|
||||||
|
<Dialog open size="sm" title={t('signage.newPlaylist')} onClose={onClose}
|
||||||
|
footer={<>
|
||||||
|
<Button variant="secondary" onClick={onClose}>{t('fees.cancel')}</Button>
|
||||||
|
<Button disabled={!name.trim()} onClick={() => onCreate({ name: name.trim(), orientation })} data-testid="signage-create-playlist">{t('display.looks.create')}</Button>
|
||||||
|
</>}>
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<Field label={t('signage.playlistName')}>
|
||||||
|
<Input value={name} autoFocus maxLength={80} onChange={e => setName(e.target.value)} placeholder={t('signage.playlistPlaceholder')} data-testid="signage-new-name" />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.orientation')} hint={t('signage.orientationHint')}>
|
||||||
|
<Select value={orientation} onChange={e => setOrientation(e.target.value)} data-testid="signage-new-orientation"
|
||||||
|
options={['landscape', 'portrait'].map(o => ({ value: o, label: t(`signage.orientations.${o}`) }))} />
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// One slide's settings (plan step 5.6a): its name, time on screen, transition, on / off, when it
|
||||||
|
// may show (days, hours, dates), and what it shows (picture, video, text, menu board's look).
|
||||||
|
// The parent keeps the draft and saves it; the preview follows every change.
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Field, Input, Select, Switch, Textarea } from '@xenia/ui'
|
||||||
|
import { FONT_KEYS, TRANSITIONS } from './signageLogic'
|
||||||
|
import { BackgroundField, ColourField, MediaPick } from './SignageFields'
|
||||||
|
import MenuEditor from './MenuEditor'
|
||||||
|
|
||||||
|
export default function SlideEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const set = patch => onChange({ ...slide, ...patch })
|
||||||
|
const c = slide.content || {}
|
||||||
|
const setC = patch => set({ content: { ...c, ...patch } })
|
||||||
|
const days = slide.days || []
|
||||||
|
const toggleDay = d => set({ days: days.includes(d) ? days.filter(x => x !== d) : [...days, d].sort() })
|
||||||
|
const bad = id => misfit.includes(id)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid gap-5" data-testid="signage-slide-editor" data-kind={slide.kind}>
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
|
<Field label={t('signage.slideName')} hint={t('signage.slideNameHint')}>
|
||||||
|
<Input value={slide.name || ''} maxLength={80} onChange={e => set({ name: e.target.value })} data-testid="signage-slide-name" />
|
||||||
|
</Field>
|
||||||
|
<div className="flex items-end pb-1">
|
||||||
|
<Switch checked={!!slide.enabled} onChange={on => set({ enabled: on })} label={t('signage.enabled')} data-testid="signage-slide-enabled" />
|
||||||
|
</div>
|
||||||
|
{slide.kind === 'video' && (
|
||||||
|
<div className="sm:col-span-2">
|
||||||
|
<Switch checked={!!slide.video_to_end} onChange={on => set({ video_to_end: on })} label={t('signage.videoToEnd')}
|
||||||
|
description={t('signage.videoToEndHint')} data-testid="signage-video-to-end" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!(slide.kind === 'video' && slide.video_to_end) && (
|
||||||
|
<Field label={t('signage.duration')} hint={slide.kind === 'menu' ? t('signage.durationMenuHint') : undefined}>
|
||||||
|
<Input inputMode="numeric" value={String(slide.duration_s ?? 10)} data-testid="signage-duration"
|
||||||
|
onChange={e => set({ duration_s: Math.min(3600, Number(e.target.value.replace(/\D/g, '')) || 0) })} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
<Field label={t('signage.transition')}>
|
||||||
|
<Select value={slide.transition || ''} onChange={e => set({ transition: e.target.value || null })} data-testid="signage-transition"
|
||||||
|
options={[{ value: '', label: t('signage.transitionDefault') }, ...TRANSITIONS.map(x => ({ value: x, label: t(`signage.transitions.${x}`) }))]} />
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset className="grid gap-3 rounded-control border border-line p-3">
|
||||||
|
<legend className="px-1 text-label font-medium text-ink-2">{t('signage.when')}</legend>
|
||||||
|
<p className="text-caption text-ink-3">{t('signage.whenHint')}</p>
|
||||||
|
<div className="flex flex-wrap gap-1.5" role="group" aria-label={t('signage.days')}>
|
||||||
|
{[0, 1, 2, 3, 4, 5, 6].map(d => (
|
||||||
|
<button key={d} type="button" aria-pressed={days.includes(d)} onClick={() => toggleDay(d)} data-testid={`signage-day-${d}`}
|
||||||
|
className={`px-2.5 py-1 rounded-control border text-label transition-colors duration-fast
|
||||||
|
${days.includes(d) ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface-2 text-ink hover:bg-surface-3'}`}>
|
||||||
|
{t(`signage.weekdays.${d}`)}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-3 grid-cols-2">
|
||||||
|
<Field label={t('signage.timeFrom')}><Input type="time" value={slide.time_from || ''} onChange={e => set({ time_from: e.target.value || null })} data-testid="signage-time-from" /></Field>
|
||||||
|
<Field label={t('signage.timeTo')}><Input type="time" value={slide.time_to || ''} onChange={e => set({ time_to: e.target.value || null })} data-testid="signage-time-to" /></Field>
|
||||||
|
<Field label={t('signage.dateFrom')}><Input type="date" value={slide.date_from || ''} onChange={e => set({ date_from: e.target.value || null })} data-testid="signage-date-from" /></Field>
|
||||||
|
<Field label={t('signage.dateTo')}><Input type="date" value={slide.date_to || ''} onChange={e => set({ date_to: e.target.value || null })} data-testid="signage-date-to" /></Field>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
{slide.kind === 'image' && (
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<MediaPick kind="image" label={t('signage.picture')} value={c.media_id} entry={media[String(c.media_id)]} misfit={bad(c.media_id)}
|
||||||
|
onChange={item => { onMedia(item); setC({ media_id: item.id }) }} testid="signage-picture" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
|
<Field label={t('signage.fit')}>
|
||||||
|
<Select value={c.fit || 'cover'} onChange={e => setC({ fit: e.target.value })}
|
||||||
|
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
|
||||||
|
</Field>
|
||||||
|
<ColourField label={t('signage.around')} value={c.background_colour || '#000000'} onChange={v => setC({ background_colour: v })} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{slide.kind === 'video' && (
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<MediaPick kind="video" label={t('signage.video')} value={c.media_id} entry={media[String(c.media_id)]} misfit={bad(c.media_id)}
|
||||||
|
onChange={item => { onMedia(item); setC({ media_id: item.id }) }} testid="signage-video" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
|
<Field label={t('signage.fit')}>
|
||||||
|
<Select value={c.fit || 'cover'} onChange={e => setC({ fit: e.target.value })}
|
||||||
|
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
|
||||||
|
</Field>
|
||||||
|
<div className="flex items-end pb-1"><Switch checked={c.muted !== false} onChange={on => setC({ muted: on })} label={t('signage.muted')} /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{slide.kind === 'text' && (
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<Field label={t('signage.title')}><Input value={c.title || ''} maxLength={120} onChange={e => setC({ title: e.target.value })} data-testid="signage-text-title" /></Field>
|
||||||
|
<Field label={t('signage.body')}><Textarea rows={3} value={c.body || ''} maxLength={1000} onChange={e => setC({ body: e.target.value })} data-testid="signage-text-body" /></Field>
|
||||||
|
<TextLook c={c} setC={setC} />
|
||||||
|
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
||||||
|
misfit={bad(c.background?.media_id)} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{slide.kind === 'menu' && <MenuEditor slide={slide} onChange={onChange} media={media} onMedia={onMedia} misfit={misfit} />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Alignment, font, colour and size of a text slide. */
|
||||||
|
export function TextLook({ c, setC, align = true }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
return (
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
|
{align && <>
|
||||||
|
<Field label={t('signage.align')}>
|
||||||
|
<Select value={c.align || 'center'} onChange={e => setC({ align: e.target.value })}
|
||||||
|
options={['left', 'center', 'right'].map(x => ({ value: x, label: t(`signage.aligns.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.vertical')}>
|
||||||
|
<Select value={c.vertical || 'middle'} onChange={e => setC({ vertical: e.target.value })}
|
||||||
|
options={['top', 'middle', 'bottom'].map(x => ({ value: x, label: t(`signage.verticals.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
</>}
|
||||||
|
<Field label={t('signage.font')}>
|
||||||
|
<Select value={c.font || 'sans'} onChange={e => setC({ font: e.target.value })} data-testid="signage-font"
|
||||||
|
options={FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<ColourField label={t('signage.textColour')} value={c.text_colour || '#ffffff'} onChange={v => setC({ text_colour: v })} testid="signage-text-colour" />
|
||||||
|
<label className="grid gap-1 text-label font-medium text-ink-2 sm:col-span-2">
|
||||||
|
{t('signage.textSize', { value: c.text_size || 100 })}
|
||||||
|
<input type="range" min={50} max={250} step={10} value={c.text_size || 100} onChange={e => setC({ text_size: Number(e.target.value) })} data-testid="signage-text-size" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// A slide drawn exactly as the TV draws it (@xenia/signage), in a box of the playlist's shape
|
||||||
|
// (plan step 5.6a). The slide is laid out on a full-size 1920 × 1080 (or 1080 × 1920) frame and
|
||||||
|
// scaled down to the box, so text, rows and menu pages match a real TV, not a small window.
|
||||||
|
import { useEffect, useRef, useState } from 'react'
|
||||||
|
import { boardPages, SlideView } from '@xenia/signage'
|
||||||
|
|
||||||
|
const LONG = 1920
|
||||||
|
const SHORT = 1080
|
||||||
|
|
||||||
|
export default function SlidePreview({ slide, media, venue, orientation = 'landscape', page = 0, playing = false, className = '', testid = 'signage-preview' }) {
|
||||||
|
const [now, setNow] = useState(() => new Date())
|
||||||
|
const box = useRef(null)
|
||||||
|
const [scale, setScale] = useState(0)
|
||||||
|
useEffect(() => {
|
||||||
|
const id = setInterval(() => setNow(new Date()), 1000)
|
||||||
|
return () => clearInterval(id)
|
||||||
|
}, [])
|
||||||
|
const tall = orientation === 'portrait'
|
||||||
|
const w = tall ? SHORT : LONG
|
||||||
|
const h = tall ? LONG : SHORT
|
||||||
|
useEffect(() => {
|
||||||
|
const el = box.current
|
||||||
|
if (!el) return undefined
|
||||||
|
const measure = () => setScale(el.clientWidth / w)
|
||||||
|
measure()
|
||||||
|
const ro = new ResizeObserver(measure)
|
||||||
|
ro.observe(el)
|
||||||
|
return () => ro.disconnect()
|
||||||
|
}, [w])
|
||||||
|
const pages = slide?.kind === 'menu' ? boardPages(slide, 0, w, h) : null
|
||||||
|
return (
|
||||||
|
<div ref={box} className={`relative overflow-hidden rounded-control bg-black ${className}`} data-testid={testid} data-orientation={orientation}
|
||||||
|
style={{ aspectRatio: tall ? '9 / 16' : '16 / 9' }}>
|
||||||
|
{slide && scale > 0 && (
|
||||||
|
<div style={{ position: 'absolute', top: 0, left: 0, width: w, height: h, transform: `scale(${scale})`, transformOrigin: 'top left', containerType: 'size' }}>
|
||||||
|
<SlideView slide={slide} media={media} venue={venue} now={now} pages={pages} page={Math.min(page, (pages?.length || 1) - 1)} playing={playing} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// The signage editor's API (backend: local_backend/routers/signage.py, plan steps 5.4a-5.6c).
|
||||||
|
import client from '../../api/client'
|
||||||
|
|
||||||
|
const data = r => r.data
|
||||||
|
|
||||||
|
export const listPlaylists = () => client.get('/api/signage/playlists').then(data)
|
||||||
|
export const getPlaylist = id => client.get(`/api/signage/playlists/${id}`).then(data)
|
||||||
|
export const createPlaylist = body => client.post('/api/signage/playlists', body).then(data)
|
||||||
|
export const updatePlaylist = (id, body) => client.put(`/api/signage/playlists/${id}`, body).then(data)
|
||||||
|
export const deletePlaylist = id => client.delete(`/api/signage/playlists/${id}`)
|
||||||
|
export const duplicatePlaylist = id => client.post(`/api/signage/playlists/${id}/duplicate`).then(data)
|
||||||
|
export const orderSlides = (id, slideIds) => client.put(`/api/signage/playlists/${id}/order`, { slide_ids: slideIds }).then(data)
|
||||||
|
|
||||||
|
export const addSlide = (playlistId, body) => client.post(`/api/signage/playlists/${playlistId}/slides`, body).then(data)
|
||||||
|
export const updateSlide = (id, body) => client.put(`/api/signage/slides/${id}`, body).then(data)
|
||||||
|
export const deleteSlide = id => client.delete(`/api/signage/slides/${id}`)
|
||||||
|
export const duplicateSlide = id => client.post(`/api/signage/slides/${id}/duplicate`).then(data)
|
||||||
|
|
||||||
|
export const previewVenue = () => client.get('/api/signage/venue').then(data)
|
||||||
|
export const previewMenu = content => client.post('/api/signage/preview/menu', { content }).then(data)
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
// The signage editor's pure helpers (plan step 5.6a): unit-tested in tests/signage.test.mjs.
|
||||||
|
|
||||||
|
export const KINDS = ['image', 'video', 'text', 'menu']
|
||||||
|
export const TRANSITIONS = ['fade', 'slide', 'zoom', 'none']
|
||||||
|
export const FONT_KEYS = ['sans', 'serif', 'rounded', 'condensed', 'display']
|
||||||
|
|
||||||
|
/** Ready-made slides to start from: { key, kind, slide fields, content }. '@x' texts are filled from
|
||||||
|
* `signage.templates.<key>.<x>` in the manager's language when the slide is made. */
|
||||||
|
export const TEMPLATES = [
|
||||||
|
{ key: 'promo', kind: 'image', duration_s: 8, content: { fit: 'cover' } },
|
||||||
|
{ key: 'announcement', kind: 'text', duration_s: 10, content: {
|
||||||
|
title: '', body: '', align: 'center', vertical: 'middle', font: 'sans', text_colour: '#ffffff', text_size: 100,
|
||||||
|
background: { kind: 'colour', colour: '#1e293b', media_id: null, dim: 0, fit: 'cover' },
|
||||||
|
widgets: [{ kind: 'name', position: 'top-left' }, { kind: 'clock', position: 'top-right' }],
|
||||||
|
} },
|
||||||
|
{ key: 'happyHour', kind: 'text', duration_s: 10, time_from: '17:00', time_to: '19:00', content: {
|
||||||
|
title: '@title', body: '@body', align: 'center', vertical: 'middle', font: 'display', text_colour: '#fde68a', text_size: 120,
|
||||||
|
background: { kind: 'colour', colour: '#7c2d12', media_id: null, dim: 0, fit: 'cover' },
|
||||||
|
} },
|
||||||
|
{ key: 'welcome', kind: 'text', duration_s: 10, content: {
|
||||||
|
title: '@title', body: '', align: 'center', vertical: 'middle', font: 'serif', text_colour: '#ffffff', text_size: 110,
|
||||||
|
background: { kind: 'colour', colour: '#14532d', media_id: null, dim: 0, fit: 'cover' },
|
||||||
|
widgets: [{ kind: 'logo', position: 'top-center', size: 'large' }, { kind: 'message', position: 'bottom-bar' }, { kind: 'date', position: 'bottom-bar' }],
|
||||||
|
} },
|
||||||
|
{ key: 'menuBoard', kind: 'menu', duration_s: 20, content: {
|
||||||
|
title: '@title', select: 'all', group_by_category: true, columns: 2, sales_point: 'in_store', sold_out: 'strike',
|
||||||
|
background: { kind: 'colour', colour: '#111827', media_id: null, dim: 0, fit: 'cover' }, accent_colour: '#f59e0b',
|
||||||
|
widgets: [{ kind: 'clock', position: 'top-right' }, { kind: 'message', position: 'bottom-bar' }],
|
||||||
|
} },
|
||||||
|
{ key: 'video', kind: 'video', video_to_end: true, content: { fit: 'cover', muted: true } },
|
||||||
|
]
|
||||||
|
|
||||||
|
/** The body to create a slide from a template; `t` fills its '@' texts. */
|
||||||
|
export function slideFromTemplate(tpl, t = k => k) {
|
||||||
|
const { key, kind, content, ...fields } = tpl
|
||||||
|
const filled = JSON.parse(JSON.stringify(content || {}), (_, v) =>
|
||||||
|
(typeof v === 'string' && v.startsWith('@') ? t(`signage.templates.${key}.${v.slice(1)}`) : v))
|
||||||
|
return { kind, ...fields, content: filled }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Does a picture / video fit a playlist's orientation? null when its size isn't known. */
|
||||||
|
export function fitsOrientation(media, orientation) {
|
||||||
|
if (!media?.width || !media?.height) return null
|
||||||
|
const wide = media.width >= media.height
|
||||||
|
return orientation === 'portrait' ? !wide || media.width === media.height : wide
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The media ids a slide shows big (its picture / video and its background): what must fit the shape. */
|
||||||
|
export function bigMedia(slide) {
|
||||||
|
const c = slide?.content || {}
|
||||||
|
return [c.media_id, c.background?.kind === 'media' ? c.background.media_id : null].filter(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The slides whose big media doesn't fit the playlist's orientation: { slideId: [mediaId] }. */
|
||||||
|
export function misfits(slides, media, orientation) {
|
||||||
|
const out = {}
|
||||||
|
for (const s of slides || []) {
|
||||||
|
const bad = bigMedia(s).filter(id => fitsOrientation(media?.[String(id)], orientation) === false)
|
||||||
|
if (bad.length) out[s.id] = bad
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A short line about when a slide shows: [{ key, params }] for the timeline card ([] = always). */
|
||||||
|
export function windowParts(slide) {
|
||||||
|
const parts = []
|
||||||
|
if (slide.days?.length && slide.days.length < 7) parts.push({ key: 'days', params: { days: slide.days } })
|
||||||
|
if (slide.time_from || slide.time_to) parts.push({ key: 'hours', params: { from: slide.time_from || '00:00', to: slide.time_to || '24:00' } })
|
||||||
|
if (slide.date_from || slide.date_to) parts.push({ key: 'dates', params: { from: slide.date_from || '…', to: slide.date_to || '…' } })
|
||||||
|
return parts
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The playlist's total time for one round (videos to their end count by their length if known). */
|
||||||
|
export function totalSeconds(slides, media) {
|
||||||
|
let total = 0
|
||||||
|
for (const s of slides || []) {
|
||||||
|
if (!s.enabled) continue
|
||||||
|
if (s.kind === 'video' && s.video_to_end) {
|
||||||
|
const ms = media?.[String(s.content?.media_id)]?.duration_ms
|
||||||
|
total += ms ? Math.round(ms / 1000) : s.duration_s || 10
|
||||||
|
} else total += s.duration_s || 10
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Move the item at `from` to `to` in a copy of `list`. */
|
||||||
|
export function moved(list, from, to) {
|
||||||
|
const out = [...list]
|
||||||
|
if (from === to || from < 0 || to < 0 || from >= out.length || to >= out.length) return out
|
||||||
|
const [x] = out.splice(from, 1)
|
||||||
|
out.splice(to, 0, x)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The fields of a slide that the editor sends back (PUT /api/signage/slides/{id}). */
|
||||||
|
export function slideBody(s) {
|
||||||
|
return {
|
||||||
|
name: s.name || null, duration_s: s.duration_s, transition: s.transition || null, video_to_end: !!s.video_to_end, enabled: !!s.enabled,
|
||||||
|
days: s.days || [], time_from: s.time_from || null, time_to: s.time_to || null, date_from: s.date_from || null, date_to: s.date_to || null,
|
||||||
|
content: s.content || {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A library item as the slide views need it (the same shape as the playlist's media map). */
|
||||||
|
export function mediaEntry(item) {
|
||||||
|
const u = item.urls || {}
|
||||||
|
return { id: item.id, kind: item.kind, name: item.name, width: item.width, height: item.height, duration_ms: item.duration_ms,
|
||||||
|
url: u.full || u.original, thumb: u.thumb, builtin: !!item.builtin }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** media(id) for the slide views: the playlist's media map (+ what the editor just picked). */
|
||||||
|
export function mediaLookup(map) {
|
||||||
|
return id => {
|
||||||
|
const m = map?.[String(id)]
|
||||||
|
return m ? { ...m, src: m.url } : null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
BookUser, Users, Receipt, CreditCard,
|
BookUser, Users, Receipt, CreditCard,
|
||||||
Package, TableProperties, UserCog, CalendarDays, Trash2, Boxes,
|
Package, TableProperties, UserCog, CalendarDays, Trash2, Boxes,
|
||||||
BarChart2, TrendingUp, Users2, ShoppingCart, Tag, Activity, Printer, ConciergeBell, FileText,
|
BarChart2, TrendingUp, Users2, ShoppingCart, Tag, Activity, Printer, ConciergeBell, FileText,
|
||||||
AppWindow, Settings, CookingPot, Truck, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, QrCode, Images,
|
AppWindow, Settings, CookingPot, Truck, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, QrCode, Images, Tv,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
|
|
||||||
const DASH = 'core.dashboard.access'
|
const DASH = 'core.dashboard.access'
|
||||||
@@ -62,6 +62,7 @@ export const NAV = [
|
|||||||
children: [
|
children: [
|
||||||
{ to: '/management/products', icon: Package, label: 'nav.products', module: 'catalog', perm: 'catalog.menu.manage' },
|
{ to: '/management/products', icon: Package, label: 'nav.products', module: 'catalog', perm: 'catalog.menu.manage' },
|
||||||
{ to: '/management/media', icon: Images, label: 'nav.media', module: 'core', anyPerm: MEDIA },
|
{ to: '/management/media', icon: Images, label: 'nav.media', module: 'core', anyPerm: MEDIA },
|
||||||
|
{ to: '/management/signage', icon: Tv, label: 'nav.signage', module: 'signage', perm: 'signage.manage' },
|
||||||
{ to: '/management/tables', icon: TableProperties, label: 'nav.tablesConfig', module: 'catalog', perm: 'catalog.tables.manage' },
|
{ to: '/management/tables', icon: TableProperties, label: 'nav.tablesConfig', module: 'catalog', perm: 'catalog.tables.manage' },
|
||||||
{ to: '/management/staff', icon: UserCog, label: 'nav.staff', module: 'core', perm: 'core.staff.manage' },
|
{ to: '/management/staff', icon: UserCog, label: 'nav.staff', module: 'core', perm: 'core.staff.manage' },
|
||||||
{ to: '/management/sessions', icon: LogIn, label: 'nav.sessions', module: 'core', perm: 'core.staff.manage' },
|
{ to: '/management/sessions', icon: LogIn, label: 'nav.sessions', module: 'core', perm: 'core.staff.manage' },
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import xenia from '@xenia/ui/tailwind-preset'
|
|||||||
export default {
|
export default {
|
||||||
// Shared design tokens (bg-surface, text-ink-2, rounded-control…); adds names only
|
// Shared design tokens (bg-surface, text-ink-2, rounded-control…); adds names only
|
||||||
presets: [xenia],
|
presets: [xenia],
|
||||||
content: ['./index.html', './src/**/*.{js,jsx}'],
|
content: ['./index.html', './src/**/*.{js,jsx}', '../packages/signage/src/**/*.{js,jsx}'], // signage slides use a few utilities (5.6a)
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
fontFamily: {
|
fontFamily: {
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
// The signage editor's helpers (plan step 5.6a).
|
||||||
|
import { test } from 'node:test'
|
||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { fitsOrientation, mediaEntry, misfits, moved, slideBody, slideFromTemplate, TEMPLATES, totalSeconds, windowParts } from '../src/pages/signage/signageLogic.js'
|
||||||
|
|
||||||
|
test('templates fill their texts in the manager\'s language and copy their content', () => {
|
||||||
|
const tpl = TEMPLATES.find(x => x.key === 'happyHour')
|
||||||
|
const a = slideFromTemplate(tpl, k => `T(${k})`)
|
||||||
|
assert.equal(a.kind, 'text')
|
||||||
|
assert.equal(a.content.title, 'T(signage.templates.happyHour.title)')
|
||||||
|
assert.equal(a.time_from, '17:00')
|
||||||
|
a.content.background.colour = '#000000'
|
||||||
|
assert.notEqual(tpl.content.background.colour, '#000000') // a copy, never the template itself
|
||||||
|
assert.ok(TEMPLATES.every(x => ['image', 'video', 'text', 'menu'].includes(x.kind)))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('does a picture fit the playlist\'s shape', () => {
|
||||||
|
assert.equal(fitsOrientation({ width: 1920, height: 1080 }, 'landscape'), true)
|
||||||
|
assert.equal(fitsOrientation({ width: 1080, height: 1920 }, 'landscape'), false)
|
||||||
|
assert.equal(fitsOrientation({ width: 1080, height: 1920 }, 'portrait'), true)
|
||||||
|
assert.equal(fitsOrientation({ width: 800, height: 800 }, 'portrait'), true)
|
||||||
|
assert.equal(fitsOrientation({}, 'portrait'), null)
|
||||||
|
const media = { 1: { width: 1080, height: 1920 }, 2: { width: 1920, height: 1080 } }
|
||||||
|
const slides = [{ id: 10, content: { media_id: 1 } }, { id: 11, content: { media_id: 2 } },
|
||||||
|
{ id: 12, content: { background: { kind: 'media', media_id: 1 } } }, { id: 13, content: { background: { kind: 'colour', media_id: 1 } } }]
|
||||||
|
assert.deepEqual(misfits(slides, media, 'landscape'), { 10: [1], 12: [1] })
|
||||||
|
})
|
||||||
|
|
||||||
|
test('the timeline: when a slide shows, the round\'s time, moving', () => {
|
||||||
|
assert.deepEqual(windowParts({}), [])
|
||||||
|
assert.deepEqual(windowParts({ days: [0, 1, 2, 3, 4, 5, 6] }), [])
|
||||||
|
assert.deepEqual(windowParts({ days: [5, 6], time_from: '12:00' }).map(p => p.key), ['days', 'hours'])
|
||||||
|
assert.equal(windowParts({ date_to: '2026-12-31' })[0].params.from, '…')
|
||||||
|
const media = { 7: { duration_ms: 12_400 } }
|
||||||
|
assert.equal(totalSeconds([{ enabled: true, duration_s: 8 }, { enabled: false, duration_s: 50 },
|
||||||
|
{ enabled: true, kind: 'video', video_to_end: true, content: { media_id: 7 } }], media), 20)
|
||||||
|
assert.deepEqual(moved([1, 2, 3, 4], 3, 0), [4, 1, 2, 3])
|
||||||
|
assert.deepEqual(moved([1, 2, 3], 0, 9), [1, 2, 3])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('what is sent back, and library items as the slides need them', () => {
|
||||||
|
const b = slideBody({ id: 1, kind: 'text', name: '', duration_s: 9, enabled: 1, days: undefined, content: { title: 'x' }, menu: {} })
|
||||||
|
assert.deepEqual(b, { name: null, duration_s: 9, transition: null, video_to_end: false, enabled: true, days: [], time_from: null, time_to: null,
|
||||||
|
date_from: null, date_to: null, content: { title: 'x' } })
|
||||||
|
assert.deepEqual(mediaEntry({ id: 3, kind: 'video', name: 'v', width: 1, height: 2, duration_ms: 5, urls: { original: '/o' } }).url, '/o')
|
||||||
|
assert.equal(mediaEntry({ id: 3, kind: 'image', urls: { full: '/f', original: '/o', thumb: '/t' } }).url, '/f')
|
||||||
|
})
|
||||||
Generated
+18
@@ -20,6 +20,7 @@
|
|||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
@@ -3219,6 +3220,10 @@
|
|||||||
"resolved": "packages/i18n",
|
"resolved": "packages/i18n",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@xenia/signage": {
|
||||||
|
"resolved": "packages/signage",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/@xenia/ui": {
|
"node_modules/@xenia/ui": {
|
||||||
"resolved": "packages/ui",
|
"resolved": "packages/ui",
|
||||||
"link": true
|
"link": true
|
||||||
@@ -9572,6 +9577,18 @@
|
|||||||
"react": "^19.0.0"
|
"react": "^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"packages/signage": {
|
||||||
|
"name": "@xenia/signage",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"lucide-react": "^1.73.0",
|
||||||
|
"qrcode.react": "^4.2.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"packages/ui": {
|
"packages/ui": {
|
||||||
"name": "@xenia/ui",
|
"name": "@xenia/ui",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
@@ -9586,6 +9603,7 @@
|
|||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
|
|||||||
@@ -47,7 +47,8 @@
|
|||||||
"approvals": "Εγκρίσεις υπευθύνου",
|
"approvals": "Εγκρίσεις υπευθύνου",
|
||||||
"deliveryFees": "Online παραγγελίες (ρύθμιση)",
|
"deliveryFees": "Online παραγγελίες (ρύθμιση)",
|
||||||
"qrCodes": "QR τραπεζιών",
|
"qrCodes": "QR τραπεζιών",
|
||||||
"media": "Πολυμέσα"
|
"media": "Πολυμέσα",
|
||||||
|
"signage": "Προβολή"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"edit": "Επεξεργασία προφίλ",
|
"edit": "Επεξεργασία προφίλ",
|
||||||
@@ -805,5 +806,164 @@
|
|||||||
},
|
},
|
||||||
"builtin": "Ενσωματωμένο",
|
"builtin": "Ενσωματωμένο",
|
||||||
"builtinHint": "Οι ενσωματωμένες εικόνες έρχονται με το Xenia: χρησιμοποιούνται παντού, αλλά δεν μετονομάζονται ούτε διαγράφονται."
|
"builtinHint": "Οι ενσωματωμένες εικόνες έρχονται με το Xenia: χρησιμοποιούνται παντού, αλλά δεν μετονομάζονται ούτε διαγράφονται."
|
||||||
|
},
|
||||||
|
"signage": {
|
||||||
|
"pageTitle": "Προβολή",
|
||||||
|
"intro": "Τι δείχνουν οι τηλεοράσεις σας: λίστες με μενού, εικόνες, βίντεο και κείμενα. Φτιάξτε κάθε λίστα για το σχήμα της τηλεόρασής της (οριζόντια ή κάθετη)· η προεπισκόπηση δείχνει τη διαφάνεια ακριβώς όπως η τηλεόραση.",
|
||||||
|
"playlists": "Λίστες",
|
||||||
|
"newPlaylist": "Νέα λίστα",
|
||||||
|
"noPlaylists": "Δεν υπάρχουν λίστες ακόμα.",
|
||||||
|
"noPlaylistsHint": "Φτιάξτε μία για οριζόντια ή κάθετη τηλεόραση και προσθέστε διαφάνειες.",
|
||||||
|
"playlistName": "Όνομα",
|
||||||
|
"playlistPlaceholder": "π.χ. Τηλεόραση βιτρίνας",
|
||||||
|
"orientation": "Σχήμα τηλεόρασης",
|
||||||
|
"orientationHint": "Φαρδιά (οριζόντια) ή ψηλή (κάθετη): διαλέξτε εικόνες και βίντεο για αυτό το σχήμα.",
|
||||||
|
"orientations": {
|
||||||
|
"landscape": "Οριζόντια (φαρδιά)",
|
||||||
|
"portrait": "Κάθετη (ψηλή)"
|
||||||
|
},
|
||||||
|
"defaultTransition": "Μετάβαση",
|
||||||
|
"transitions": {
|
||||||
|
"fade": "Σβήσιμο",
|
||||||
|
"slide": "Ολίσθηση",
|
||||||
|
"zoom": "Ζουμ",
|
||||||
|
"none": "Καμία"
|
||||||
|
},
|
||||||
|
"duplicatePlaylist": "Αντίγραφο της λίστας",
|
||||||
|
"duplicated": "Αντιγράφηκε.",
|
||||||
|
"summary_one": "{{count}} διαφάνεια · {{minutes}}:{{seconds}} ο γύρος",
|
||||||
|
"summary_other": "{{count}} διαφάνειες · {{minutes}}:{{seconds}} ο γύρος",
|
||||||
|
"playingOn": "παίζει σε: {{names}}",
|
||||||
|
"timeline": "Χρονολόγιο",
|
||||||
|
"kinds": {
|
||||||
|
"image": "Εικόνα",
|
||||||
|
"video": "Βίντεο",
|
||||||
|
"text": "Κείμενο",
|
||||||
|
"menu": "Μενού"
|
||||||
|
},
|
||||||
|
"misfit": "Αυτή η εικόνα ή το βίντεο δεν ταιριάζει στο σχήμα της λίστας: θα κοπεί ή θα έχει μπάρες.",
|
||||||
|
"toTheEnd": "ως το τέλος",
|
||||||
|
"seconds_one": "{{count}} δευτερόλεπτο",
|
||||||
|
"seconds_other": "{{count}} δευτερόλεπτα",
|
||||||
|
"off": "κλειστή",
|
||||||
|
"window": {
|
||||||
|
"hours": "{{from}}–{{to}}",
|
||||||
|
"dates": "{{from}} → {{to}}"
|
||||||
|
},
|
||||||
|
"weekdays": {
|
||||||
|
"0": "Δευ",
|
||||||
|
"1": "Τρι",
|
||||||
|
"2": "Τετ",
|
||||||
|
"3": "Πεμ",
|
||||||
|
"4": "Παρ",
|
||||||
|
"5": "Σαβ",
|
||||||
|
"6": "Κυρ"
|
||||||
|
},
|
||||||
|
"duplicateSlide": "Αντίγραφο της διαφάνειας",
|
||||||
|
"deleteSlide": "Αφαίρεση αυτής της διαφάνειας;",
|
||||||
|
"removed": "Η διαφάνεια αφαιρέθηκε.",
|
||||||
|
"addSlide": "Προσθήκη διαφάνειας",
|
||||||
|
"added": "Η διαφάνεια προστέθηκε.",
|
||||||
|
"undo": "Αναίρεση αλλαγών",
|
||||||
|
"pickSlide": "Διαλέξτε μια διαφάνεια στο χρονολόγιο για να την αλλάξετε.",
|
||||||
|
"noSlides": "Δεν υπάρχουν διαφάνειες: προσθέστε την πρώτη.",
|
||||||
|
"blank": "Κενή",
|
||||||
|
"templatesTitle": "Ή ξεκινήστε από έτοιμη διαφάνεια",
|
||||||
|
"templates": {
|
||||||
|
"promo": {
|
||||||
|
"name": "Εικόνα προσφοράς"
|
||||||
|
},
|
||||||
|
"announcement": {
|
||||||
|
"name": "Ανακοίνωση"
|
||||||
|
},
|
||||||
|
"happyHour": {
|
||||||
|
"name": "Happy hour (μόνο 17:00–19:00)",
|
||||||
|
"title": "Happy hour",
|
||||||
|
"body": "17:00 – 19:00"
|
||||||
|
},
|
||||||
|
"welcome": {
|
||||||
|
"name": "Καλώς ήρθατε",
|
||||||
|
"title": "Καλώς ήρθατε"
|
||||||
|
},
|
||||||
|
"menuBoard": {
|
||||||
|
"name": "Μενού",
|
||||||
|
"title": "Μενού"
|
||||||
|
},
|
||||||
|
"video": {
|
||||||
|
"name": "Βίντεο ως το τέλος"
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"name": "Εικόνα"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"name": "Κείμενο"
|
||||||
|
},
|
||||||
|
"menu": {
|
||||||
|
"name": "Μενού"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deletePlaylistTitle": "Διαγραφή «{{name}}»;",
|
||||||
|
"deletePlaylistBody": "Οι διαφάνειές της φεύγουν μαζί της. Οι εικόνες και τα βίντεο μένουν στη βιβλιοθήκη.",
|
||||||
|
"deletePlaylistUsed": "Παίζει σε: {{names}}. Αυτές οι οθόνες δεν θα δείχνουν τίποτα μέχρι να τους δώσετε άλλη λίστα. Οι διαφάνειές της φεύγουν· οι εικόνες και τα βίντεο μένουν στη βιβλιοθήκη.",
|
||||||
|
"discard": "Η διαφάνεια έχει αλλαγές που δεν αποθηκεύτηκαν. Να φύγετε;",
|
||||||
|
"slideName": "Όνομα στο χρονολόγιο",
|
||||||
|
"slideNameHint": "Μόνο για εσάς (προαιρετικό).",
|
||||||
|
"enabled": "Να εμφανίζεται",
|
||||||
|
"videoToEnd": "Το βίντεο παίζει ως το τέλος",
|
||||||
|
"videoToEndHint": "Όχι: δείχνεται για τα δευτερόλεπτα παρακάτω (και επαναλαμβάνεται αν είναι μικρότερο).",
|
||||||
|
"duration": "Δευτερόλεπτα στην οθόνη",
|
||||||
|
"durationMenuHint": "Ένα μεγάλο μενού γυρίζει σελίδες και μένει όσο χρειάζεται.",
|
||||||
|
"transition": "Μπαίνει με",
|
||||||
|
"transitionDefault": "Τη μετάβαση της λίστας",
|
||||||
|
"when": "Πότε εμφανίζεται",
|
||||||
|
"whenHint": "Κενό για πάντα. Διαλέξτε μέρες, ώρες (μπορεί να περνούν τα μεσάνυχτα) ή ημερομηνίες για να εμφανίζεται μόνο τότε.",
|
||||||
|
"days": "Μέρες",
|
||||||
|
"timeFrom": "Από (ώρα)",
|
||||||
|
"timeTo": "Έως (ώρα)",
|
||||||
|
"dateFrom": "Από (ημερομηνία)",
|
||||||
|
"dateTo": "Έως (ημερομηνία)",
|
||||||
|
"picture": "Η εικόνα",
|
||||||
|
"video": "Το βίντεο",
|
||||||
|
"fit": "Προσαρμογή",
|
||||||
|
"fits": {
|
||||||
|
"cover": "Γεμίζει την οθόνη (μπορεί να κοπεί)",
|
||||||
|
"contain": "Ολόκληρη (μπορεί να αφήσει μπάρες)"
|
||||||
|
},
|
||||||
|
"around": "Χρώμα στις μπάρες",
|
||||||
|
"muted": "Χωρίς ήχο",
|
||||||
|
"title": "Τίτλος",
|
||||||
|
"body": "Κείμενο",
|
||||||
|
"align": "Στοίχιση",
|
||||||
|
"aligns": {
|
||||||
|
"left": "Αριστερά",
|
||||||
|
"center": "Κέντρο",
|
||||||
|
"right": "Δεξιά"
|
||||||
|
},
|
||||||
|
"vertical": "Ύψος",
|
||||||
|
"verticals": {
|
||||||
|
"top": "Πάνω",
|
||||||
|
"middle": "Μέση",
|
||||||
|
"bottom": "Κάτω"
|
||||||
|
},
|
||||||
|
"font": "Γραμματοσειρά",
|
||||||
|
"fonts": {
|
||||||
|
"sans": "Καθαρή",
|
||||||
|
"serif": "Κλασική",
|
||||||
|
"rounded": "Στρογγυλή",
|
||||||
|
"condensed": "Στενή",
|
||||||
|
"display": "Έντονη αφίσα"
|
||||||
|
},
|
||||||
|
"textColour": "Χρώμα κειμένου",
|
||||||
|
"textSize": "Μέγεθος κειμένου: {{value}}%",
|
||||||
|
"change": "Αλλαγή",
|
||||||
|
"pickVideo": "Επιλογή βίντεο",
|
||||||
|
"pickPicture": "Επιλογή εικόνας",
|
||||||
|
"background": "Φόντο",
|
||||||
|
"bgColour": "Ένα χρώμα",
|
||||||
|
"bgPhoto": "Μια φωτογραφία",
|
||||||
|
"colour": "Χρώμα",
|
||||||
|
"dim": "Σκούρεμα φωτογραφίας: {{value}}%",
|
||||||
|
"columns": "Στήλες",
|
||||||
|
"accent": "Χρώμα τιμών και επικεφαλίδων"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,8 @@
|
|||||||
"approvals": "Manager approvals",
|
"approvals": "Manager approvals",
|
||||||
"deliveryFees": "Online ordering",
|
"deliveryFees": "Online ordering",
|
||||||
"qrCodes": "Table QR codes",
|
"qrCodes": "Table QR codes",
|
||||||
"media": "Media"
|
"media": "Media",
|
||||||
|
"signage": "Signage"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"edit": "Edit profile",
|
"edit": "Edit profile",
|
||||||
@@ -805,5 +806,164 @@
|
|||||||
},
|
},
|
||||||
"builtin": "Built-in",
|
"builtin": "Built-in",
|
||||||
"builtinHint": "Built-in pictures come with Xenia: they can be used anywhere, but not renamed or deleted."
|
"builtinHint": "Built-in pictures come with Xenia: they can be used anywhere, but not renamed or deleted."
|
||||||
|
},
|
||||||
|
"signage": {
|
||||||
|
"pageTitle": "Signage",
|
||||||
|
"intro": "What your TVs show: playlists of menu boards, pictures, videos and texts. Build each playlist for the shape of its TV (landscape or portrait); the preview shows a slide exactly as the TV will.",
|
||||||
|
"playlists": "Playlists",
|
||||||
|
"newPlaylist": "New playlist",
|
||||||
|
"noPlaylists": "No playlists yet.",
|
||||||
|
"noPlaylistsHint": "Make one for a landscape or a portrait TV, then add slides.",
|
||||||
|
"playlistName": "Name",
|
||||||
|
"playlistPlaceholder": "e.g. Window TV",
|
||||||
|
"orientation": "TV shape",
|
||||||
|
"orientationHint": "Wide (landscape) or tall (portrait): pick the pictures and videos for this shape.",
|
||||||
|
"orientations": {
|
||||||
|
"landscape": "Landscape (wide)",
|
||||||
|
"portrait": "Portrait (tall)"
|
||||||
|
},
|
||||||
|
"defaultTransition": "Transition",
|
||||||
|
"transitions": {
|
||||||
|
"fade": "Fade",
|
||||||
|
"slide": "Slide in",
|
||||||
|
"zoom": "Zoom",
|
||||||
|
"none": "None"
|
||||||
|
},
|
||||||
|
"duplicatePlaylist": "Duplicate the playlist",
|
||||||
|
"duplicated": "Copied.",
|
||||||
|
"summary_one": "{{count}} slide · {{minutes}}:{{seconds}} a round",
|
||||||
|
"summary_other": "{{count}} slides · {{minutes}}:{{seconds}} a round",
|
||||||
|
"playingOn": "playing on {{names}}",
|
||||||
|
"timeline": "Timeline",
|
||||||
|
"kinds": {
|
||||||
|
"image": "Picture",
|
||||||
|
"video": "Video",
|
||||||
|
"text": "Text",
|
||||||
|
"menu": "Menu board"
|
||||||
|
},
|
||||||
|
"misfit": "This picture or video doesn't fit the playlist's shape: it will be cropped or have bars.",
|
||||||
|
"toTheEnd": "to the end",
|
||||||
|
"seconds_one": "{{count}} second",
|
||||||
|
"seconds_other": "{{count}} seconds",
|
||||||
|
"off": "off",
|
||||||
|
"window": {
|
||||||
|
"hours": "{{from}}–{{to}}",
|
||||||
|
"dates": "{{from}} → {{to}}"
|
||||||
|
},
|
||||||
|
"weekdays": {
|
||||||
|
"0": "Mon",
|
||||||
|
"1": "Tue",
|
||||||
|
"2": "Wed",
|
||||||
|
"3": "Thu",
|
||||||
|
"4": "Fri",
|
||||||
|
"5": "Sat",
|
||||||
|
"6": "Sun"
|
||||||
|
},
|
||||||
|
"duplicateSlide": "Duplicate the slide",
|
||||||
|
"deleteSlide": "Remove this slide?",
|
||||||
|
"removed": "Slide removed.",
|
||||||
|
"addSlide": "Add a slide",
|
||||||
|
"added": "Slide added.",
|
||||||
|
"undo": "Undo changes",
|
||||||
|
"pickSlide": "Pick a slide on the timeline to change it.",
|
||||||
|
"noSlides": "No slides yet: add the first one.",
|
||||||
|
"blank": "Start empty",
|
||||||
|
"templatesTitle": "Or start from a ready-made slide",
|
||||||
|
"templates": {
|
||||||
|
"promo": {
|
||||||
|
"name": "Promotion picture"
|
||||||
|
},
|
||||||
|
"announcement": {
|
||||||
|
"name": "Announcement"
|
||||||
|
},
|
||||||
|
"happyHour": {
|
||||||
|
"name": "Happy hour (17:00–19:00 only)",
|
||||||
|
"title": "Happy hour",
|
||||||
|
"body": "17:00 – 19:00"
|
||||||
|
},
|
||||||
|
"welcome": {
|
||||||
|
"name": "Welcome",
|
||||||
|
"title": "Welcome"
|
||||||
|
},
|
||||||
|
"menuBoard": {
|
||||||
|
"name": "Menu board",
|
||||||
|
"title": "Menu"
|
||||||
|
},
|
||||||
|
"video": {
|
||||||
|
"name": "Video to its end"
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"name": "Picture"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"name": "Text"
|
||||||
|
},
|
||||||
|
"menu": {
|
||||||
|
"name": "Menu board"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deletePlaylistTitle": "Delete \"{{name}}\"?",
|
||||||
|
"deletePlaylistBody": "Its slides go with it. The pictures and videos stay in the media library.",
|
||||||
|
"deletePlaylistUsed": "It is playing on {{names}}: those screens will show nothing until you give them another playlist. Its slides go with it; the pictures and videos stay in the media library.",
|
||||||
|
"discard": "This slide has changes that aren't saved. Leave it anyway?",
|
||||||
|
"slideName": "Name on the timeline",
|
||||||
|
"slideNameHint": "Only for you (optional).",
|
||||||
|
"enabled": "Show this slide",
|
||||||
|
"videoToEnd": "Play the video to its end",
|
||||||
|
"videoToEndHint": "Off: it shows for the seconds below (and repeats if it is shorter).",
|
||||||
|
"duration": "Seconds on screen",
|
||||||
|
"durationMenuHint": "A long menu turns its pages and stays as long as it needs.",
|
||||||
|
"transition": "Comes in with",
|
||||||
|
"transitionDefault": "The playlist's transition",
|
||||||
|
"when": "When it shows",
|
||||||
|
"whenHint": "Leave empty for always. Pick days, hours (they may pass midnight) or dates to show it only then.",
|
||||||
|
"days": "Days",
|
||||||
|
"timeFrom": "From (time)",
|
||||||
|
"timeTo": "To (time)",
|
||||||
|
"dateFrom": "From (date)",
|
||||||
|
"dateTo": "To (date)",
|
||||||
|
"picture": "The picture",
|
||||||
|
"video": "The video",
|
||||||
|
"fit": "Fit",
|
||||||
|
"fits": {
|
||||||
|
"cover": "Fill the screen (may crop)",
|
||||||
|
"contain": "Show it whole (may leave bars)"
|
||||||
|
},
|
||||||
|
"around": "Colour of the bars",
|
||||||
|
"muted": "Without sound",
|
||||||
|
"title": "Title",
|
||||||
|
"body": "Text",
|
||||||
|
"align": "Alignment",
|
||||||
|
"aligns": {
|
||||||
|
"left": "Left",
|
||||||
|
"center": "Centre",
|
||||||
|
"right": "Right"
|
||||||
|
},
|
||||||
|
"vertical": "Height",
|
||||||
|
"verticals": {
|
||||||
|
"top": "Top",
|
||||||
|
"middle": "Middle",
|
||||||
|
"bottom": "Bottom"
|
||||||
|
},
|
||||||
|
"font": "Font",
|
||||||
|
"fonts": {
|
||||||
|
"sans": "Clean",
|
||||||
|
"serif": "Classic",
|
||||||
|
"rounded": "Rounded",
|
||||||
|
"condensed": "Narrow",
|
||||||
|
"display": "Bold poster"
|
||||||
|
},
|
||||||
|
"textColour": "Text colour",
|
||||||
|
"textSize": "Text size: {{value}}%",
|
||||||
|
"change": "Change",
|
||||||
|
"pickVideo": "Pick a video",
|
||||||
|
"pickPicture": "Pick a picture",
|
||||||
|
"background": "Background",
|
||||||
|
"bgColour": "A colour",
|
||||||
|
"bgPhoto": "A photo",
|
||||||
|
"colour": "Colour",
|
||||||
|
"dim": "Darken the photo: {{value}}%",
|
||||||
|
"columns": "Columns",
|
||||||
|
"accent": "Prices and headings colour"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "@xenia/signage",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"description": "Signage slides as the TVs draw them, and the player's pure logic (schedule pick, slide windows, menu pages): one implementation for the terminal's player and the manager's previews (plan steps 5.5a-5.6a).",
|
||||||
|
"main": "src/index.js",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"lucide-react": "^1.73.0",
|
||||||
|
"qrcode.react": "^4.2.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "node --test \"tests/*.test.mjs\""
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
// One slide as a TV shows it (plan step 5.6a): picture, video, text or menu board. Used by the
|
||||||
|
// player (terminal) and the manager's previews. Needs a parent with `container-type: size`.
|
||||||
|
// media(id) → { src, url, kind, width, height } | null (src: the address or the TV's kept copy)
|
||||||
|
import { useEffect, useRef } from 'react'
|
||||||
|
import { MenuSlide, TextSlide } from './Slides.jsx'
|
||||||
|
|
||||||
|
export function SlideView({ slide, media, venue, now, pages, page, onEnded, playing = true }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{slide.kind === 'image' && <ImageSlide content={slide.content || {}} media={media} />}
|
||||||
|
{slide.kind === 'video' && <VideoSlide slide={slide} media={media} onEnded={onEnded} playing={playing} />}
|
||||||
|
{slide.kind === 'text' && <TextSlide content={slide.content || {}} media={media} venue={venue} now={now} />}
|
||||||
|
{slide.kind === 'menu' && <MenuSlide slide={slide} media={media} venue={venue} now={now} pages={pages || []} page={page || 0} />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ImageSlide({ content, media }) {
|
||||||
|
const m = content.media_id ? media(content.media_id) : null
|
||||||
|
return (
|
||||||
|
<div className="absolute inset-0" style={{ background: content.background_colour || '#000' }}>
|
||||||
|
{m && <img src={m.src} alt="" className="w-full h-full" style={{ objectFit: content.fit || 'cover' }} data-testid="signage-image" />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function VideoSlide({ slide, media, onEnded, playing }) {
|
||||||
|
const c = slide.content || {}
|
||||||
|
const m = c.media_id ? media(c.media_id) : null
|
||||||
|
const ref = useRef(null)
|
||||||
|
useEffect(() => {
|
||||||
|
const v = ref.current
|
||||||
|
if (!v) return
|
||||||
|
if (playing) v.play?.().catch(() => {})
|
||||||
|
else v.pause?.()
|
||||||
|
}, [m?.src, playing])
|
||||||
|
return (
|
||||||
|
<div className="absolute inset-0" style={{ background: c.background_colour || '#000' }}>
|
||||||
|
{m && <video ref={ref} src={m.src} autoPlay={playing} muted={c.muted !== false || !playing} playsInline loop={!slide.video_to_end}
|
||||||
|
onEnded={slide.video_to_end ? onEnded : undefined} onError={slide.video_to_end ? onEnded : undefined}
|
||||||
|
className="w-full h-full" style={{ objectFit: c.fit || 'cover' }} data-testid="signage-video" />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Text and menu slides of the signage player, and their widgets (plan steps 5.5a, 5.5b). Colours,
|
// Text and menu slides of the signage player, and their widgets (plan steps 5.5a, 5.5b). Colours,
|
||||||
// fonts and sizes here are the venue's own choices for its TV (slide content = data, CS-16), so
|
// fonts and sizes here are the venue's own choices for its TV (slide content = data, CS-16), so
|
||||||
// they are inline styles, not tokens. Sizes scale with the screen (vmin), so a slide looks the
|
// they are inline styles, not tokens. Sizes scale with the screen (cqmin), so a slide looks the
|
||||||
// same on any TV.
|
// same on any TV.
|
||||||
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
||||||
import { QRCodeSVG } from 'qrcode.react'
|
import { QRCodeSVG } from 'qrcode.react'
|
||||||
@@ -28,10 +28,10 @@ export function TextSlide({ content: c, media, venue, now }) {
|
|||||||
<Background bg={c.background} media={media} />
|
<Background bg={c.background} media={media} />
|
||||||
<div className="absolute inset-0 flex flex-col" style={{
|
<div className="absolute inset-0 flex flex-col" style={{
|
||||||
justifyContent: JUSTIFY[c.vertical] || 'center', textAlign: c.align || 'center',
|
justifyContent: JUSTIFY[c.vertical] || 'center', textAlign: c.align || 'center',
|
||||||
padding: `${hasBar(c, 'top-bar') ? 14 : 8}vmin 8vmin ${hasBar(c, 'bottom-bar') ? 14 : 8}vmin`, gap: `${3 * scale}vmin`,
|
padding: `${hasBar(c, 'top-bar') ? 14 : 8}cqmin 8cqmin ${hasBar(c, 'bottom-bar') ? 14 : 8}cqmin`, gap: `${3 * scale}cqmin`,
|
||||||
}}>
|
}}>
|
||||||
{c.title && <h1 style={{ fontSize: `${9 * scale}vmin`, lineHeight: 1.1, fontWeight: 800, margin: 0 }} data-testid="signage-title">{c.title}</h1>}
|
{c.title && <h1 style={{ fontSize: `${9 * scale}cqmin`, lineHeight: 1.1, fontWeight: 800, margin: 0 }} data-testid="signage-title">{c.title}</h1>}
|
||||||
{c.body && <p style={{ fontSize: `${4.5 * scale}vmin`, lineHeight: 1.35, margin: 0, whiteSpace: 'pre-line' }} data-testid="signage-body">{c.body}</p>}
|
{c.body && <p style={{ fontSize: `${4.5 * scale}cqmin`, lineHeight: 1.35, margin: 0, whiteSpace: 'pre-line' }} data-testid="signage-body">{c.body}</p>}
|
||||||
</div>
|
</div>
|
||||||
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} colour={c.text_colour} />
|
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} colour={c.text_colour} />
|
||||||
</div>
|
</div>
|
||||||
@@ -50,32 +50,32 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
|
|||||||
<div className="absolute inset-0" style={{ color: c.text_colour || '#fff', fontFamily: FONTS[c.font] || FONTS.sans }}>
|
<div className="absolute inset-0" style={{ color: c.text_colour || '#fff', fontFamily: FONTS[c.font] || FONTS.sans }}>
|
||||||
<Background bg={c.background} media={media} />
|
<Background bg={c.background} media={media} />
|
||||||
<div className="absolute inset-0 flex flex-col"
|
<div className="absolute inset-0 flex flex-col"
|
||||||
style={{ padding: `${hasBar(c, 'top-bar') ? 12 : 5}vmin 5vmin ${hasBar(c, 'bottom-bar') ? 12 : 5}vmin` }}
|
style={{ padding: `${hasBar(c, 'top-bar') ? 12 : 5}cqmin 5cqmin ${hasBar(c, 'bottom-bar') ? 12 : 5}cqmin` }}
|
||||||
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
|
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
|
||||||
{c.title && <h1 style={{ fontSize: `${7 * scale}vmin`, fontWeight: 800, margin: '0 0 2vmin', color: accent, lineHeight: 1.1 }}>{c.title}</h1>}
|
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: accent, lineHeight: 1.1 }}>{c.title}</h1>}
|
||||||
<div style={{ columnCount: c.columns || 2, columnGap: '5vmin', fontSize: `${3.2 * scale}vmin`, flex: 1, columnFill: 'auto' }}>
|
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, columnFill: 'auto' }}>
|
||||||
{groups.map((g, i) => (
|
{groups.map((g, i) => (
|
||||||
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '1.6vmin' }}>
|
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '1.6cqmin' }}>
|
||||||
{g.category && c.category_titles !== false && (
|
{g.category && c.category_titles !== false && (
|
||||||
<h2 style={{ fontSize: '1.15em', color: accent, margin: '0 0 0.6vmin', fontWeight: 700, breakAfter: 'avoid' }}
|
<h2 style={{ fontSize: '1.15em', color: accent, margin: '0 0 0.6cqmin', fontWeight: 700, breakAfter: 'avoid' }}
|
||||||
data-testid="signage-menu-heading">{g.category.name}</h2>
|
data-testid="signage-menu-heading">{g.category.name}</h2>
|
||||||
)}
|
)}
|
||||||
{g.items.map(it => (
|
{g.items.map(it => (
|
||||||
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
|
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
|
||||||
style={{ display: 'flex', alignItems: 'center', gap: '1.5vmin', breakInside: 'avoid', padding: '0.5vmin 0',
|
style={{ display: 'flex', alignItems: 'center', gap: '1.5cqmin', breakInside: 'avoid', padding: '0.5cqmin 0',
|
||||||
opacity: it.available ? 1 : 0.5 }}>
|
opacity: it.available ? 1 : 0.5 }}>
|
||||||
{c.show_photos && (it.image
|
{c.show_photos && (it.image
|
||||||
? <img src={it.image} alt="" style={{ width: '7vmin', height: '7vmin', objectFit: 'cover', borderRadius: '1vmin', flexShrink: 0 }} />
|
? <img src={it.image} alt="" style={{ width: '7cqmin', height: '7cqmin', objectFit: 'cover', borderRadius: '1cqmin', flexShrink: 0 }} />
|
||||||
: <span style={{ width: '7vmin', height: '7vmin', flexShrink: 0 }} />)}
|
: <span style={{ width: '7cqmin', height: '7cqmin', flexShrink: 0 }} />)}
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: '1vmin' }}>
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: '1cqmin' }}>
|
||||||
<span style={{ textDecoration: it.available ? 'none' : 'line-through', fontWeight: 600 }}>{it.name}</span>
|
<span style={{ textDecoration: it.available ? 'none' : 'line-through', fontWeight: 600 }}>{it.name}</span>
|
||||||
{it.badge && (
|
{it.badge && (
|
||||||
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.2vmin 0.9vmin', borderRadius: '99vmin',
|
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.2cqmin 0.9cqmin', borderRadius: '99cqmin',
|
||||||
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap' }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap' }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
||||||
)}
|
)}
|
||||||
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
||||||
<span style={{ flex: 1, borderBottom: '0.25vmin dotted currentColor', opacity: 0.35, minWidth: '2vmin' }} />
|
<span style={{ flex: 1, borderBottom: '0.25cqmin dotted currentColor', opacity: 0.35, minWidth: '2cqmin' }} />
|
||||||
{it.price != null && <span style={{ color: accent, fontVariantNumeric: 'tabular-nums', fontWeight: 700, whiteSpace: 'nowrap' }}
|
{it.price != null && <span style={{ color: accent, fontVariantNumeric: 'tabular-nums', fontWeight: 700, whiteSpace: 'nowrap' }}
|
||||||
data-testid="signage-menu-price">{formatMoney(it.price)}</span>}
|
data-testid="signage-menu-price">{formatMoney(it.price)}</span>}
|
||||||
</div>
|
</div>
|
||||||
@@ -87,8 +87,8 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{pages.length > 1 && (
|
{pages.length > 1 && (
|
||||||
<div style={{ display: 'flex', gap: '1vmin', justifyContent: 'center', paddingTop: '1vmin' }} aria-hidden="true">
|
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
||||||
{pages.map((_, i) => <span key={i} style={{ width: '1.2vmin', height: '1.2vmin', borderRadius: '50%', background: i === page ? accent : 'currentColor', opacity: i === page ? 1 : 0.3 }} />)}
|
{pages.map((_, i) => <span key={i} style={{ width: '1.2cqmin', height: '1.2cqmin', borderRadius: '50%', background: i === page ? accent : 'currentColor', opacity: i === page ? 1 : 0.3 }} />)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -101,12 +101,12 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
|
|||||||
|
|
||||||
const SIZE = { small: 0.75, medium: 1, large: 1.4 }
|
const SIZE = { small: 0.75, medium: 1, large: 1.4 }
|
||||||
const CORNER = {
|
const CORNER = {
|
||||||
'top-left': { top: '3vmin', left: '3vmin', alignItems: 'flex-start' },
|
'top-left': { top: '3cqmin', left: '3cqmin', alignItems: 'flex-start' },
|
||||||
'top-center': { top: '3vmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
'top-center': { top: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
||||||
'top-right': { top: '3vmin', right: '3vmin', alignItems: 'flex-end' },
|
'top-right': { top: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
||||||
'bottom-left': { bottom: '3vmin', left: '3vmin', alignItems: 'flex-start' },
|
'bottom-left': { bottom: '3cqmin', left: '3cqmin', alignItems: 'flex-start' },
|
||||||
'bottom-center': { bottom: '3vmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
'bottom-center': { bottom: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
||||||
'bottom-right': { bottom: '3vmin', right: '3vmin', alignItems: 'flex-end' },
|
'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The widgets of a slide, in their corners and bars. One that has nothing to show is left out. */
|
/** The widgets of a slide, in their corners and bars. One that has nothing to show is left out. */
|
||||||
@@ -118,8 +118,8 @@ export function Widgets({ widgets, media, venue, now, colour }) {
|
|||||||
<>
|
<>
|
||||||
{bars.map(([where, pos]) => bar(where).length > 0 && (
|
{bars.map(([where, pos]) => bar(where).length > 0 && (
|
||||||
<div key={where} className="absolute inset-x-0" data-testid={`signage-${where}`}
|
<div key={where} className="absolute inset-x-0" data-testid={`signage-${where}`}
|
||||||
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '3vmin', padding: '2vmin 4vmin',
|
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '3cqmin', padding: '2cqmin 4cqmin',
|
||||||
background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: '9vmin' }}>
|
background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: '9cqmin' }}>
|
||||||
{bar(where).map((w, i) => <Widget key={i} w={w} media={media} venue={venue} now={now} />)}
|
{bar(where).map((w, i) => <Widget key={i} w={w} media={media} venue={venue} now={now} />)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -137,25 +137,25 @@ const ICONS = { sun: Sun, moon: Moon, 'cloud-sun': CloudSun, 'cloud-moon': Cloud
|
|||||||
function Widget({ w, media, venue, now }) {
|
function Widget({ w, media, venue, now }) {
|
||||||
const { formatDate, formatTime } = useFormat()
|
const { formatDate, formatTime } = useFormat()
|
||||||
const s = SIZE[w.size] || 1
|
const s = SIZE[w.size] || 1
|
||||||
const text = { fontSize: `${3.4 * s}vmin`, fontWeight: 700, lineHeight: 1.15, textShadow: '0 0.2vmin 0.8vmin rgba(0,0,0,0.35)' }
|
const text = { fontSize: `${3.4 * s}cqmin`, fontWeight: 700, lineHeight: 1.15, textShadow: '0 0.2cqmin 0.8cqmin rgba(0,0,0,0.35)' }
|
||||||
if (w.kind === 'logo') {
|
if (w.kind === 'logo') {
|
||||||
const m = media(w.media_id)
|
const m = media(w.media_id)
|
||||||
return m ? <img src={m.src} alt="" style={{ height: `${9 * s}vmin`, maxWidth: `${30 * s}vmin`, objectFit: 'contain' }} data-testid="signage-w-logo" /> : null
|
return m ? <img src={m.src} alt="" style={{ height: `${9 * s}cqmin`, maxWidth: `${30 * s}cqmin`, objectFit: 'contain' }} data-testid="signage-w-logo" /> : null
|
||||||
}
|
}
|
||||||
if (w.kind === 'name') return venue?.name ? <span style={{ ...text, fontSize: `${4.2 * s}vmin` }} data-testid="signage-w-name">{venue.name}</span> : null
|
if (w.kind === 'name') return venue?.name ? <span style={{ ...text, fontSize: `${4.2 * s}cqmin` }} data-testid="signage-w-name">{venue.name}</span> : null
|
||||||
if (w.kind === 'date') return <span style={text} data-testid="signage-w-date">{formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong')}</span>
|
if (w.kind === 'date') return <span style={text} data-testid="signage-w-date">{formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong')}</span>
|
||||||
if (w.kind === 'clock') return <span style={{ ...text, fontSize: `${4.6 * s}vmin`, fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">{formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')}</span>
|
if (w.kind === 'clock') return <span style={{ ...text, fontSize: `${4.6 * s}cqmin`, fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">{formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')}</span>
|
||||||
if (w.kind === 'message') {
|
if (w.kind === 'message') {
|
||||||
const msg = w.text || venue?.message
|
const msg = w.text || venue?.message
|
||||||
return msg ? <span style={{ ...text, fontWeight: 600 }} data-testid="signage-w-message">{msg}</span> : null
|
return msg ? <span style={{ ...text, fontWeight: 600 }} data-testid="signage-w-message">{msg}</span> : null
|
||||||
}
|
}
|
||||||
if (w.kind === 'qr') {
|
if (w.kind === 'qr') {
|
||||||
return w.link ? (
|
return w.link ? (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '0.8vmin' }} data-testid="signage-w-qr" data-link={w.link}>
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '0.8cqmin' }} data-testid="signage-w-qr" data-link={w.link}>
|
||||||
<div style={{ background: '#fff', padding: '1vmin', borderRadius: '1vmin', lineHeight: 0 }}>
|
<div style={{ background: '#fff', padding: '1cqmin', borderRadius: '1cqmin', lineHeight: 0 }}>
|
||||||
<QRCodeSVG value={w.link} size={256} style={{ width: `${14 * s}vmin`, height: `${14 * s}vmin` }} />
|
<QRCodeSVG value={w.link} size={256} style={{ width: `${14 * s}cqmin`, height: `${14 * s}cqmin` }} />
|
||||||
</div>
|
</div>
|
||||||
{w.qr_caption && <span style={{ ...text, fontSize: `${2.4 * s}vmin` }}>{w.qr_caption}</span>}
|
{w.qr_caption && <span style={{ ...text, fontSize: `${2.4 * s}cqmin` }}>{w.qr_caption}</span>}
|
||||||
</div>
|
</div>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
@@ -165,14 +165,14 @@ function Widget({ w, media, venue, now }) {
|
|||||||
const Icon = ICONS[weatherIcon(wx.code, wx.is_day)] || Cloud
|
const Icon = ICONS[weatherIcon(wx.code, wx.is_day)] || Cloud
|
||||||
const deg = wx.units === 'fahrenheit' ? '°F' : '°C'
|
const deg = wx.units === 'fahrenheit' ? '°F' : '°C'
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '1.5vmin' }} data-testid="signage-w-weather">
|
<div style={{ display: 'flex', alignItems: 'center', gap: '1.5cqmin' }} data-testid="signage-w-weather">
|
||||||
<Icon style={{ width: `${6 * s}vmin`, height: `${6 * s}vmin` }} aria-hidden="true" />
|
<Icon style={{ width: `${6 * s}cqmin`, height: `${6 * s}cqmin` }} aria-hidden="true" />
|
||||||
<span style={{ ...text, fontSize: `${4.4 * s}vmin` }}>{Math.round(wx.temperature)}{deg}</span>
|
<span style={{ ...text, fontSize: `${4.4 * s}cqmin` }}>{Math.round(wx.temperature)}{deg}</span>
|
||||||
{(w.weather_days || 1) > 1 && (wx.days || []).slice(1, w.weather_days).map(d => {
|
{(w.weather_days || 1) > 1 && (wx.days || []).slice(1, w.weather_days).map(d => {
|
||||||
const DayIcon = ICONS[weatherIcon(d.code, true)] || Cloud
|
const DayIcon = ICONS[weatherIcon(d.code, true)] || Cloud
|
||||||
return (
|
return (
|
||||||
<span key={d.date} style={{ display: 'flex', alignItems: 'center', gap: '0.6vmin', ...text, fontSize: `${2.4 * s}vmin`, fontWeight: 600 }}>
|
<span key={d.date} style={{ display: 'flex', alignItems: 'center', gap: '0.6cqmin', ...text, fontSize: `${2.4 * s}cqmin`, fontWeight: 600 }}>
|
||||||
{formatDate(`${d.date}T12:00:00Z`, 'weekday').slice(0, 3)} <DayIcon style={{ width: `${3.4 * s}vmin`, height: `${3.4 * s}vmin` }} aria-hidden="true" />
|
{formatDate(`${d.date}T12:00:00Z`, 'weekday').slice(0, 3)} <DayIcon style={{ width: `${3.4 * s}cqmin`, height: `${3.4 * s}cqmin` }} aria-hidden="true" />
|
||||||
{Math.round(d.max)}° / {Math.round(d.min)}°
|
{Math.round(d.max)}° / {Math.round(d.min)}°
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// @xenia/signage (plan step 5.6a): what a signage slide looks like, drawn the same in the TV's
|
||||||
|
// player (terminal/src/apps/signage) and in the manager's live previews. Sizes are container
|
||||||
|
// units (cqmin): put a slide inside an element with `container-type: size` (frameStyle() does).
|
||||||
|
export * from './logic.js'
|
||||||
|
export { Background, MenuSlide, TextSlide, Widgets } from './Slides.jsx'
|
||||||
|
export { SlideView } from './SlideView.jsx'
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// The signage player's logic (plan step 5.5a). Pure: unit-tested in Node (tests/signage.test.mjs).
|
// The signage player's logic (plan steps 5.5a, 5.5b; @xenia/signage since 5.6a). Pure: unit-tested in
|
||||||
|
// Node (packages/signage/tests/logic.test.mjs).
|
||||||
// The schedule rules are the server's (local_backend/services/signage_schedule.py) so a screen
|
// The schedule rules are the server's (local_backend/services/signage_schedule.py) so a screen
|
||||||
// switches playlists by itself while the server is down; the same cases are tested on both sides.
|
// switches playlists by itself while the server is down; the same cases are tested on both sides.
|
||||||
|
|
||||||
@@ -94,9 +95,9 @@ export function slideMs(slide) {
|
|||||||
export function frameStyle(rotation) {
|
export function frameStyle(rotation) {
|
||||||
const r = Number(rotation) || 0
|
const r = Number(rotation) || 0
|
||||||
if (r === 90 || r === 270) {
|
if (r === 90 || r === 270) {
|
||||||
return { width: '100vh', height: '100vw', transform: `translate(-50%, -50%) rotate(${r}deg)`, top: '50%', left: '50%', position: 'absolute' }
|
return { width: '100vh', height: '100vw', transform: `translate(-50%, -50%) rotate(${r}deg)`, top: '50%', left: '50%', position: 'absolute', containerType: 'size' }
|
||||||
}
|
}
|
||||||
return { width: '100vw', height: '100vh', transform: r === 180 ? 'rotate(180deg)' : undefined, top: 0, left: 0, position: 'absolute' }
|
return { width: '100vw', height: '100vh', transform: r === 180 ? 'rotate(180deg)' : undefined, top: 0, left: 0, position: 'absolute', containerType: 'size' }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every media address a playlist (or a schedule's playlists) needs, to keep on the device. */
|
/** Every media address a playlist (or a schedule's playlists) needs, to keep on the device. */
|
||||||
@@ -119,7 +120,7 @@ export const FONTS = {
|
|||||||
|
|
||||||
// ── menu boards (5.5b) ───────────────────────────────────────────────────────
|
// ── menu boards (5.5b) ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
/** The frame's height in vmin (its shorter side is 100) for a screen w × h: 100 when wide, ~178 when tall (16:9). */
|
/** The frame's height in cqmin (its shorter side is 100) for a screen w × h: 100 when wide, ~178 when tall (16:9). */
|
||||||
export function frameHeightVmin(rotation, w = 16, h = 9) {
|
export function frameHeightVmin(rotation, w = 16, h = 9) {
|
||||||
const turned = Number(rotation) === 90 || Number(rotation) === 270
|
const turned = Number(rotation) === 90 || Number(rotation) === 270
|
||||||
const frameTall = turned ? w > h : h > w // the screen's sides, swapped when the picture is turned
|
const frameTall = turned ? w > h : h > w // the screen's sides, swapped when the picture is turned
|
||||||
@@ -128,7 +129,7 @@ export function frameHeightVmin(rotation, w = 16, h = 9) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* How many rows fit in one column of a menu board: rows are items (taller with a photo or a
|
* How many rows fit in one column of a menu board: rows are items (taller with a photo or a
|
||||||
* description) and group headings. Sizes in vmin, as the board draws them.
|
* description) and group headings. Sizes in cqmin, as the board draws them.
|
||||||
*/
|
*/
|
||||||
export function rowsPerColumn({ heightVmin = 100, textSize = 100, photos = false, descriptions = false, title = false, bars = 0 }) {
|
export function rowsPerColumn({ heightVmin = 100, textSize = 100, photos = false, descriptions = false, title = false, bars = 0 }) {
|
||||||
const s = (textSize || 100) / 100
|
const s = (textSize || 100) / 100
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// local_backend/tests/test_signage_schedule.py, slide windows, the next slide, the frame.
|
// local_backend/tests/test_signage_schedule.py, slide windows, the next slide, the frame.
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
import { boardPages, frameHeightVmin, frameStyle, localNow, matches, mediaUrls, menuMs, menuPages, nextSlide, pageAt, pick, playlistNow, rowsPerColumn, slideMs, weatherIcon } from '../src/apps/signage/logic.js'
|
import { boardPages, frameHeightVmin, frameStyle, localNow, matches, mediaUrls, menuMs, menuPages, nextSlide, pageAt, pick, playlistNow, rowsPerColumn, slideMs, weatherIcon } from '../src/logic.js'
|
||||||
|
|
||||||
const at = (date, hhmm) => {
|
const at = (date, hhmm) => {
|
||||||
const d = new Date(`${date}T12:00:00Z`)
|
const d = new Date(`${date}T12:00:00Z`)
|
||||||
@@ -11,6 +11,7 @@ COPY packages/ui/package.json packages/ui/
|
|||||||
COPY packages/i18n/package.json packages/i18n/
|
COPY packages/i18n/package.json packages/i18n/
|
||||||
COPY packages/api/package.json packages/api/
|
COPY packages/api/package.json packages/api/
|
||||||
COPY packages/access/package.json packages/access/
|
COPY packages/access/package.json packages/access/
|
||||||
|
COPY packages/signage/package.json packages/signage/
|
||||||
COPY waiter_pwa/package.json waiter_pwa/
|
COPY waiter_pwa/package.json waiter_pwa/
|
||||||
COPY manager_dashboard/package.json manager_dashboard/
|
COPY manager_dashboard/package.json manager_dashboard/
|
||||||
COPY terminal/package.json terminal/
|
COPY terminal/package.json terminal/
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import client from '../../api/client'
|
import client from '../../api/client'
|
||||||
import { useDevice, useLiveEvent, useLiveEvents } from '../../device/context'
|
import { useDevice, useLiveEvent, useLiveEvents } from '../../device/context'
|
||||||
import { boardPages, frameStyle, localNow, mediaUrls, menuMs, nextSlide, pageAt, playlistNow, slideMs } from './logic'
|
import { boardPages, frameStyle, localNow, mediaUrls, menuMs, nextSlide, pageAt, playlistNow, SlideView, slideMs } from '@xenia/signage'
|
||||||
import { MenuSlide, TextSlide } from './Slides'
|
|
||||||
|
|
||||||
const quiet = { xenia: { noOverride: true } }
|
const quiet = { xenia: { noOverride: true } }
|
||||||
const CACHE_KEY = 'xenia:signage:screen'
|
const CACHE_KEY = 'xenia:signage:screen'
|
||||||
@@ -186,33 +185,7 @@ function Layer({ slide, media, venue, now, onEnded, className, current = false,
|
|||||||
return (
|
return (
|
||||||
<section className={`absolute inset-0 overflow-hidden ${className}`} style={{ animationDuration: `${TRANSITION_MS}ms` }}
|
<section className={`absolute inset-0 overflow-hidden ${className}`} style={{ animationDuration: `${TRANSITION_MS}ms` }}
|
||||||
data-testid={current ? 'signage-slide' : 'signage-slide-out'} data-kind={slide.kind} data-slide={slide.id}>
|
data-testid={current ? 'signage-slide' : 'signage-slide-out'} data-kind={slide.kind} data-slide={slide.id}>
|
||||||
{slide.kind === 'image' && <ImageSlide content={slide.content} media={media} />}
|
<SlideView slide={slide} media={media} venue={venue} now={now} pages={pages} page={page} onEnded={current ? onEnded : undefined} />
|
||||||
{slide.kind === 'video' && <VideoSlide slide={slide} media={media} onEnded={current ? onEnded : undefined} />}
|
|
||||||
{slide.kind === 'text' && <TextSlide content={slide.content} media={media} venue={venue} now={now} />}
|
|
||||||
{slide.kind === 'menu' && <MenuSlide slide={slide} media={media} venue={venue} now={now} pages={pages || []} page={page || 0} />}
|
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImageSlide({ content, media }) {
|
|
||||||
const m = media(content.media_id)
|
|
||||||
return (
|
|
||||||
<div className="absolute inset-0" style={{ background: content.background_colour || '#000' }}>
|
|
||||||
{m && <img src={m.src} alt="" className="w-full h-full" style={{ objectFit: content.fit || 'cover' }} data-testid="signage-image" />}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function VideoSlide({ slide, media, onEnded }) {
|
|
||||||
const c = slide.content
|
|
||||||
const m = media(c.media_id)
|
|
||||||
const ref = useRef(null)
|
|
||||||
useEffect(() => { ref.current?.play?.().catch(() => {}) }, [m?.src])
|
|
||||||
return (
|
|
||||||
<div className="absolute inset-0" style={{ background: c.background_colour || '#000' }}>
|
|
||||||
{m && <video ref={ref} src={m.src} autoPlay muted={c.muted !== false} playsInline loop={!slide.video_to_end}
|
|
||||||
onEnded={slide.video_to_end ? onEnded : undefined} onError={slide.video_to_end ? onEnded : undefined}
|
|
||||||
className="w-full h-full" style={{ objectFit: c.fit || 'cover' }} data-testid="signage-video" />}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import xenia from '@xenia/ui/tailwind-preset'
|
|||||||
export default {
|
export default {
|
||||||
// Shared design tokens only (bg-surface, text-ink-2, rounded-control…), CS-16
|
// Shared design tokens only (bg-surface, text-ink-2, rounded-control…), CS-16
|
||||||
presets: [xenia],
|
presets: [xenia],
|
||||||
content: ['./index.html', './src/**/*.{js,jsx}'],
|
content: ['./index.html', './src/**/*.{js,jsx}', '../packages/signage/src/**/*.{js,jsx}'], // signage slides use a few utilities (5.6a)
|
||||||
theme: { extend: {} },
|
theme: { extend: {} },
|
||||||
plugins: [],
|
plugins: [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const suites = [
|
|||||||
['unit: packages/i18n (node --test + guard)', 'npm', ['test', '--silent', '-w', '@xenia/i18n'], CS],
|
['unit: packages/i18n (node --test + guard)', 'npm', ['test', '--silent', '-w', '@xenia/i18n'], CS],
|
||||||
['unit: packages/api (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/api'], CS],
|
['unit: packages/api (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/api'], CS],
|
||||||
['unit: packages/access (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/access'], CS],
|
['unit: packages/access (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/access'], CS],
|
||||||
|
['unit: packages/signage (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/signage'], CS],
|
||||||
['unit: manager_dashboard (node --test)', 'npm', ['test', '--silent', '-w', 'manager-dashboard'], CS],
|
['unit: manager_dashboard (node --test)', 'npm', ['test', '--silent', '-w', 'manager-dashboard'], CS],
|
||||||
['lint: manager_dashboard (v2 code)', 'npm', ['run', 'lint', '--silent', '-w', 'manager-dashboard'], CS],
|
['lint: manager_dashboard (v2 code)', 'npm', ['run', 'lint', '--silent', '-w', 'manager-dashboard'], CS],
|
||||||
['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS],
|
['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS],
|
||||||
|
|||||||
+67
-5
@@ -1,20 +1,28 @@
|
|||||||
// Signage suite (plan steps 5.5a, 5.5b): a TV paired as a signage screen plays its playlist (picture,
|
// Signage suite (plan steps 5.5a, 5.5b, 5.6a): a TV paired as a signage screen plays its playlist (picture,
|
||||||
// text, video to its end, menu board) in order with transitions, turns for a TV mounted sideways,
|
// text, video to its end, menu board) in order with transitions, turns for a TV mounted sideways,
|
||||||
// keeps playing with the server stopped (a quiet mark, no banner), and catches up when it is back.
|
// keeps playing with the server stopped (a quiet mark, no banner), and catches up when it is back.
|
||||||
// Starts its own backend (:8065) and the terminal (:5193).
|
// Starts its own backend (:8065) and the terminal (:5193).
|
||||||
// node signage.mjs
|
// node signage.mjs
|
||||||
import { execFileSync } from 'node:child_process'
|
import { execFileSync, spawn } from 'node:child_process'
|
||||||
|
import { openSync } from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { chromium } from 'playwright'
|
import { chromium } from 'playwright'
|
||||||
import { BROWSER_CHANNEL, OUT, PYTHON, reporter, sleep, waitFor } from './lib/env.mjs'
|
import { BROWSER_CHANNEL, CS, OUT, PYTHON, reporter, sleep, waitFor } from './lib/env.mjs'
|
||||||
import { startBackend, startTerminalVite } from './lib/proc.mjs'
|
import { killTree, startBackend, startTerminalVite, waitHttp } from './lib/proc.mjs'
|
||||||
import { supportLogin } from './lib/support.mjs'
|
import { supportLogin } from './lib/support.mjs'
|
||||||
|
|
||||||
let backend = await startBackend({ port: 8065, siteId: 'test-site-1', env: { LICENSE_MODE: 'off' } })
|
let backend = await startBackend({ port: 8065, siteId: 'test-site-1', env: { LICENSE_MODE: 'off' } })
|
||||||
const dataDir = backend.dataDir
|
const dataDir = backend.dataDir
|
||||||
const term = await startTerminalVite({ port: 5193, backendUrl: backend.url })
|
const term = await startTerminalVite({ port: 5193, backendUrl: backend.url })
|
||||||
|
const MPORT = 5194
|
||||||
|
const MANAGER = `http://localhost:${MPORT}`
|
||||||
|
const mlog = openSync(path.join(OUT, `vite-${MPORT}.log`), 'w')
|
||||||
|
const managerVite = spawn('npx', ['vite', '--port', String(MPORT), '--strictPort'], {
|
||||||
|
cwd: path.join(CS, 'manager_dashboard'), shell: process.platform === 'win32', detached: process.platform !== 'win32',
|
||||||
|
stdio: ['ignore', mlog, mlog], env: { ...process.env, XENIA_BACKEND: backend.url },
|
||||||
|
})
|
||||||
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||||
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b)')
|
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b), the editor (5.6a)')
|
||||||
const errors = []
|
const errors = []
|
||||||
let failures = 0
|
let failures = 0
|
||||||
|
|
||||||
@@ -177,6 +185,59 @@ try {
|
|||||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
||||||
await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300)
|
await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300)
|
||||||
|
|
||||||
|
// ── 5.6a: the editor in the manager ──────────────────────────────────────
|
||||||
|
await waitHttp(`${MANAGER}/`)
|
||||||
|
const tallJpg = execFileSync(PYTHON, ['-c', "import io,sys;from PIL import Image;b=io.BytesIO();Image.new('RGB',(1080,1920),(30,140,90)).save(b,'JPEG');sys.stdout.buffer.write(b.getvalue())"])
|
||||||
|
const tallPhoto = await upload(boss, tallJpg, 'tall poster.jpg', 'image/jpeg')
|
||||||
|
const mgr = await (await browser.newContext({ viewport: { width: 1440, height: 900 } })).newPage()
|
||||||
|
mgr.on('pageerror', e => errors.push(e.message))
|
||||||
|
await mgr.goto(`${MANAGER}/login`)
|
||||||
|
await mgr.getByTestId('login-form').waitFor({ timeout: 60_000 })
|
||||||
|
if (!(await mgr.getByTestId('login-account').count())) await mgr.getByLabel('Username').fill('manager')
|
||||||
|
await mgr.getByLabel('Password').fill('password')
|
||||||
|
await mgr.getByRole('button', { name: 'Sign in', exact: true }).click()
|
||||||
|
await mgr.waitForURL(u => u.pathname !== '/login', { timeout: 20_000 })
|
||||||
|
await mgr.goto(`${MANAGER}/management/signage`)
|
||||||
|
r.check('5.6a: Management → Signage lists the playlists', await shown(mgr, 'signage-playlist-item', 20_000)
|
||||||
|
&& await mgr.getByTestId('signage-playlist-item').count() >= 2)
|
||||||
|
await mgr.getByTestId('signage-new-playlist').click()
|
||||||
|
await mgr.getByTestId('signage-new-name').fill('Opening')
|
||||||
|
await mgr.getByTestId('signage-create-playlist').click()
|
||||||
|
await waitFor(async () => (await mgr.getByTestId('signage-playlist-name').inputValue().catch(() => '')) === 'Opening', 15_000, 200)
|
||||||
|
await mgr.getByRole('dialog').waitFor({ state: 'detached', timeout: 5000 }).catch(() => {})
|
||||||
|
await mgr.getByTestId('signage-add-slide').click()
|
||||||
|
r.check('5.6a: "Add a slide" offers empty slides and ready-made ones with a preview',
|
||||||
|
await mgr.getByTestId('signage-template-preview').count() >= 5)
|
||||||
|
await mgr.getByTestId('signage-template-announcement').click()
|
||||||
|
await mgr.getByTestId('signage-slide-editor').waitFor({ timeout: 10_000 })
|
||||||
|
await mgr.getByTestId('signage-text-title').fill('Opening soon')
|
||||||
|
r.check('5.6a: the preview follows the editor as you type (as the TV draws it)',
|
||||||
|
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-title').textContent().catch(() => '')) === 'Opening soon', 5000, 200))
|
||||||
|
await mgr.getByTestId('signage-slide-save').click()
|
||||||
|
await sleep(800)
|
||||||
|
await mgr.getByTestId('signage-add-slide').click()
|
||||||
|
await mgr.getByTestId('signage-template-promo').click()
|
||||||
|
await mgr.getByTestId('signage-picture-pick').click({ timeout: 10_000 })
|
||||||
|
await mgr.getByTestId('media-picker').locator(`[data-testid="media-item"][data-id="${tallPhoto.id}"]`).click()
|
||||||
|
r.check('5.6a: a tall picture on a landscape playlist is flagged', await shown(mgr, 'signage-picture-misfit', 5000))
|
||||||
|
await mgr.getByTestId('signage-slide-save').click()
|
||||||
|
await sleep(800)
|
||||||
|
r.check('5.6a: …and the timeline card shows the warning', await mgr.getByTestId('signage-card-misfit').count() === 1)
|
||||||
|
await mgr.screenshot({ path: path.join(OUT, 'signage-editor.png'), fullPage: true })
|
||||||
|
// the picture first: the arrow on its card
|
||||||
|
await mgr.getByTestId('signage-slide-card').nth(1).getByTestId('signage-up').click()
|
||||||
|
await sleep(800)
|
||||||
|
const opening = (await api('GET', '/api/signage/playlists', { token: boss })).find(p => p.name === 'Opening')
|
||||||
|
const full = await api('GET', `/api/signage/playlists/${opening.id}`, { token: boss })
|
||||||
|
r.check('5.6a: built in the manager: the picture, then the text "Opening soon"', full.slides.map(x => x.kind).join(',') === 'image,text'
|
||||||
|
&& full.slides[1].content.title === 'Opening soon' && full.slides[0].content.media_id === tallPhoto.id, JSON.stringify(full.slides.map(x => [x.kind, x.content.title])))
|
||||||
|
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: opening.id } })
|
||||||
|
const onTv = await waitFor(async () => ((await tv.getByTestId('signage-title').allTextContents().catch(() => [])).includes('Opening soon') ? true : null), 30_000, 300)
|
||||||
|
r.check('5.6a: …and the TV plays it', !!onTv)
|
||||||
|
await mgr.context().close()
|
||||||
|
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
||||||
|
await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300)
|
||||||
|
|
||||||
// ── the server stops: the TV keeps playing ────────────────────────────────
|
// ── the server stops: the TV keeps playing ────────────────────────────────
|
||||||
await backend.stop()
|
await backend.stop()
|
||||||
const offlineOrder = await watch(tv, 14_000)
|
const offlineOrder = await watch(tv, 14_000)
|
||||||
@@ -204,6 +265,7 @@ try {
|
|||||||
} finally {
|
} finally {
|
||||||
await browser.close()
|
await browser.close()
|
||||||
term.stop()
|
term.stop()
|
||||||
|
killTree(managerVite)
|
||||||
await backend.stop()
|
await backend.stop()
|
||||||
}
|
}
|
||||||
process.exit(failures ? 1 : 0)
|
process.exit(failures ? 1 : 0)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ COPY packages/ui/package.json packages/ui/
|
|||||||
COPY packages/i18n/package.json packages/i18n/
|
COPY packages/i18n/package.json packages/i18n/
|
||||||
COPY packages/api/package.json packages/api/
|
COPY packages/api/package.json packages/api/
|
||||||
COPY packages/access/package.json packages/access/
|
COPY packages/access/package.json packages/access/
|
||||||
|
COPY packages/signage/package.json packages/signage/
|
||||||
COPY waiter_pwa/package.json waiter_pwa/
|
COPY waiter_pwa/package.json waiter_pwa/
|
||||||
COPY manager_dashboard/package.json manager_dashboard/
|
COPY manager_dashboard/package.json manager_dashboard/
|
||||||
COPY terminal/package.json terminal/
|
COPY terminal/package.json terminal/
|
||||||
|
|||||||
Reference in New Issue
Block a user