feat(manager): signage screens, schedules, the message of the day and the weather's town (platform-v2 step 5.6c)
Signage gets tabs: - Screens: every paired signage TV with what it plays (a playlist, or a schedule that wins over it), its shape and rotation, a warning when a playlist was made for the other shape; a link to pair one in Devices. - Schedules: lines (a playlist on days / between hours that may pass midnight / between dates, with a priority) and the playlist for the rest of the time; "now: …" per schedule; the screens on it. - Message and weather: the message of the day for every screen; the weather's town from a search (°C / °F), now / fetched at, "no forecast" when the server can't reach the service, fetch now, remove; says the weather needs internet and the widget hides without it. - e2e signage.mjs +6 (message saved, weather section, choosing a playlist and turning the picture move the TV, a schedule built in the manager plays what it picks now); a crash is reported as a failed check. 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/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/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/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`. Tabs (5.6c): Screens (`ScreensTab`: playlist, schedule, shape, rotation through `PUT /api/signage/screens/{id}`), Schedules (`SchedulesTab`), Message and weather (`SignageSettingsTab`: `PUT /api/signage/message`, the town search and `PUT /api/signage/weather/place`). **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/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()` |
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// Signage → Schedules (plan step 5.6c): which playlist plays when. A schedule is lines (a playlist
|
||||
// on some days, between some hours, between some dates, with a priority) and a playlist for the rest
|
||||
// of the time. When two lines match, the higher priority wins, then the more specific (dates, then
|
||||
// days, then hours). A TV with a schedule switches by itself, also while the server is down.
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { Plus, Trash2 } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, IconButton, Input, Select, Spinner } from '@xenia/ui'
|
||||
import * as api from './signageApi'
|
||||
|
||||
const emptyEntry = playlistId => ({ playlist_id: playlistId, days: [], time_from: null, time_to: null, date_from: null, date_to: null, priority: 0 })
|
||||
|
||||
export default function SchedulesTab() {
|
||||
const { t } = useTranslation('manager')
|
||||
const [list, setList] = useState(null)
|
||||
const [playlists, setPlaylists] = useState([])
|
||||
const [current, setCurrent] = useState(null)
|
||||
const [draft, setDraft] = useState(null)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [confirm, setConfirm] = useState(false)
|
||||
|
||||
const load = useCallback(async (pick) => {
|
||||
try {
|
||||
const [l, p] = await Promise.all([api.listSchedules(), api.listPlaylists()])
|
||||
setList(l); setPlaylists(p)
|
||||
const s = l.find(x => x.id === pick) || (pick === undefined ? l[0] : null)
|
||||
setCurrent(s?.id ?? null)
|
||||
setDraft(s ? { name: s.name, fallback_playlist_id: s.fallback_playlist_id, entries: s.entries } : null)
|
||||
} catch (err) { toast.error(errorMessage(err, t)) }
|
||||
}, [t])
|
||||
useEffect(() => { load() }, [load])
|
||||
const saved = list?.find(x => x.id === current)
|
||||
const dirty = useMemo(() => !!(saved && draft && JSON.stringify({ name: saved.name, fallback_playlist_id: saved.fallback_playlist_id, entries: saved.entries }) !== JSON.stringify(draft)), [saved, draft])
|
||||
if (!list) return <div className="flex justify-center p-6"><Spinner /></div>
|
||||
|
||||
const act = async (fn, done, pick = current) => {
|
||||
setBusy(true)
|
||||
try { const r = await fn(); toast.success(done); await load(r?.id ?? pick) } catch (err) { toast.error(errorMessage(err, t)) }
|
||||
setBusy(false)
|
||||
}
|
||||
const plOptions = playlists.map(p => ({ value: String(p.id), label: p.name }))
|
||||
const setEntry = (i, patch) => setDraft(d => ({ ...d, entries: d.entries.map((e, j) => (j === i ? { ...e, ...patch } : e)) }))
|
||||
const toggleDay = (i, day) => setEntry(i, { days: draft.entries[i].days.includes(day) ? draft.entries[i].days.filter(x => x !== day) : [...draft.entries[i].days, day].sort() })
|
||||
|
||||
return (
|
||||
<div className="grid gap-5 xl:grid-cols-[14rem_1fr]" data-testid="signage-schedules">
|
||||
<nav className="grid gap-2 content-start">
|
||||
<ul className="grid gap-1.5">
|
||||
{list.map(s => (
|
||||
<li key={s.id}>
|
||||
<button type="button" onClick={() => { if (!dirty || window.confirm(t('signage.discard'))) load(s.id) }} aria-current={s.id === current ? 'true' : undefined}
|
||||
data-testid="signage-schedule-item" data-name={s.name}
|
||||
className={`w-full text-left px-3 py-2 rounded-control border transition-colors duration-fast grid
|
||||
${s.id === current ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface hover:bg-surface-2 text-ink'}`}>
|
||||
<span className="text-label font-medium truncate">{s.name}</span>
|
||||
<span className="text-caption text-ink-3 truncate">{s.playing_now ? t('signage.schedules.nowPlaying', { name: s.playing_now.name }) : t('signage.schedules.nowNothing')}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Button variant="secondary" icon={<Plus size={16} />} disabled={!playlists.length || busy} data-testid="signage-new-schedule"
|
||||
onClick={() => act(() => api.createSchedule({ name: t('signage.schedules.newName'), fallback_playlist_id: playlists[0]?.id ?? null, entries: [] }), t('signage.schedules.created'))}>
|
||||
{t('signage.schedules.new')}</Button>
|
||||
{!playlists.length && <p className="text-caption text-ink-3">{t('signage.schedules.needPlaylist')}</p>}
|
||||
</nav>
|
||||
|
||||
{!draft ? <EmptyState title={t('signage.schedules.none')} description={t('signage.schedules.noneHint')} /> : (
|
||||
<div className="grid gap-4 content-start" data-testid="signage-schedule-editor" data-id={current}>
|
||||
<div className="flex flex-wrap items-end gap-2">
|
||||
<Field label={t('signage.playlistName')} className="flex-1 min-w-[12rem]">
|
||||
<Input value={draft.name} maxLength={80} onChange={e => setDraft(d => ({ ...d, name: e.target.value }))} data-testid="signage-schedule-name" />
|
||||
</Field>
|
||||
<IconButton variant="ghost" label={t('fees.delete')} onClick={() => setConfirm(true)} data-testid="signage-schedule-delete"><Trash2 size={16} /></IconButton>
|
||||
</div>
|
||||
<p className="text-caption text-ink-3">{t('signage.schedules.how')}</p>
|
||||
<ol className="grid gap-3" data-testid="signage-schedule-entries">
|
||||
{draft.entries.map((e, i) => (
|
||||
<li key={i} className="rounded-card border border-line bg-surface p-3 grid gap-3" data-testid="signage-schedule-entry">
|
||||
<div className="flex flex-wrap items-end gap-2">
|
||||
<Field label={t('signage.schedules.plays')} className="flex-1 min-w-[10rem]">
|
||||
<Select value={String(e.playlist_id)} onChange={ev => setEntry(i, { playlist_id: Number(ev.target.value) })} options={plOptions} data-testid="signage-entry-playlist" />
|
||||
</Field>
|
||||
<Field label={t('signage.schedules.priority')} hint={t('signage.schedules.priorityHint')}>
|
||||
<Input inputMode="numeric" className="w-24" value={String(e.priority || 0)}
|
||||
onChange={ev => setEntry(i, { priority: Math.min(100, Number(ev.target.value.replace(/\D/g, '')) || 0) })} data-testid="signage-entry-priority" />
|
||||
</Field>
|
||||
<IconButton variant="ghost" label={t('fees.delete')} onClick={() => setDraft(d => ({ ...d, entries: d.entries.filter((_, j) => j !== i) }))}><Trash2 size={16} /></IconButton>
|
||||
</div>
|
||||
<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={e.days.includes(d)} onClick={() => toggleDay(i, d)} data-testid={`signage-entry-day-${d}`}
|
||||
className={`px-2.5 py-1 rounded-control border text-label transition-colors duration-fast
|
||||
${e.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 lg:grid-cols-4">
|
||||
<Field label={t('signage.timeFrom')}><Input type="time" value={e.time_from || ''} onChange={ev => setEntry(i, { time_from: ev.target.value || null })} data-testid="signage-entry-from" /></Field>
|
||||
<Field label={t('signage.timeTo')}><Input type="time" value={e.time_to || ''} onChange={ev => setEntry(i, { time_to: ev.target.value || null })} data-testid="signage-entry-to" /></Field>
|
||||
<Field label={t('signage.dateFrom')}><Input type="date" value={e.date_from || ''} onChange={ev => setEntry(i, { date_from: ev.target.value || null })} /></Field>
|
||||
<Field label={t('signage.dateTo')}><Input type="date" value={e.date_to || ''} onChange={ev => setEntry(i, { date_to: ev.target.value || null })} /></Field>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
<Button variant="secondary" icon={<Plus size={16} />} onClick={() => setDraft(d => ({ ...d, entries: [...d.entries, emptyEntry(playlists[0]?.id)] }))}
|
||||
disabled={!playlists.length || draft.entries.length >= 100} data-testid="signage-add-entry">{t('signage.schedules.addLine')}</Button>
|
||||
<Field label={t('signage.schedules.otherwise')} hint={t('signage.schedules.otherwiseHint')}>
|
||||
<Select value={draft.fallback_playlist_id == null ? '' : String(draft.fallback_playlist_id)} data-testid="signage-schedule-fallback"
|
||||
onChange={e => setDraft(d => ({ ...d, fallback_playlist_id: e.target.value ? Number(e.target.value) : null }))}
|
||||
options={[{ value: '', label: t('signage.screens.nothing') }, ...plOptions]} />
|
||||
</Field>
|
||||
{saved?.screens?.length > 0 && <p className="text-label text-ink-3">{t('signage.playingOn', { names: saved.screens.map(s => s.name).join(', ') })}</p>}
|
||||
<div className="flex gap-2 items-center">
|
||||
<Button loading={busy} disabled={!dirty || !draft.name.trim()} data-testid="signage-schedule-save"
|
||||
onClick={() => act(() => api.updateSchedule(current, { ...draft, name: draft.name.trim() }), t('settings.saved'))}>{t('fees.save')}</Button>
|
||||
{dirty && <span className="text-label text-ink-3">{t('display.looks.unsaved')}</span>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{confirm && saved && (
|
||||
<Dialog open size="sm" title={t('signage.schedules.deleteTitle', { name: saved.name })} onClose={() => setConfirm(false)}
|
||||
footer={<>
|
||||
<Button variant="secondary" onClick={() => setConfirm(false)}>{t('fees.cancel')}</Button>
|
||||
<Button variant="danger" loading={busy} onClick={() => act(() => api.deleteSchedule(current), t('signage.schedules.deleted'), undefined).then(() => setConfirm(false))}>{t('fees.delete')}</Button>
|
||||
</>}>
|
||||
<p className="text-body text-ink-2">{t('signage.schedules.deleteBody')}</p>
|
||||
</Dialog>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// Signage → Screens (plan step 5.6c): every paired signage TV with what it plays (a playlist, or a
|
||||
// schedule that wins over it), its shape and how its picture is turned; a warning when a playlist
|
||||
// was made for the other shape. New TVs are paired in Devices.
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { AlertTriangle, Monitor } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { EmptyState, Field, Select, Spinner } from '@xenia/ui'
|
||||
import * as api from './signageApi'
|
||||
|
||||
export default function ScreensTab() {
|
||||
const { t } = useTranslation('manager')
|
||||
const [screens, setScreens] = useState(null)
|
||||
const [playlists, setPlaylists] = useState([])
|
||||
const [schedules, setSchedules] = useState([])
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const [s, p, c] = await Promise.all([api.listScreens(), api.listPlaylists(), api.listSchedules()])
|
||||
setScreens(s); setPlaylists(p); setSchedules(c)
|
||||
} catch (err) { toast.error(errorMessage(err, t)) }
|
||||
}, [t])
|
||||
useEffect(() => { load() }, [load])
|
||||
const save = async (id, body) => {
|
||||
try { const s = await api.updateScreen(id, body); setScreens(list => list.map(x => (x.id === id ? s : x))); toast.success(t('settings.saved')) }
|
||||
catch (err) { toast.error(errorMessage(err, t)) }
|
||||
}
|
||||
if (!screens) return <div className="flex justify-center p-6"><Spinner /></div>
|
||||
if (!screens.length) {
|
||||
return <EmptyState title={t('signage.screens.none')} description={t('signage.screens.noneHint')}
|
||||
action={<Link to="/devices?pair=signage" className="text-accent-ink font-medium">{t('signage.screens.pair')}</Link>} />
|
||||
}
|
||||
return (
|
||||
<ul className="grid gap-3" data-testid="signage-screens">
|
||||
{screens.map(s => (
|
||||
<li key={s.id} className="rounded-card border border-line bg-surface p-4 grid gap-3" data-testid="signage-screen" data-id={s.id} data-name={s.name}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Monitor size={18} className="text-ink-2" aria-hidden="true" />
|
||||
<span className="text-body font-semibold text-ink flex-1">{s.name}</span>
|
||||
{s.orientation_mismatch && (
|
||||
<span className="text-caption text-warning-ink flex items-center gap-1" data-testid="signage-screen-mismatch">
|
||||
<AlertTriangle size={14} aria-hidden="true" />{t('signage.screens.mismatch')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<Field label={t('signage.screens.playlist')}>
|
||||
<Select value={s.playlist_id == null ? '' : String(s.playlist_id)} data-testid="signage-screen-playlist"
|
||||
onChange={e => save(s.id, { playlist_id: e.target.value ? Number(e.target.value) : null })}
|
||||
options={[{ value: '', label: t('signage.screens.nothing') }, ...playlists.map(p => ({ value: String(p.id), label: p.name }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.screens.schedule')} hint={t('signage.screens.scheduleHint')}>
|
||||
<Select value={s.schedule_id == null ? '' : String(s.schedule_id)} data-testid="signage-screen-schedule"
|
||||
onChange={e => save(s.id, { schedule_id: e.target.value ? Number(e.target.value) : null })}
|
||||
options={[{ value: '', label: t('signage.screens.noSchedule') }, ...schedules.map(c => ({ value: String(c.id), label: c.name }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.orientation')}>
|
||||
<Select value={s.orientation} onChange={e => save(s.id, { orientation: e.target.value })} data-testid="signage-screen-orientation"
|
||||
options={['landscape', 'portrait'].map(o => ({ value: o, label: t(`signage.orientations.${o}`) }))} />
|
||||
</Field>
|
||||
<Field label={t('signage.screens.rotation')} hint={t('signage.screens.rotationHint')}>
|
||||
<Select value={String(s.rotation)} onChange={e => save(s.id, { rotation: Number(e.target.value) })} data-testid="signage-screen-rotation"
|
||||
options={[0, 90, 180, 270].map(r => ({ value: String(r), label: t(`signage.screens.rotations.${r}`) }))} />
|
||||
</Field>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// 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).
|
||||
// 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 town: one tab each.
|
||||
// Backend: /api/signage (routers/signage.py).
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
@@ -10,12 +10,18 @@ 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'
|
||||
import SchedulesTab from './SchedulesTab'
|
||||
import ScreensTab from './ScreensTab'
|
||||
import SignageSettingsTab from './SignageSettingsTab'
|
||||
|
||||
const TABS = ['playlists', 'screens', 'schedules', 'settings']
|
||||
|
||||
export default function SignagePage() {
|
||||
const { t } = useTranslation('manager')
|
||||
const [list, setList] = useState(null)
|
||||
const [current, setCurrent] = useState(null)
|
||||
const [creating, setCreating] = useState(false)
|
||||
const [tab, setTab] = useState('playlists')
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try { const l = await api.listPlaylists(); setList(l); return l } catch (err) { toast.error(errorMessage(err, t)); return null }
|
||||
@@ -28,7 +34,19 @@ export default function SignagePage() {
|
||||
<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="flex flex-wrap gap-1 border-b border-line" role="tablist" aria-label={t('signage.pageTitle')}>
|
||||
{TABS.map(k => (
|
||||
<button key={k} type="button" role="tab" aria-selected={tab === k} onClick={() => setTab(k)} data-testid={`signage-tab-${k}`}
|
||||
className={`px-3 py-2 -mb-px border-b-2 text-label font-medium transition-colors duration-fast
|
||||
${tab === k ? 'border-accent text-accent-ink' : 'border-transparent text-ink-2 hover:text-ink'}`}>
|
||||
{t(`signage.tabs.${k}`)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{tab === 'screens' && <ScreensTab />}
|
||||
{tab === 'schedules' && <SchedulesTab />}
|
||||
{tab === 'settings' && <SignageSettingsTab />}
|
||||
{tab !== 'playlists' ? null : !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>
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
// Signage → Message and weather (plan step 5.6c): the message of the day (one place for every
|
||||
// screen, at once) and the weather's town (picked from a search; the weather needs internet, and
|
||||
// without it the widget is simply hidden on the TVs).
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { CloudOff, RefreshCw, Search } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useLanguage, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Field, Input, Select, Spinner } from '@xenia/ui'
|
||||
import * as api from './signageApi'
|
||||
|
||||
export default function SignageSettingsTab() {
|
||||
const { t } = useTranslation('manager')
|
||||
const { formatDateTime } = useFormat()
|
||||
const { language: lang } = useLanguage()
|
||||
const [message, setMessage] = useState(null)
|
||||
const [savedMessage, setSavedMessage] = useState('')
|
||||
const [status, setStatus] = useState(null)
|
||||
const [q, setQ] = useState('')
|
||||
const [places, setPlaces] = useState(null)
|
||||
const [units, setUnits] = useState('celsius')
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const [m, w] = await Promise.all([api.getMessage(), api.weatherStatus()])
|
||||
setMessage(m.text || ''); setSavedMessage(m.text || ''); setStatus(w)
|
||||
if (w.place?.units) setUnits(w.place.units)
|
||||
} catch (err) { toast.error(errorMessage(err, t)) }
|
||||
}, [t])
|
||||
useEffect(() => { load() }, [load])
|
||||
const act = async (fn, done) => {
|
||||
setBusy(true)
|
||||
try { const r = await fn(); if (done) toast.success(done); return r } catch (err) { toast.error(errorMessage(err, t)); return null } finally { setBusy(false) }
|
||||
}
|
||||
if (message === null) return <div className="flex justify-center p-6"><Spinner /></div>
|
||||
const w = status?.weather
|
||||
|
||||
return (
|
||||
<div className="grid gap-5 max-w-3xl" data-testid="signage-settings">
|
||||
<section className="rounded-card border border-line bg-surface p-4 grid gap-3">
|
||||
<h2 className="text-body font-semibold text-ink">{t('signage.settings.message')}</h2>
|
||||
<p className="text-label text-ink-2">{t('signage.settings.messageHint')}</p>
|
||||
<div className="flex gap-2 items-start">
|
||||
<Input value={message} maxLength={200} onChange={e => setMessage(e.target.value)} className="flex-1" aria-label={t('signage.settings.message')} data-testid="signage-message" />
|
||||
<Button disabled={busy || message.trim() === savedMessage.trim()} data-testid="signage-message-save"
|
||||
onClick={() => act(() => api.putMessage(message.trim()), t('settings.saved')).then(r => { if (r) setSavedMessage(r.text || '') })}>{t('fees.save')}</Button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="rounded-card border border-line bg-surface p-4 grid gap-3" data-testid="signage-weather">
|
||||
<h2 className="text-body font-semibold text-ink">{t('signage.settings.weather')}</h2>
|
||||
<p className="text-label text-ink-2 flex items-start gap-1.5"><CloudOff size={16} className="shrink-0 mt-0.5" aria-hidden="true" />{t('signage.settings.weatherHint')}</p>
|
||||
{status?.place ? (
|
||||
<div className="grid gap-1 text-label" data-testid="signage-weather-place">
|
||||
<span className="text-ink"><strong>{status.place.name}</strong> · {t(`signage.settings.units.${status.place.units}`)}</span>
|
||||
{w ? <span className="text-ink-2" data-testid="signage-weather-now">{t('signage.settings.now', { temp: Math.round(w.temperature), unit: status.place.units === 'fahrenheit' ? '°F' : '°C', at: status.fetched_at ? formatDateTime(new Date(status.fetched_at * 1000)) : '' })}</span>
|
||||
: <span className="text-warning-ink" data-testid="signage-weather-none">{t(status.error ? 'signage.settings.noForecast' : 'signage.settings.waiting')}</span>}
|
||||
<div className="flex gap-2 pt-1">
|
||||
<Button size="sm" variant="secondary" icon={<RefreshCw size={14} />} disabled={busy} onClick={() => act(api.refreshWeather).then(r => r && setStatus(r))}>{t('signage.settings.refresh')}</Button>
|
||||
<Button size="sm" variant="ghost" disabled={busy} onClick={() => act(api.forgetWeatherPlace, t('settings.saved')).then(r => r && setStatus(r))}>{t('signage.settings.forget')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : <p className="text-label text-ink-3">{t('signage.settings.noPlace')}</p>}
|
||||
<div className="grid gap-2">
|
||||
<div className="flex gap-2 items-end flex-wrap">
|
||||
<Field label={t('signage.settings.town')} className="flex-1 min-w-[12rem]">
|
||||
<Input value={q} onChange={e => setQ(e.target.value)} placeholder={t('signage.settings.townPlaceholder')} data-testid="signage-weather-search" />
|
||||
</Field>
|
||||
<Field label={t('signage.settings.unitsLabel')}>
|
||||
<Select value={units} onChange={e => setUnits(e.target.value)} options={['celsius', 'fahrenheit'].map(u => ({ value: u, label: t(`signage.settings.units.${u}`) }))} />
|
||||
</Field>
|
||||
<Button variant="secondary" icon={<Search size={16} />} disabled={busy || q.trim().length < 2} data-testid="signage-weather-find"
|
||||
onClick={() => act(() => api.weatherPlaces(q.trim(), lang === 'el' ? 'el' : 'en')).then(r => r && setPlaces(r))}>{t('signage.settings.find')}</Button>
|
||||
</div>
|
||||
{places && (places.length === 0 ? <p className="text-label text-ink-3">{t('media.noMatch')}</p> : (
|
||||
<ul className="grid gap-1" data-testid="signage-weather-places">
|
||||
{places.map((p, i) => (
|
||||
<li key={i}>
|
||||
<button type="button" className="w-full text-left px-2 py-1.5 rounded-control hover:bg-surface-2 text-label text-ink" data-testid="signage-weather-place-pick"
|
||||
onClick={() => act(() => api.setWeatherPlace({ name: p.name, latitude: p.latitude, longitude: p.longitude, units }), t('settings.saved'))
|
||||
.then(r => { if (r) { setStatus(r); setPlaces(null); setQ('') } })}>
|
||||
<strong>{p.name}</strong> <span className="text-ink-3">{[p.region, p.country].filter(Boolean).join(', ')}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -18,3 +18,19 @@ export const duplicateSlide = id => client.post(`/api/signage/slides/${id}/dupli
|
||||
|
||||
export const previewVenue = () => client.get('/api/signage/venue').then(data)
|
||||
export const previewMenu = content => client.post('/api/signage/preview/menu', { content }).then(data)
|
||||
|
||||
export const listScreens = () => client.get('/api/signage/screens').then(data)
|
||||
export const updateScreen = (id, body) => client.put(`/api/signage/screens/${id}`, body).then(data)
|
||||
|
||||
export const listSchedules = () => client.get('/api/signage/schedules').then(data)
|
||||
export const createSchedule = body => client.post('/api/signage/schedules', body).then(data)
|
||||
export const updateSchedule = (id, body) => client.put(`/api/signage/schedules/${id}`, body).then(data)
|
||||
export const deleteSchedule = id => client.delete(`/api/signage/schedules/${id}`)
|
||||
|
||||
export const getMessage = () => client.get('/api/signage/message').then(data)
|
||||
export const putMessage = text => client.put('/api/signage/message', { text }).then(data)
|
||||
export const weatherStatus = () => client.get('/api/signage/weather').then(data)
|
||||
export const weatherPlaces = (q, language) => client.get('/api/signage/weather/places', { params: { q, language } }).then(data)
|
||||
export const setWeatherPlace = body => client.put('/api/signage/weather/place', body).then(data)
|
||||
export const forgetWeatherPlace = () => client.delete('/api/signage/weather/place').then(data)
|
||||
export const refreshWeather = () => client.post('/api/signage/weather/refresh').then(data)
|
||||
|
||||
@@ -1044,6 +1044,71 @@
|
||||
"days_one": "Σήμερα",
|
||||
"days_other": "Σήμερα και {{count}} μέρες",
|
||||
"weatherNeedsInternet": "Ο καιρός χρειάζεται internet: χωρίς αυτό (ή χωρίς πόλη) το στοιχείο κρύβεται."
|
||||
},
|
||||
"tabs": {
|
||||
"playlists": "Λίστες",
|
||||
"screens": "Οθόνες",
|
||||
"schedules": "Προγράμματα",
|
||||
"settings": "Μήνυμα και καιρός"
|
||||
},
|
||||
"screens": {
|
||||
"none": "Δεν υπάρχουν οθόνες προβολής ακόμα.",
|
||||
"noneHint": "Ανοίξτε http://<διακομιστής>:8082 στην τηλεόραση (ή σε μικρό υπολογιστή / stick πάνω της) και συνδέστε τη ως οθόνη προβολής.",
|
||||
"pair": "Σύνδεση τηλεόρασης στις Συσκευές",
|
||||
"playlist": "Παίζει",
|
||||
"nothing": "Τίποτα (κενή οθόνη)",
|
||||
"schedule": "Πρόγραμμα",
|
||||
"scheduleHint": "Όταν οριστεί, αποφασίζει τι παίζει (αντί για τη λίστα).",
|
||||
"noSchedule": "Χωρίς πρόγραμμα",
|
||||
"rotation": "Περιστροφή εικόνας",
|
||||
"rotationHint": "Για τηλεόραση τοποθετημένη πλάγια που δεν γυρίζει μόνη της την εικόνα.",
|
||||
"rotations": {
|
||||
"0": "Όχι",
|
||||
"90": "90° δεξιά",
|
||||
"180": "Ανάποδα",
|
||||
"270": "90° αριστερά"
|
||||
},
|
||||
"mismatch": "Μια λίστα εδώ φτιάχτηκε για το άλλο σχήμα"
|
||||
},
|
||||
"schedules": {
|
||||
"new": "Νέο πρόγραμμα",
|
||||
"newName": "Νέο πρόγραμμα",
|
||||
"created": "Το πρόγραμμα δημιουργήθηκε.",
|
||||
"deleted": "Το πρόγραμμα διαγράφηκε.",
|
||||
"none": "Δεν υπάρχουν προγράμματα ακόμα.",
|
||||
"noneHint": "Ένα πρόγραμμα παίζει διαφορετικές λίστες σε διαφορετικές ώρες: μεσημέρι, βράδυ, Σαββατοκύριακα, γιορτές.",
|
||||
"needPlaylist": "Φτιάξτε πρώτα μια λίστα.",
|
||||
"nowPlaying": "τώρα: {{name}}",
|
||||
"nowNothing": "τώρα: τίποτα",
|
||||
"how": "Κάθε γραμμή παίζει τη λίστα της στις μέρες, στις ώρες (μπορεί να περνούν τα μεσάνυχτα) και στις ημερομηνίες της· κενό σημαίνει πάντα. Όταν ταιριάζουν δύο γραμμές, κερδίζει η μεγαλύτερη προτεραιότητα, μετά η πιο συγκεκριμένη (ημερομηνίες, μετά μέρες, μετά ώρες).",
|
||||
"plays": "Παίζει",
|
||||
"priority": "Προτεραιότητα",
|
||||
"priorityHint": "Η μεγαλύτερη κερδίζει",
|
||||
"addLine": "Προσθήκη γραμμής",
|
||||
"otherwise": "Τον υπόλοιπο χρόνο",
|
||||
"otherwiseHint": "Όταν δεν ταιριάζει καμία γραμμή.",
|
||||
"deleteTitle": "Διαγραφή «{{name}}»;",
|
||||
"deleteBody": "Οι οθόνες που το έχουν γυρίζουν στη λίστα τους. Οι λίστες μένουν."
|
||||
},
|
||||
"settings": {
|
||||
"message": "Μήνυμα ημέρας",
|
||||
"messageHint": "Το δείχνει κάθε στοιχείο μηνύματος σε κάθε οθόνη (εκτός αν έχει δικό του κείμενο). Η αλλαγή φαίνεται αμέσως.",
|
||||
"weather": "Καιρός",
|
||||
"weatherHint": "Ο καιρός χρειάζεται internet: ο διακομιστής τον φέρνει κάθε 30 λεπτά. Χωρίς internet (ή χωρίς πόλη) το στοιχείο καιρού απλώς κρύβεται στις τηλεοράσεις.",
|
||||
"noPlace": "Δεν έχει οριστεί πόλη.",
|
||||
"town": "Πόλη",
|
||||
"townPlaceholder": "π.χ. Καλάβρυτα",
|
||||
"find": "Αναζήτηση",
|
||||
"unitsLabel": "Θερμοκρασίες",
|
||||
"units": {
|
||||
"celsius": "°C",
|
||||
"fahrenheit": "°F"
|
||||
},
|
||||
"now": "Τώρα {{temp}}{{unit}} · ενημέρωση {{at}}",
|
||||
"noForecast": "Καμία πρόγνωση: ο διακομιστής δεν φτάνει την υπηρεσία καιρού (χωρίς internet;). Το στοιχείο κρύβεται στο μεταξύ.",
|
||||
"waiting": "Καμία πρόγνωση ακόμα.",
|
||||
"refresh": "Ενημέρωση τώρα",
|
||||
"forget": "Αφαίρεση πόλης"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1044,6 +1044,71 @@
|
||||
"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."
|
||||
},
|
||||
"tabs": {
|
||||
"playlists": "Playlists",
|
||||
"screens": "Screens",
|
||||
"schedules": "Schedules",
|
||||
"settings": "Message and weather"
|
||||
},
|
||||
"screens": {
|
||||
"none": "No signage screens yet.",
|
||||
"noneHint": "Open http://<server>:8082 on the TV (or a small PC or stick on it) and pair it as a signage screen.",
|
||||
"pair": "Pair a TV in Devices",
|
||||
"playlist": "Plays",
|
||||
"nothing": "Nothing (a blank screen)",
|
||||
"schedule": "Schedule",
|
||||
"scheduleHint": "When set, it decides what plays (instead of the playlist).",
|
||||
"noSchedule": "No schedule",
|
||||
"rotation": "Turn the picture",
|
||||
"rotationHint": "For a TV mounted sideways that can't turn the picture itself.",
|
||||
"rotations": {
|
||||
"0": "No",
|
||||
"90": "90° right",
|
||||
"180": "Upside down",
|
||||
"270": "90° left"
|
||||
},
|
||||
"mismatch": "A playlist here was made for the other shape"
|
||||
},
|
||||
"schedules": {
|
||||
"new": "New schedule",
|
||||
"newName": "New schedule",
|
||||
"created": "Schedule created.",
|
||||
"deleted": "Schedule deleted.",
|
||||
"none": "No schedules yet.",
|
||||
"noneHint": "A schedule plays different playlists at different times: lunch, evenings, weekends, holidays.",
|
||||
"needPlaylist": "Make a playlist first.",
|
||||
"nowPlaying": "now: {{name}}",
|
||||
"nowNothing": "now: nothing",
|
||||
"how": "Each line plays its playlist on its days, between its hours (they may pass midnight) and dates; empty means always. When two lines match, the higher priority wins, then the more specific one (dates, then days, then hours).",
|
||||
"plays": "Plays",
|
||||
"priority": "Priority",
|
||||
"priorityHint": "Higher wins",
|
||||
"addLine": "Add a line",
|
||||
"otherwise": "The rest of the time",
|
||||
"otherwiseHint": "When no line matches.",
|
||||
"deleteTitle": "Delete \"{{name}}\"?",
|
||||
"deleteBody": "The screens on it go back to their playlist. The playlists stay."
|
||||
},
|
||||
"settings": {
|
||||
"message": "Message of the day",
|
||||
"messageHint": "Shown by every message widget on every screen (unless the widget has its own text). A change shows at once.",
|
||||
"weather": "Weather",
|
||||
"weatherHint": "The weather needs internet: the server fetches it every 30 minutes. Without internet (or without a town) the weather widget is simply hidden on the TVs.",
|
||||
"noPlace": "No town set yet.",
|
||||
"town": "Town",
|
||||
"townPlaceholder": "e.g. Kalavryta",
|
||||
"find": "Find",
|
||||
"unitsLabel": "Temperatures",
|
||||
"units": {
|
||||
"celsius": "°C",
|
||||
"fahrenheit": "°F"
|
||||
},
|
||||
"now": "Now {{temp}}{{unit}} · fetched {{at}}",
|
||||
"noForecast": "No forecast: the server can't reach the weather service (no internet?). The widget is hidden meanwhile.",
|
||||
"waiting": "No forecast yet.",
|
||||
"refresh": "Fetch now",
|
||||
"forget": "Remove the town"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+49
-3
@@ -1,4 +1,4 @@
|
||||
// Signage suite (plan steps 5.5a, 5.5b, 5.6a, 5.6b): a TV paired as a signage screen plays its playlist (picture,
|
||||
// Signage suite (plan steps 5.5a, 5.5b, 5.6a-c): 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,
|
||||
// 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).
|
||||
@@ -22,7 +22,7 @@ const managerVite = spawn('npx', ['vite', '--port', String(MPORT), '--strictPort
|
||||
stdio: ['ignore', mlog, mlog], env: { ...process.env, XENIA_BACKEND: backend.url },
|
||||
})
|
||||
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, 5.6b)')
|
||||
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b), the editor (5.6a-c)')
|
||||
const errors = []
|
||||
let failures = 0
|
||||
|
||||
@@ -277,6 +277,51 @@ try {
|
||||
&& !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') })
|
||||
// ── 5.6c: screens, schedules, the message of the day ─────────────────────
|
||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
||||
await mgr.getByTestId('signage-tab-settings').click()
|
||||
await mgr.getByTestId('signage-weather').waitFor({ timeout: 10_000 }) // loaded: the message field holds the saved text
|
||||
await mgr.getByTestId('signage-message').fill('Kalimera from the manager')
|
||||
await mgr.getByTestId('signage-message-save').click()
|
||||
await sleep(700)
|
||||
r.check('5.6c: the message of the day is saved from the manager', (await api('GET', '/api/signage/message', { token: boss })).text === 'Kalimera from the manager')
|
||||
r.check('5.6c: the weather section says what it needs (no town yet)', await shown(mgr, 'signage-weather', 5000)
|
||||
&& (await mgr.getByTestId('signage-weather').textContent()).includes('internet'))
|
||||
await mgr.getByTestId('signage-tab-screens').click()
|
||||
const card = mgr.locator('[data-testid="signage-screen"][data-name="Window TV"]')
|
||||
await card.waitFor({ timeout: 10_000 })
|
||||
await card.getByTestId('signage-screen-playlist').selectOption({ label: 'Opening' })
|
||||
const opId = (await api('GET', '/api/signage/playlists', { token: boss })).find(x => x.name === 'Opening').id
|
||||
r.check('5.6c: Screens: choosing the playlist switches the TV', !!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(opId), 15_000, 300)))
|
||||
await card.getByTestId('signage-screen-rotation').selectOption('180')
|
||||
r.check('5.6c: …and turning its picture', !!(await waitFor(async () => (await tv.getByTestId('signage-frame').getAttribute('data-rotation')) === '180', 15_000, 300)))
|
||||
await card.getByTestId('signage-screen-rotation').selectOption('0')
|
||||
// a schedule: "Opening" around now, "Window" the rest of the time
|
||||
const nowAthens = new Intl.DateTimeFormat('en-GB', { timeZone: 'Europe/Athens', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(new Date())
|
||||
const [hh] = nowAthens.split(':').map(Number)
|
||||
const from = `${String(Math.max(0, hh - 1)).padStart(2, '0')}:00`
|
||||
const to = `${String(Math.min(23, hh + 1)).padStart(2, '0')}:59`
|
||||
await mgr.getByTestId('signage-tab-schedules').click()
|
||||
await mgr.getByTestId('signage-new-schedule').click()
|
||||
await mgr.getByTestId('signage-schedule-editor').waitFor({ timeout: 10_000 })
|
||||
await mgr.getByTestId('signage-schedule-name').fill('Opening hours')
|
||||
await mgr.getByTestId('signage-add-entry').click()
|
||||
await mgr.getByTestId('signage-entry-playlist').selectOption({ label: 'Opening' })
|
||||
await mgr.getByTestId('signage-entry-from').fill(from)
|
||||
await mgr.getByTestId('signage-entry-to').fill(to)
|
||||
await mgr.getByTestId('signage-schedule-fallback').selectOption({ label: 'Window' })
|
||||
await mgr.getByTestId('signage-schedule-save').click()
|
||||
await sleep(900)
|
||||
const sch = (await api('GET', '/api/signage/schedules', { token: boss })).find(x => x.name === 'Opening hours')
|
||||
r.check('5.6c: a schedule built in the manager: "Opening" now, "Window" the rest of the time',
|
||||
sch?.entries?.[0]?.time_from === from && sch.playing_now?.name === 'Opening' && sch.fallback_playlist_id === pl.id, JSON.stringify(sch))
|
||||
await mgr.getByTestId('signage-tab-screens').click()
|
||||
await card.getByTestId('signage-screen-playlist').selectOption({ label: 'Window' })
|
||||
await sleep(500)
|
||||
await card.getByTestId('signage-screen-schedule').selectOption({ label: 'Opening hours' })
|
||||
r.check('5.6c: the TV on the schedule plays what it picks now', !!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(opId), 15_000, 300)))
|
||||
await mgr.screenshot({ path: path.join(OUT, 'signage-screens.png'), fullPage: true })
|
||||
await card.getByTestId('signage-screen-schedule').selectOption('')
|
||||
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)
|
||||
@@ -304,7 +349,8 @@ try {
|
||||
failures += r.done()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
failures += 1 + r.done()
|
||||
r.check('the suite ran to the end', false, String(e.message).split(/\r?\n/)[0]) // never "all passed" after a crash
|
||||
failures += r.done()
|
||||
} finally {
|
||||
await browser.close()
|
||||
term.stop()
|
||||
|
||||
Reference in New Issue
Block a user