feat(manager): the menu board editor and widgets (platform-v2 step 5.6b)
- Menu board: everything or chosen whole categories (sub-categories included, new products join) plus single products found by search; hide a product from the board (and show it again); the board's own order with arrows on what the server resolved (categories and products; boardOrder writes it); a badge per product; grouping, headings, photos, descriptions, whose prices (a sales point or none), sold out crossed out or hidden, columns, products per page (or as many as fit), seconds per page; colours, font, size, background. - Widgets (text and menu slides): logo, venue name, date (long / short), clock (seconds), message of the day (or its own text), QR code (ordering / QR menu / a link + caption), weather (1-3 days, says it needs internet); where (corners, bars) and size. - The preview stays in view while the settings scroll. - @xenia/signage: the venue clock's Intl call names its time zone where the i18n guard reads it. - tests: manager signage.test.mjs +1; e2e signage.mjs builds a menu board in the editor (categories, a single product, the order, a badge, hiding, a clock) and checks what was saved and resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-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`). **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/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. The menu board editor (5.6b, `MenuEditor.jsx`) orders what the server resolved: `boardOrder()` writes the whole shown order into `category_order` / `product_order`; widgets: `WidgetsEditor.jsx`. **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()` |
|
||||||
|
|||||||
@@ -1,27 +1,184 @@
|
|||||||
// A menu board's settings (plan steps 5.6a, 5.6b): its title, look and background. Which products
|
// A menu board's settings (plan step 5.6b): which products (everything, whole categories that stay
|
||||||
// it lists and in what order: step 5.6b.
|
// up to date, single products, minus hidden ones), the board's own order of categories and products
|
||||||
import { useTranslation } from '@xenia/i18n'
|
// (arrows on what the board shows), badges, prices of a sales point, photos / descriptions, sold-out
|
||||||
import { Field, Input, Select } from '@xenia/ui'
|
// style, columns and pages, the look, and the widgets. `slide.menu` is the server's resolution of
|
||||||
|
// the draft (PlaylistEditor asks for it as you change things).
|
||||||
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import { ArrowDown, ArrowUp, EyeOff, X } from 'lucide-react'
|
||||||
|
import { SALES_POINTS } from '@xenia/access'
|
||||||
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||||
|
import { Field, IconButton, Input, Select, Switch } from '@xenia/ui'
|
||||||
|
import client from '../../api/client'
|
||||||
|
import { BADGES, boardOrder, moveGroup, moveItem, toggled } from './signageLogic'
|
||||||
import { BackgroundField, ColourField } from './SignageFields'
|
import { BackgroundField, ColourField } from './SignageFields'
|
||||||
import { TextLook } from './SlideEditor'
|
import { TextLook } from './SlideEditor'
|
||||||
|
import WidgetsEditor from './WidgetsEditor'
|
||||||
|
|
||||||
export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
|
const { formatMoney } = useFormat()
|
||||||
const c = slide.content || {}
|
const c = slide.content || {}
|
||||||
const setC = patch => onChange({ ...slide, content: { ...c, ...patch } })
|
const setC = patch => onChange({ ...slide, content: { ...c, ...patch } })
|
||||||
|
const [cats, setCats] = useState([])
|
||||||
|
const [products, setProducts] = useState([])
|
||||||
|
const [q, setQ] = useState('')
|
||||||
|
useEffect(() => {
|
||||||
|
client.get('/api/products/categories').then(r => setCats(r.data)).catch(() => {})
|
||||||
|
client.get('/api/products/').then(r => setProducts(r.data.filter(p => p.lifecycle_status === 'active' && !p.is_service_item))).catch(() => {})
|
||||||
|
}, [])
|
||||||
|
const byId = useMemo(() => Object.fromEntries(products.map(p => [p.id, p])), [products])
|
||||||
|
const top = cats.filter(x => !x.parent_id)
|
||||||
|
const subsOf = id => cats.filter(x => x.parent_id === id)
|
||||||
|
const groups = slide.menu?.groups || []
|
||||||
|
const shown = new Set(groups.flatMap(g => g.items.map(i => i.id)))
|
||||||
|
const found = q.trim().length < 1 ? [] : products.filter(p => p.name.toLowerCase().includes(q.trim().toLowerCase()) && !shown.has(p.id)).slice(0, 8)
|
||||||
|
const reorder = next => setC(boardOrder(next))
|
||||||
|
const badges = c.badges || {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-3" data-testid="signage-menu-editor">
|
<div className="grid gap-4" 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>
|
<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')}>
|
{/* what it lists */}
|
||||||
<Select value={String(c.columns || 2)} onChange={e => setC({ columns: Number(e.target.value) })}
|
<fieldset className="grid gap-3 rounded-control border border-line p-3">
|
||||||
options={[1, 2, 3].map(n => ({ value: String(n), label: String(n) }))} data-testid="signage-columns" />
|
<legend className="px-1 text-label font-medium text-ink-2">{t('signage.menu.what')}</legend>
|
||||||
|
<Select value={c.select || 'custom'} onChange={e => setC({ select: e.target.value })} aria-label={t('signage.menu.what')} data-testid="signage-menu-select"
|
||||||
|
options={[{ value: 'all', label: t('signage.menu.all') }, { value: 'custom', label: t('signage.menu.custom') }]} />
|
||||||
|
{c.select !== 'all' && <>
|
||||||
|
<div className="grid gap-1.5">
|
||||||
|
<span className="text-label text-ink-2">{t('signage.menu.categories')}</span>
|
||||||
|
<p className="text-caption text-ink-3">{t('signage.menu.categoriesHint')}</p>
|
||||||
|
<div className="flex flex-wrap gap-1.5" data-testid="signage-menu-categories">
|
||||||
|
{top.flatMap(cat => [cat, ...subsOf(cat.id)]).map(cat => {
|
||||||
|
const on = (c.category_ids || []).includes(cat.id)
|
||||||
|
return (
|
||||||
|
<button key={cat.id} type="button" aria-pressed={on} onClick={() => setC({ category_ids: toggled(c.category_ids, cat.id) })}
|
||||||
|
data-testid="signage-menu-category" data-name={cat.name}
|
||||||
|
className={`px-2.5 py-1 rounded-control border text-label transition-colors duration-fast
|
||||||
|
${on ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface-2 text-ink hover:bg-surface-3'}`}>
|
||||||
|
{cat.parent_id ? `↳ ${cat.name}` : cat.name}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-1.5">
|
||||||
|
<span className="text-label text-ink-2">{t('signage.menu.products')}</span>
|
||||||
|
{(c.product_ids || []).length > 0 && (
|
||||||
|
<div className="flex flex-wrap gap-1.5">
|
||||||
|
{(c.product_ids || []).map(id => (
|
||||||
|
<span key={id} className="inline-flex items-center gap-1 pl-2.5 pr-1 py-0.5 rounded-control bg-surface-2 text-label text-ink">
|
||||||
|
{byId[id]?.name ?? `#${id}`}
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('media.removePhoto')} onClick={() => setC({ product_ids: (c.product_ids || []).filter(x => x !== id) })}><X size={12} /></IconButton>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Input value={q} onChange={e => setQ(e.target.value)} placeholder={t('signage.menu.searchProduct')} aria-label={t('signage.menu.searchProduct')} data-testid="signage-menu-search" />
|
||||||
|
{found.length > 0 && (
|
||||||
|
<ul className="grid gap-1" data-testid="signage-menu-found">
|
||||||
|
{found.map(p => (
|
||||||
|
<li key={p.id}>
|
||||||
|
<button type="button" className="w-full text-left px-2 py-1 rounded-control hover:bg-surface-2 text-label text-ink" data-testid="signage-menu-found-item"
|
||||||
|
onClick={() => { setC({ product_ids: toggled(c.product_ids, p.id), exclude_ids: (c.exclude_ids || []).filter(x => x !== p.id) }); setQ('') }}>
|
||||||
|
+ {p.name}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>}
|
||||||
|
{(c.exclude_ids || []).length > 0 && (
|
||||||
|
<div className="grid gap-1.5">
|
||||||
|
<span className="text-label text-ink-2">{t('signage.menu.hidden')}</span>
|
||||||
|
<div className="flex flex-wrap gap-1.5">
|
||||||
|
{(c.exclude_ids || []).map(id => (
|
||||||
|
<button key={id} type="button" onClick={() => setC({ exclude_ids: (c.exclude_ids || []).filter(x => x !== id) })}
|
||||||
|
className="px-2.5 py-1 rounded-control border border-line bg-surface-2 text-label text-ink-2 hover:bg-surface-3" title={t('signage.menu.showAgain')}>
|
||||||
|
{byId[id]?.name ?? `#${id}`} · {t('signage.menu.showAgain')}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
{/* the board's own order, badges, hiding */}
|
||||||
|
<fieldset className="grid gap-2 rounded-control border border-line p-3">
|
||||||
|
<legend className="px-1 text-label font-medium text-ink-2">{t('signage.menu.onTheBoard', { count: slide.menu?.count ?? 0 })}</legend>
|
||||||
|
<p className="text-caption text-ink-3">{t('signage.menu.orderHint')}</p>
|
||||||
|
<div className="grid gap-3 max-h-[28rem] overflow-auto pr-1" data-testid="signage-menu-board">
|
||||||
|
{groups.map((g, gi) => (
|
||||||
|
<div key={`${g.category?.id ?? 'all'}`} className="grid gap-1" data-testid="signage-menu-group" data-name={g.category?.name ?? ''}>
|
||||||
|
{g.category && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<span className="text-label font-semibold text-ink flex-1">{g.category.name}</span>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={gi === 0} onClick={() => reorder(moveGroup(groups, gi, -1))} data-testid="signage-group-up"><ArrowUp size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={gi === groups.length - 1} onClick={() => reorder(moveGroup(groups, gi, 1))}><ArrowDown size={14} /></IconButton>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<ul className="grid gap-0.5">
|
||||||
|
{g.items.map((it, ii) => (
|
||||||
|
<li key={it.id} className="flex items-center gap-1.5 pl-2 rounded-control hover:bg-surface-2" data-testid="signage-menu-row" data-id={it.id}>
|
||||||
|
<span className={`flex-1 min-w-0 truncate text-label ${it.available ? 'text-ink' : 'text-ink-3 line-through'}`}>{it.name}</span>
|
||||||
|
{it.price != null && <span className="text-caption text-ink-2 tabular-nums">{formatMoney(it.price)}</span>}
|
||||||
|
<Select size="sm" value={badges[String(it.id)] || ''} aria-label={t('signage.menu.badge')} data-testid="signage-menu-badge"
|
||||||
|
onChange={e => {
|
||||||
|
const next = { ...badges }
|
||||||
|
if (e.target.value) next[String(it.id)] = e.target.value
|
||||||
|
else delete next[String(it.id)]
|
||||||
|
setC({ badges: next })
|
||||||
|
}}
|
||||||
|
options={[{ value: '', label: t('signage.menu.noBadge') }, ...BADGES.map(b => ({ value: b, label: t(`signage.badges.${b}`) }))]} />
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={ii === 0} onClick={() => reorder(moveItem(groups, gi, ii, -1))} data-testid="signage-item-up"><ArrowUp size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={ii === g.items.length - 1} onClick={() => reorder(moveItem(groups, gi, ii, 1))}><ArrowDown size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.menu.hide')} data-testid="signage-item-hide"
|
||||||
|
onClick={() => setC({ exclude_ids: toggled(c.exclude_ids, it.id), product_ids: (c.product_ids || []).filter(x => x !== it.id) })}><EyeOff size={14} /></IconButton>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{groups.length === 0 && <p className="text-label text-ink-3">{t('signage.menu.empty')}</p>}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
{/* what each line shows, and the pages */}
|
||||||
|
<fieldset className="grid gap-3 rounded-control border border-line p-3 sm:grid-cols-2">
|
||||||
|
<legend className="px-1 text-label font-medium text-ink-2">{t('signage.menu.options')}</legend>
|
||||||
|
<Switch checked={c.group_by_category !== false} onChange={on => setC({ group_by_category: on })} label={t('signage.menu.group')} data-testid="signage-menu-group-switch" />
|
||||||
|
<Switch checked={c.category_titles !== false} onChange={on => setC({ category_titles: on })} label={t('signage.menu.headings')} />
|
||||||
|
<Switch checked={!!c.show_photos} onChange={on => setC({ show_photos: on })} label={t('signage.menu.photos')} data-testid="signage-menu-photos" />
|
||||||
|
<Switch checked={!!c.show_descriptions} onChange={on => setC({ show_descriptions: on })} label={t('signage.menu.descriptions')} />
|
||||||
|
<Field label={t('signage.menu.prices')}>
|
||||||
|
<Select value={c.sales_point ?? ''} onChange={e => setC({ sales_point: e.target.value || null })} data-testid="signage-menu-prices"
|
||||||
|
options={[{ value: '', label: t('signage.menu.noPrices') }, ...SALES_POINTS.map(sp => ({ value: sp, label: t(`common:salesPoints.${sp}.name`) }))]} />
|
||||||
</Field>
|
</Field>
|
||||||
|
<Field label={t('signage.menu.soldOut')}>
|
||||||
|
<Select value={c.sold_out || 'strike'} onChange={e => setC({ sold_out: e.target.value })}
|
||||||
|
options={[{ value: 'strike', label: t('signage.menu.strike') }, { value: 'hide', label: t('signage.menu.hideSoldOut') }]} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.columns')}>
|
||||||
|
<Select value={String(c.columns || 2)} onChange={e => setC({ columns: Number(e.target.value) })} data-testid="signage-columns"
|
||||||
|
options={[1, 2, 3].map(n => ({ value: String(n), label: String(n) }))} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.menu.perPage')} hint={t('signage.menu.perPageHint')}>
|
||||||
|
<Input inputMode="numeric" value={c.page_size ? String(c.page_size) : ''} placeholder={t('signage.menu.auto')}
|
||||||
|
onChange={e => { const n = Number(e.target.value.replace(/\D/g, '')); setC({ page_size: n ? Math.min(60, Math.max(3, n)) : null }) }} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.menu.pageSeconds')}>
|
||||||
|
<Input inputMode="numeric" value={String(c.page_seconds || 10)} onChange={e => setC({ page_seconds: Math.min(120, Math.max(3, Number(e.target.value.replace(/\D/g, '')) || 3)) })} />
|
||||||
|
</Field>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
<ColourField label={t('signage.accent')} value={c.accent_colour || '#f59e0b'} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
<ColourField label={t('signage.accent')} value={c.accent_colour || '#f59e0b'} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
||||||
</div>
|
</div>
|
||||||
<TextLook c={c} setC={setC} align={false} />
|
<TextLook c={c} setC={setC} align={false} />
|
||||||
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
||||||
misfit={misfit.includes(c.background?.media_id)} />
|
misfit={misfit.includes(c.background?.media_id)} />
|
||||||
|
<WidgetsEditor widgets={c.widgets || []} onChange={widgets => setC({ widgets })} media={media} onMedia={onMedia} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,8 +158,11 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) {
|
|||||||
{/* the slide being edited */}
|
{/* the slide being edited */}
|
||||||
<section className="grid gap-4 content-start">
|
<section className="grid gap-4 content-start">
|
||||||
{draft ? <>
|
{draft ? <>
|
||||||
<SlidePreview slide={draft} media={mediaLookup(media)} venue={venue} orientation={pl.orientation} playing
|
{/* the preview stays in view while the settings below scroll */}
|
||||||
className={pl.orientation === 'portrait' ? 'max-w-xs mx-auto w-full' : 'w-full'} />
|
<div className="sticky top-0 z-10 bg-canvas pb-2">
|
||||||
|
<SlidePreview slide={draft} media={mediaLookup(media)} venue={venue} orientation={pl.orientation} playing
|
||||||
|
className={pl.orientation === 'portrait' ? 'max-w-[13rem] mx-auto w-full' : 'w-full max-w-2xl mx-auto'} />
|
||||||
|
</div>
|
||||||
<SlideEditor slide={draft} onChange={setDraft} media={media} onMedia={item => setMedia(m => ({ ...m, [String(item.id)]: mediaEntry(item) }))}
|
<SlideEditor slide={draft} onChange={setDraft} media={media} onMedia={item => setMedia(m => ({ ...m, [String(item.id)]: mediaEntry(item) }))}
|
||||||
misfit={draftBad} />
|
misfit={draftBad} />
|
||||||
<div className="flex gap-2 items-center sticky bottom-0 bg-canvas py-2">
|
<div className="flex gap-2 items-center sticky bottom-0 bg-canvas py-2">
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Field, Input, Select, Switch, Textarea } from '@xenia/ui'
|
|||||||
import { FONT_KEYS, TRANSITIONS } from './signageLogic'
|
import { FONT_KEYS, TRANSITIONS } from './signageLogic'
|
||||||
import { BackgroundField, ColourField, MediaPick } from './SignageFields'
|
import { BackgroundField, ColourField, MediaPick } from './SignageFields'
|
||||||
import MenuEditor from './MenuEditor'
|
import MenuEditor from './MenuEditor'
|
||||||
|
import WidgetsEditor from './WidgetsEditor'
|
||||||
|
|
||||||
export default function SlideEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
export default function SlideEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
@@ -98,6 +99,7 @@ export default function SlideEditor({ slide, onChange, media, onMedia, misfit =
|
|||||||
<TextLook c={c} setC={setC} />
|
<TextLook c={c} setC={setC} />
|
||||||
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
||||||
misfit={bad(c.background?.media_id)} />
|
misfit={bad(c.background?.media_id)} />
|
||||||
|
<WidgetsEditor widgets={c.widgets || []} onChange={widgets => setC({ widgets })} media={media} onMedia={onMedia} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// The widgets of a text or menu slide (plan step 5.6b): logo, name, date, clock, message of the
|
||||||
|
// day, QR code, weather; each in a corner or a bar, small / medium / large, with its own options.
|
||||||
|
// Up to 10 (the server's limit).
|
||||||
|
import { Plus, Trash2 } from 'lucide-react'
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, Field, IconButton, Input, Select, Switch } from '@xenia/ui'
|
||||||
|
import { MediaPick } from './SignageFields'
|
||||||
|
import { WIDGET_KINDS, WIDGET_POSITIONS } from './signageLogic'
|
||||||
|
|
||||||
|
export default function WidgetsEditor({ widgets = [], onChange, media, onMedia }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const set = (i, patch) => onChange(widgets.map((w, j) => (j === i ? { ...w, ...patch } : w)))
|
||||||
|
const add = kind => onChange([...widgets, { kind, position: kind === 'message' ? 'bottom-bar' : 'top-right', size: 'medium' }])
|
||||||
|
return (
|
||||||
|
<fieldset className="grid gap-3 rounded-control border border-line p-3" data-testid="signage-widgets">
|
||||||
|
<legend className="px-1 text-label font-medium text-ink-2">{t('signage.widgets.title')}</legend>
|
||||||
|
{widgets.length === 0 && <p className="text-caption text-ink-3">{t('signage.widgets.none')}</p>}
|
||||||
|
{widgets.map((w, i) => (
|
||||||
|
<div key={i} className="grid gap-2 rounded-control bg-surface-2 p-2" data-testid="signage-widget" data-kind={w.kind}>
|
||||||
|
<div className="flex flex-wrap items-end gap-2">
|
||||||
|
<span className="text-label font-medium text-ink min-w-[6rem] pb-2">{t(`signage.widgets.kinds.${w.kind}`)}</span>
|
||||||
|
<Field label={t('signage.widgets.position')} className="flex-1 min-w-[9rem]">
|
||||||
|
<Select value={w.position} onChange={e => set(i, { position: e.target.value })} data-testid="signage-widget-position"
|
||||||
|
options={WIDGET_POSITIONS.map(p => ({ value: p, label: t(`signage.widgets.positions.${p}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.widgets.size')}>
|
||||||
|
<Select value={w.size || 'medium'} onChange={e => set(i, { size: e.target.value })}
|
||||||
|
options={['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<IconButton variant="ghost" label={t('fees.delete')} onClick={() => onChange(widgets.filter((_, j) => j !== i))} data-testid="signage-widget-remove"><Trash2 size={16} /></IconButton>
|
||||||
|
</div>
|
||||||
|
{w.kind === 'logo' && (
|
||||||
|
<MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
|
||||||
|
onChange={item => { onMedia(item); set(i, { media_id: item.id }) }} />
|
||||||
|
)}
|
||||||
|
{w.kind === 'message' && (
|
||||||
|
<Field label={t('signage.widgets.ownText')} hint={t('signage.widgets.ownTextHint')}>
|
||||||
|
<Input value={w.text || ''} maxLength={200} onChange={e => set(i, { text: e.target.value || null })} data-testid="signage-widget-text" />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
{w.kind === 'date' && (
|
||||||
|
<Select value={w.date_style || 'long'} onChange={e => set(i, { date_style: e.target.value })} aria-label={t('signage.widgets.kinds.date')}
|
||||||
|
options={[{ value: 'long', label: t('signage.widgets.dateLong') }, { value: 'short', label: t('signage.widgets.dateShort') }]} />
|
||||||
|
)}
|
||||||
|
{w.kind === 'clock' && <Switch checked={!!w.clock_seconds} onChange={on => set(i, { clock_seconds: on })} label={t('signage.widgets.seconds')} />}
|
||||||
|
{w.kind === 'qr' && (
|
||||||
|
<div className="grid gap-2 sm:grid-cols-2">
|
||||||
|
<Field label={t('display.qrTarget')}>
|
||||||
|
<Select value={w.qr_target || 'ordering'} onChange={e => set(i, { qr_target: e.target.value })}
|
||||||
|
options={['ordering', 'menu', 'custom'].map(q => ({ value: q, label: t(`display.qrTargets.${q}`) }))} />
|
||||||
|
</Field>
|
||||||
|
{w.qr_target === 'custom' && (
|
||||||
|
<Field label={t('display.qrUrl')}><Input value={w.qr_url || ''} placeholder="https://" onChange={e => set(i, { qr_url: e.target.value || null })} /></Field>
|
||||||
|
)}
|
||||||
|
<Field label={t('display.qrCaption')}><Input value={w.qr_caption || ''} maxLength={80} onChange={e => set(i, { qr_caption: e.target.value || null })} /></Field>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{w.kind === 'weather' && (
|
||||||
|
<div className="grid gap-1">
|
||||||
|
<Select value={String(w.weather_days || 1)} onChange={e => set(i, { weather_days: Number(e.target.value) })} aria-label={t('signage.widgets.weatherDays')}
|
||||||
|
options={[1, 2, 3].map(n => ({ value: String(n), label: t('signage.widgets.days', { count: n }) }))} />
|
||||||
|
<p className="text-caption text-ink-3">{t('signage.widgets.weatherNeedsInternet')}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{widgets.length < 10 && (
|
||||||
|
<div className="flex flex-wrap gap-1.5">
|
||||||
|
{WIDGET_KINDS.map(k => (
|
||||||
|
<Button key={k} size="sm" variant="secondary" icon={<Plus size={14} />} onClick={() => add(k)} data-testid={`signage-widget-add-${k}`}>
|
||||||
|
{t(`signage.widgets.kinds.${k}`)}</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</fieldset>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -115,3 +115,38 @@ export function mediaLookup(map) {
|
|||||||
return m ? { ...m, src: m.url } : null
|
return m ? { ...m, src: m.url } : null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── menu boards and widgets (5.6b) ───────────────────────────────────────────
|
||||||
|
|
||||||
|
export const WIDGET_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'qr', 'weather']
|
||||||
|
export const WIDGET_POSITIONS = ['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right', 'top-bar', 'bottom-bar']
|
||||||
|
export const BADGES = ['new', 'chef', 'offer', 'popular', 'spicy', 'vegetarian', 'vegan']
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The board's own order from the groups as they are shown: categories in that order, every product
|
||||||
|
* in that order (the server puts listed ids first, so this pins the whole board).
|
||||||
|
*/
|
||||||
|
export function boardOrder(groups) {
|
||||||
|
return {
|
||||||
|
category_order: groups.filter(g => g.category).map(g => g.category.id),
|
||||||
|
product_order: groups.flatMap(g => g.items.map(i => i.id)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Groups with group `i` moved by `d` (−1 up, +1 down). */
|
||||||
|
export function moveGroup(groups, i, d) {
|
||||||
|
return moved(groups, i, i + d)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Groups with item `ii` of group `gi` moved by `d` inside its group. */
|
||||||
|
export function moveItem(groups, gi, ii, d) {
|
||||||
|
return groups.map((g, j) => (j === gi ? { ...g, items: moved(g.items, ii, ii + d) } : g))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toggle an id in a list (kept sorted for stable saves). */
|
||||||
|
export function toggled(list, id) {
|
||||||
|
const set = new Set(list || [])
|
||||||
|
if (set.has(id)) set.delete(id)
|
||||||
|
else set.add(id)
|
||||||
|
return [...set].sort((a, b) => a - b)
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,3 +45,15 @@ test('what is sent back, and library items as the slides need them', () => {
|
|||||||
assert.deepEqual(mediaEntry({ id: 3, kind: 'video', name: 'v', width: 1, height: 2, duration_ms: 5, urls: { original: '/o' } }).url, '/o')
|
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')
|
assert.equal(mediaEntry({ id: 3, kind: 'image', urls: { full: '/f', original: '/o', thumb: '/t' } }).url, '/f')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('the board\'s own order from what it shows; moving categories and products; toggling ids', async () => {
|
||||||
|
const { boardOrder, moveGroup, moveItem, toggled } = await import('../src/pages/signage/signageLogic.js')
|
||||||
|
const groups = [{ category: { id: 1 }, items: [{ id: 10 }, { id: 11 }] }, { category: { id: 2 }, items: [{ id: 20 }] }]
|
||||||
|
assert.deepEqual(boardOrder(groups), { category_order: [1, 2], product_order: [10, 11, 20] })
|
||||||
|
assert.deepEqual(boardOrder(moveGroup(groups, 1, -1)), { category_order: [2, 1], product_order: [20, 10, 11] })
|
||||||
|
assert.deepEqual(boardOrder(moveItem(groups, 0, 1, -1)).product_order, [11, 10, 20])
|
||||||
|
assert.deepEqual(boardOrder([{ category: null, items: [{ id: 5 }] }]), { category_order: [], product_order: [5] })
|
||||||
|
assert.deepEqual(toggled([3, 1], 2), [1, 2, 3])
|
||||||
|
assert.deepEqual(toggled([1, 2], 2), [1])
|
||||||
|
assert.deepEqual(toggled(undefined, 4), [4])
|
||||||
|
})
|
||||||
|
|||||||
@@ -964,6 +964,86 @@
|
|||||||
"colour": "Χρώμα",
|
"colour": "Χρώμα",
|
||||||
"dim": "Σκούρεμα φωτογραφίας: {{value}}%",
|
"dim": "Σκούρεμα φωτογραφίας: {{value}}%",
|
||||||
"columns": "Στήλες",
|
"columns": "Στήλες",
|
||||||
"accent": "Χρώμα τιμών και επικεφαλίδων"
|
"accent": "Χρώμα τιμών και επικεφαλίδων",
|
||||||
|
"menu": {
|
||||||
|
"what": "Τι δείχνει",
|
||||||
|
"all": "Όλα τα προϊόντα (και τα νέα)",
|
||||||
|
"custom": "Επιλεγμένες κατηγορίες και προϊόντα",
|
||||||
|
"categories": "Ολόκληρες κατηγορίες",
|
||||||
|
"categoriesHint": "Προϊόντα που προστίθενται αργότερα σε μια επιλεγμένη κατηγορία εμφανίζονται μόνα τους. Μια κατηγορία περιλαμβάνει τις υποκατηγορίες της.",
|
||||||
|
"products": "Μεμονωμένα προϊόντα (από οποιαδήποτε κατηγορία)",
|
||||||
|
"searchProduct": "Αναζήτηση προϊόντος για προσθήκη…",
|
||||||
|
"hidden": "Κρυμμένα από αυτό το μενού",
|
||||||
|
"showAgain": "εμφάνιση ξανά",
|
||||||
|
"hide": "Απόκρυψη από αυτό το μενού",
|
||||||
|
"onTheBoard_one": "Στο μενού: {{count}} προϊόν",
|
||||||
|
"onTheBoard_other": "Στο μενού: {{count}} προϊόντα",
|
||||||
|
"orderHint": "Η δική του σειρά: μετακινήστε κατηγορίες και προϊόντα με τα βέλη. Η σειρά των σερβιτόρων και του ταμείου δεν αλλάζει.",
|
||||||
|
"badge": "Σήμα",
|
||||||
|
"noBadge": "Χωρίς σήμα",
|
||||||
|
"empty": "Τίποτα ακόμα: διαλέξτε κατηγορίες ή προϊόντα παραπάνω.",
|
||||||
|
"options": "Τι δείχνει κάθε γραμμή",
|
||||||
|
"group": "Ομαδοποίηση ανά κατηγορία",
|
||||||
|
"headings": "Επικεφαλίδες κατηγοριών",
|
||||||
|
"photos": "Φωτογραφίες",
|
||||||
|
"descriptions": "Περιγραφές",
|
||||||
|
"prices": "Τιμές",
|
||||||
|
"noPrices": "Χωρίς τιμές",
|
||||||
|
"soldOut": "Εξαντλημένα",
|
||||||
|
"strike": "Διαγραμμένα",
|
||||||
|
"hideSoldOut": "Κρυμμένα",
|
||||||
|
"perPage": "Προϊόντα ανά σελίδα",
|
||||||
|
"perPageHint": "Κενό: όσα χωράνε στην τηλεόραση. Ένα μεγάλο μενού γυρίζει σελίδες.",
|
||||||
|
"auto": "Όσα χωράνε",
|
||||||
|
"pageSeconds": "Δευτερόλεπτα ανά σελίδα"
|
||||||
|
},
|
||||||
|
"badges": {
|
||||||
|
"new": "Νέο",
|
||||||
|
"chef": "Πρόταση σεφ",
|
||||||
|
"offer": "Προσφορά",
|
||||||
|
"popular": "Δημοφιλές",
|
||||||
|
"spicy": "Καυτερό",
|
||||||
|
"vegetarian": "Χορτοφαγικό",
|
||||||
|
"vegan": "Vegan"
|
||||||
|
},
|
||||||
|
"widgets": {
|
||||||
|
"title": "Στοιχεία",
|
||||||
|
"none": "Κανένα στοιχείο: προσθέστε ρολόι, λογότυπο, μήνυμα ημέρας…",
|
||||||
|
"kinds": {
|
||||||
|
"logo": "Λογότυπο",
|
||||||
|
"name": "Όνομα καταστήματος",
|
||||||
|
"date": "Ημερομηνία",
|
||||||
|
"clock": "Ρολόι",
|
||||||
|
"message": "Μήνυμα ημέρας",
|
||||||
|
"qr": "Κωδικός QR",
|
||||||
|
"weather": "Καιρός"
|
||||||
|
},
|
||||||
|
"position": "Πού",
|
||||||
|
"size": "Μέγεθος",
|
||||||
|
"sizes": {
|
||||||
|
"small": "Μικρό",
|
||||||
|
"medium": "Μεσαίο",
|
||||||
|
"large": "Μεγάλο"
|
||||||
|
},
|
||||||
|
"positions": {
|
||||||
|
"top-left": "Πάνω αριστερά",
|
||||||
|
"top-center": "Πάνω κέντρο",
|
||||||
|
"top-right": "Πάνω δεξιά",
|
||||||
|
"bottom-left": "Κάτω αριστερά",
|
||||||
|
"bottom-center": "Κάτω κέντρο",
|
||||||
|
"bottom-right": "Κάτω δεξιά",
|
||||||
|
"top-bar": "Μπάρα πάνω",
|
||||||
|
"bottom-bar": "Μπάρα κάτω"
|
||||||
|
},
|
||||||
|
"ownText": "Δικό του κείμενο (προαιρετικό)",
|
||||||
|
"ownTextHint": "Κενό: το μήνυμα ημέρας του καταστήματος (Προβολή → Οθόνες).",
|
||||||
|
"dateLong": "Τρίτη, 17 Νοεμβρίου 2026",
|
||||||
|
"dateShort": "17/11/2026",
|
||||||
|
"seconds": "Με δευτερόλεπτα",
|
||||||
|
"weatherDays": "Μέρες",
|
||||||
|
"days_one": "Σήμερα",
|
||||||
|
"days_other": "Σήμερα και {{count}} μέρες",
|
||||||
|
"weatherNeedsInternet": "Ο καιρός χρειάζεται internet: χωρίς αυτό (ή χωρίς πόλη) το στοιχείο κρύβεται."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -964,6 +964,86 @@
|
|||||||
"colour": "Colour",
|
"colour": "Colour",
|
||||||
"dim": "Darken the photo: {{value}}%",
|
"dim": "Darken the photo: {{value}}%",
|
||||||
"columns": "Columns",
|
"columns": "Columns",
|
||||||
"accent": "Prices and headings colour"
|
"accent": "Prices and headings colour",
|
||||||
|
"menu": {
|
||||||
|
"what": "What it lists",
|
||||||
|
"all": "Every product (new ones too)",
|
||||||
|
"custom": "Chosen categories and products",
|
||||||
|
"categories": "Whole categories",
|
||||||
|
"categoriesHint": "Products added to a chosen category later appear by themselves. A category includes its sub-categories.",
|
||||||
|
"products": "Single products (from any category)",
|
||||||
|
"searchProduct": "Search a product to add…",
|
||||||
|
"hidden": "Hidden from this board",
|
||||||
|
"showAgain": "show again",
|
||||||
|
"hide": "Hide from this board",
|
||||||
|
"onTheBoard_one": "On the board: {{count}} product",
|
||||||
|
"onTheBoard_other": "On the board: {{count}} products",
|
||||||
|
"orderHint": "The board's own order: move categories and products with the arrows. The waiters' and the counter's order doesn't change.",
|
||||||
|
"badge": "Badge",
|
||||||
|
"noBadge": "No badge",
|
||||||
|
"empty": "Nothing on the board yet: pick categories or products above.",
|
||||||
|
"options": "What each line shows",
|
||||||
|
"group": "Group by category",
|
||||||
|
"headings": "Category headings",
|
||||||
|
"photos": "Photos",
|
||||||
|
"descriptions": "Descriptions",
|
||||||
|
"prices": "Prices",
|
||||||
|
"noPrices": "No prices",
|
||||||
|
"soldOut": "Sold-out products",
|
||||||
|
"strike": "Crossed out",
|
||||||
|
"hideSoldOut": "Hidden",
|
||||||
|
"perPage": "Products per page",
|
||||||
|
"perPageHint": "Empty: as many as fit the TV. A long menu turns its pages.",
|
||||||
|
"auto": "As many as fit",
|
||||||
|
"pageSeconds": "Seconds per page"
|
||||||
|
},
|
||||||
|
"badges": {
|
||||||
|
"new": "New",
|
||||||
|
"chef": "Chef's pick",
|
||||||
|
"offer": "Offer",
|
||||||
|
"popular": "Popular",
|
||||||
|
"spicy": "Spicy",
|
||||||
|
"vegetarian": "Vegetarian",
|
||||||
|
"vegan": "Vegan"
|
||||||
|
},
|
||||||
|
"widgets": {
|
||||||
|
"title": "Widgets",
|
||||||
|
"none": "No widgets: add the clock, your logo, the message of the day…",
|
||||||
|
"kinds": {
|
||||||
|
"logo": "Logo",
|
||||||
|
"name": "Venue name",
|
||||||
|
"date": "Date",
|
||||||
|
"clock": "Clock",
|
||||||
|
"message": "Message of the day",
|
||||||
|
"qr": "QR code",
|
||||||
|
"weather": "Weather"
|
||||||
|
},
|
||||||
|
"position": "Where",
|
||||||
|
"size": "Size",
|
||||||
|
"sizes": {
|
||||||
|
"small": "Small",
|
||||||
|
"medium": "Medium",
|
||||||
|
"large": "Large"
|
||||||
|
},
|
||||||
|
"positions": {
|
||||||
|
"top-left": "Top left",
|
||||||
|
"top-center": "Top centre",
|
||||||
|
"top-right": "Top right",
|
||||||
|
"bottom-left": "Bottom left",
|
||||||
|
"bottom-center": "Bottom centre",
|
||||||
|
"bottom-right": "Bottom right",
|
||||||
|
"top-bar": "Bar at the top",
|
||||||
|
"bottom-bar": "Bar at the bottom"
|
||||||
|
},
|
||||||
|
"ownText": "Its own text (optional)",
|
||||||
|
"ownTextHint": "Empty: the venue's message of the day (Signage → Screens).",
|
||||||
|
"dateLong": "Tuesday, 17 November 2026",
|
||||||
|
"dateShort": "17/11/2026",
|
||||||
|
"seconds": "With seconds",
|
||||||
|
"weatherDays": "Days",
|
||||||
|
"days_one": "Today",
|
||||||
|
"days_other": "Today and {{count}} days",
|
||||||
|
"weatherNeedsInternet": "The weather needs internet: without it (or without a town set) the widget is hidden."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
/** The venue's local clock at `date`: { weekday (0 = Monday), minutes, date: "YYYY-MM-DD" }. */
|
/** The venue's local clock at `date`: { weekday (0 = Monday), minutes, date: "YYYY-MM-DD" }. */
|
||||||
export function localNow(timeZone, date = new Date()) {
|
export function localNow(timeZone, date = new Date()) {
|
||||||
const parts = Object.fromEntries(new Intl.DateTimeFormat('en-GB', {
|
// the venue's zone (the schedule's), not the TV's: a TV set to another zone still switches on time
|
||||||
timeZone: timeZone || undefined, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit',
|
const opts = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', weekday: 'short', hourCycle: 'h23' }
|
||||||
weekday: 'short', hourCycle: 'h23',
|
const parts = Object.fromEntries(new Intl.DateTimeFormat('en-GB', { timeZone: timeZone || undefined, ...opts })
|
||||||
}).formatToParts(date).map(p => [p.type, p.value]))
|
.formatToParts(date).map(p => [p.type, p.value]))
|
||||||
const weekday = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].indexOf(parts.weekday)
|
const weekday = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].indexOf(parts.weekday)
|
||||||
return { weekday, minutes: Number(parts.hour) * 60 + Number(parts.minute), date: `${parts.year}-${parts.month}-${parts.day}` }
|
return { weekday, minutes: Number(parts.hour) * 60 + Number(parts.minute), date: `${parts.year}-${parts.month}-${parts.day}` }
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-2
@@ -1,4 +1,4 @@
|
|||||||
// Signage suite (plan steps 5.5a, 5.5b, 5.6a): a TV paired as a signage screen plays its playlist (picture,
|
// Signage suite (plan steps 5.5a, 5.5b, 5.6a, 5.6b): 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).
|
||||||
@@ -22,7 +22,7 @@ const managerVite = spawn('npx', ['vite', '--port', String(MPORT), '--strictPort
|
|||||||
stdio: ['ignore', mlog, mlog], env: { ...process.env, XENIA_BACKEND: backend.url },
|
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), the editor (5.6a)')
|
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b), the editor (5.6a, 5.6b)')
|
||||||
const errors = []
|
const errors = []
|
||||||
let failures = 0
|
let failures = 0
|
||||||
|
|
||||||
@@ -234,6 +234,49 @@ try {
|
|||||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: opening.id } })
|
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)
|
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)
|
r.check('5.6a: …and the TV plays it', !!onTv)
|
||||||
|
// ── 5.6b: a menu board built in the editor ───────────────────────────────
|
||||||
|
const cats = await api('GET', '/api/products/categories', { token: boss })
|
||||||
|
const [catA, catB] = cats.filter(c => !c.parent_id)
|
||||||
|
const extra = products.find(x => x.category_id !== catA.id && x.category_id !== catB.id) || products[products.length - 1]
|
||||||
|
await mgr.getByTestId('signage-add-slide').click()
|
||||||
|
await mgr.getByTestId('signage-template-menuBoard').click()
|
||||||
|
await mgr.getByTestId('signage-menu-editor').waitFor({ timeout: 10_000 })
|
||||||
|
await mgr.getByTestId('signage-menu-select').selectOption('custom')
|
||||||
|
await mgr.locator(`[data-testid="signage-menu-category"][data-name="${catA.name}"]`).click()
|
||||||
|
await mgr.locator(`[data-testid="signage-menu-category"][data-name="${catB.name}"]`).click()
|
||||||
|
await mgr.getByTestId('signage-menu-search').fill(extra.name.slice(0, 4))
|
||||||
|
await mgr.getByTestId('signage-menu-found-item').filter({ hasText: extra.name }).first().click()
|
||||||
|
const groupsSeen = await waitFor(async () => {
|
||||||
|
const n = await mgr.getByTestId('signage-menu-group').count()
|
||||||
|
return n >= 2 ? n : null
|
||||||
|
}, 10_000, 300)
|
||||||
|
r.check('5.6b: chosen categories and a single product appear on the board (the server resolves the draft)', !!groupsSeen,
|
||||||
|
String(groupsSeen))
|
||||||
|
// the second category first; a badge on the first product shown; hide one
|
||||||
|
await mgr.getByTestId('signage-menu-group').nth(1).getByTestId('signage-group-up').click()
|
||||||
|
const firstRow = mgr.getByTestId('signage-menu-row').first()
|
||||||
|
await sleep(700)
|
||||||
|
const badgeId = Number(await firstRow.getAttribute('data-id'))
|
||||||
|
await firstRow.getByTestId('signage-menu-badge').selectOption('offer')
|
||||||
|
const hideRow = mgr.getByTestId('signage-menu-row').nth(1)
|
||||||
|
const hiddenId = Number(await hideRow.getAttribute('data-id'))
|
||||||
|
await hideRow.getByTestId('signage-item-hide').click()
|
||||||
|
await mgr.getByTestId('signage-widget-add-clock').click()
|
||||||
|
await sleep(900)
|
||||||
|
r.check('5.6b: the preview shows the board with its badge',
|
||||||
|
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-badge').count()) > 0, 8000, 300) === true)
|
||||||
|
await mgr.getByTestId('signage-slide-save').click()
|
||||||
|
await sleep(1000)
|
||||||
|
const op = (await api('GET', '/api/signage/playlists', { token: boss })).find(x => x.name === 'Opening')
|
||||||
|
const menuSlide = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu')
|
||||||
|
const mc = menuSlide?.content || {}
|
||||||
|
r.check('5.6b: saved: the categories, the single product, the hidden one, the board\'s own order, the badge, the clock',
|
||||||
|
mc.select === 'custom' && mc.category_ids?.includes(catA.id) && mc.category_ids?.includes(catB.id) && mc.product_ids?.includes(extra.id)
|
||||||
|
&& mc.exclude_ids?.includes(hiddenId) && mc.category_order?.[0] === catB.id && mc.badges?.[String(badgeId)] === 'offer'
|
||||||
|
&& (mc.widgets || []).some(w => w.kind === 'clock')
|
||||||
|
&& !menuSlide.menu.groups.flatMap(g => g.items).some(i => i.id === hiddenId) && menuSlide.menu.groups[0].category?.id === catB.id,
|
||||||
|
JSON.stringify({ select: mc.select, cats: mc.category_ids, prods: mc.product_ids, ex: mc.exclude_ids, order: mc.category_order, badges: mc.badges }))
|
||||||
|
await mgr.screenshot({ path: path.join(OUT, 'signage-menu-editor.png') })
|
||||||
await mgr.context().close()
|
await mgr.context().close()
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user