feat(signage,scenes): schedule lines with screens and smart days, screens' defaults, horizontal timeline, scenes
- Scenes (Alembic 0043, models/scene.py, /api/scenes, core.scenes.manage): named modes on or off (optionally until a time); price rules / deals get the condition "a scene is on"; signage lines can play only during a scene; turning one on tells every screen and pushes the online menu. - Signage schedules are lines (signage_schedule_items): playlist, screens ([] = every screen), priority, days, smart days (1st / last day, first / last week, Greek public holidays or not: core/calendar_days.py, mirrored in @xenia/signage), hours, dates, scene. No line → the screen's default playlist. 0043 turns the old named schedules into lines for their screens. - Screens: default playlist, TV shape, turn; what plays now and why. - Manager: tabs Screens · Playlists · Schedules · Slides (placeholder) · Message and weather; schedule lines with playlist / screens / priority / delete on one line; the playlist editor's horizontal timeline of fixed cards, the slide's basics beside its preview (one height), then its content; Management → Scenes; the scene condition in pricing. - Tests: backend (lines, smart days, scenes, prices), player logic, e2e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,7 @@ import ApprovalsPage from './pages/staff/ApprovalsPage'
|
||||
import ManagementSchedulePage from './pages/schedule/SchedulePage'
|
||||
import PrepZonesConfigPage from './pages/printing/PrepZonesPage'
|
||||
import PricingPage from './pages/pricing/PricingPage'
|
||||
import ScenesPage from './pages/scenes/ScenesPage'
|
||||
|
||||
// Inventory
|
||||
import ThrowawaysPage from './pages/inventory/ThrowawaysPage'
|
||||
@@ -155,6 +156,7 @@ export default function App() {
|
||||
<Route path="management/schedule" element={<ManagementSchedulePage />} />
|
||||
<Route path="management/prep-zones" element={<PrepZonesConfigPage />} />
|
||||
<Route path="management/pricing" element={<PricingPage />} />
|
||||
<Route path="management/scenes" element={<ScenesPage />} />
|
||||
|
||||
{/* ── Inventory ── */}
|
||||
<Route path="inventory/throwaways" element={<ThrowawaysPage />} />
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from 'react'
|
||||
import { ArrowDown, ArrowUp, Check, Pencil, Plus, Power, Trash2, X } from 'lucide-react'
|
||||
import { SALES_POINTS, normalizeSalesPoints } from '@xenia/access'
|
||||
import { latin, useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, IconButton, Input, Select, cx } from '@xenia/ui'
|
||||
import { Button, Dropdown, IconButton, Input, Select, cx } from '@xenia/ui'
|
||||
import { COLOURS } from './useCatalog'
|
||||
import { OLD_PLACEHOLDERS, WEEKDAYS, blankCondition, conditionComplete, toggleIn } from './pricingLogic'
|
||||
|
||||
@@ -220,6 +220,12 @@ function ConditionFields({ cond, onChange, catalog }) {
|
||||
placeholder={catalog.groups.length ? t('pricing.choose') : t('pricing.condition.noGroups')}
|
||||
options={catalog.groups.map(g => ({ value: g.id, label: g.name }))} />
|
||||
)
|
||||
case 'scene_active': return (
|
||||
<Dropdown size="sm" value={p.scene_id ?? null} aria-label={t('pricing.condition.fields.scene_id')} data-testid="pricing-cond-scene"
|
||||
onChange={v => set('scene_id', v == null || v === '' ? null : Number(v))}
|
||||
placeholder={catalog.scenes.length ? t('pricing.choose') : t('pricing.condition.noScenes')}
|
||||
options={catalog.scenes.map(s => ({ value: s.id, label: s.name, dot: s.color || undefined }))} />
|
||||
)
|
||||
default: return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6] // Monday = 0, as the server counts
|
||||
|
||||
// conditions a rule can have; the deals take fewer
|
||||
export const MODIFIER_CONDITIONS = ['time_range', 'day_of_week', 'date_range', 'specific_date', 'price_group_active',
|
||||
export const MODIFIER_CONDITIONS = ['time_range', 'day_of_week', 'date_range', 'specific_date', 'price_group_active', 'scene_active',
|
||||
'order_channel', 'min_item_quantity', 'min_category_qty', 'min_order_value']
|
||||
export const DEAL_CONDITIONS = ['min_item_quantity', 'min_order_value', 'time_range', 'day_of_week', 'date_range',
|
||||
'order_channel', 'price_group_active']
|
||||
'order_channel', 'price_group_active', 'scene_active']
|
||||
export const OLD_PLACEHOLDERS = ['user_tier', 'low_stock'] // never did anything; shown, not offered
|
||||
|
||||
export const MODIFIER_TARGETS = ['all', 'item', 'category', 'prep_zone', 'tag']
|
||||
@@ -31,6 +31,7 @@ export function blankCondition(type) {
|
||||
case 'min_order_value': return { condition_type: type, params: { min: 20 } }
|
||||
case 'order_channel': return { condition_type: type, params: { channels: [] } }
|
||||
case 'price_group_active': return { condition_type: type, params: { price_group_id: null } }
|
||||
case 'scene_active': return { condition_type: type, params: { scene_id: null } } // a scene is on (2026-11-21)
|
||||
default: return { condition_type: type, params: {} }
|
||||
}
|
||||
}
|
||||
@@ -51,6 +52,7 @@ export function conditionComplete({ condition_type: type, params: p = {} }) {
|
||||
case 'min_order_value': return positive(p.min ?? 0, 0)
|
||||
case 'order_channel': return (p.channels ?? []).length > 0
|
||||
case 'price_group_active': return Number.isInteger(p.price_group_id)
|
||||
case 'scene_active': return Number.isInteger(p.scene_id)
|
||||
default: return OLD_PLACEHOLDERS.includes(type)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// What the pricing rules can point at (plan step 6.7), loaded once and kept current: products,
|
||||
// categories (as a tree), prep zones, tags and price groups; and the colours a rule can have.
|
||||
// categories (as a tree), prep zones, tags, price groups and scenes; and the colours a rule can have.
|
||||
import { useMemo } from 'react'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
import { CATEGORY_COLOURS } from '../products/categoryColours'
|
||||
import { categoryTree, treeLabel } from '../products/productsLogic'
|
||||
import * as api from './pricingApi'
|
||||
import { SCENE_EVENTS, listScenes } from '../scenes/scenesApi'
|
||||
|
||||
export const COLOURS = CATEGORY_COLOURS // the venue's colours (data, as the categories')
|
||||
|
||||
@@ -14,6 +15,7 @@ export function useCatalog() {
|
||||
const zones = useLiveQuery({ queryKey: ['prep-zones'], queryFn: api.listPrepZones, staleTime: 60_000 })
|
||||
const tags = useLiveQuery({ queryKey: ['product-tags'], queryFn: api.listTags, staleTime: 60_000 })
|
||||
const groups = useLiveQuery({ queryKey: ['pricing', 'groups'], queryFn: api.listGroups, events: api.PRICING_EVENTS })
|
||||
const scenes = useLiveQuery({ queryKey: ['scenes'], queryFn: listScenes, events: SCENE_EVENTS })
|
||||
return useMemo(() => ({
|
||||
products: (products.data ?? []).filter(p => p.lifecycle_status !== 'archived' && !p.is_service_item)
|
||||
.sort((a, b) => a.name.localeCompare(b.name)).map(p => ({ id: p.id, name: p.name, price: p.base_price })),
|
||||
@@ -21,6 +23,7 @@ export function useCatalog() {
|
||||
zones: (zones.data ?? []).map(z => ({ id: z.id, name: z.name })),
|
||||
tags: tags.data ?? [],
|
||||
groups: groups.data ?? [],
|
||||
}), [products.data, categories.data, zones.data, tags.data, groups.data])
|
||||
scenes: scenes.data ?? [],
|
||||
}), [products.data, categories.data, zones.data, tags.data, groups.data, scenes.data])
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
// Management → Scenes (owner 2026-11-21): the venue's modes ("Party mode", "Match night") that are
|
||||
// on or off. Turning one on changes, at once, everything that follows it: the signage schedule
|
||||
// lines that play only in it (Signage → Schedules) and the price rules or deals with the condition
|
||||
// "a scene is on" (Offers & pricing). Several can be on together; one can be on for a while only.
|
||||
// Backend: /api/scenes (routers/scenes.py, services/scenes.py).
|
||||
import { useState } from 'react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import toast from 'react-hot-toast'
|
||||
import { PartyPopper, Pencil, Plus, Trash2 } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Dropdown, EmptyState, Field, IconButton, Input, Page, PageHeader, Spinner, Switch, cx } from '@xenia/ui'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
import { CATEGORY_COLOURS } from '../products/categoryColours'
|
||||
import * as api from './scenesApi'
|
||||
import { FOR, untilOf } from './scenesApi'
|
||||
|
||||
|
||||
export default function ScenesPage() {
|
||||
const { t } = useTranslation('manager')
|
||||
const { formatDateTime } = useFormat()
|
||||
const qc = useQueryClient()
|
||||
const { data: scenes, isPending } = useLiveQuery({ queryKey: ['scenes'], queryFn: api.listScenes, events: api.SCENE_EVENTS })
|
||||
const [editing, setEditing] = useState(null)
|
||||
const [removing, setRemoving] = useState(null)
|
||||
const [forOf, setForOf] = useState({})
|
||||
const refresh = () => qc.invalidateQueries({ queryKey: ['scenes'] })
|
||||
const act = async (fn, done) => {
|
||||
try { await fn(); if (done) toast.success(done); refresh(); return true } catch (err) { toast.error(errorMessage(err, t)); return false }
|
||||
}
|
||||
|
||||
return (
|
||||
<Page testId="scenes-page">
|
||||
<PageHeader title={t('scenes.title')} subtitle={t('scenes.intro')}
|
||||
actions={<Button icon={<Plus size={16} />} onClick={() => setEditing({})} data-testid="scene-new">{t('scenes.new')}</Button>} />
|
||||
{isPending ? <div className="flex justify-center p-6"><Spinner /></div>
|
||||
: !scenes?.length ? <EmptyState icon={<PartyPopper size={28} />} title={t('scenes.none')} description={t('scenes.noneHint')} />
|
||||
: (
|
||||
<ul className="grid gap-3 md:grid-cols-2 xl:grid-cols-3" data-testid="scenes">
|
||||
{scenes.map(s => (
|
||||
<li key={s.id} data-testid="scene" data-name={s.name} data-active={s.active}
|
||||
className={cx('rounded-card border bg-surface shadow-raised p-card grid gap-3', s.active ? 'border-accent ring-2 ring-accent' : 'border-line')}>
|
||||
<div className="flex items-start gap-3">
|
||||
{/* a scene's colour is the venue's choice (data) */}
|
||||
<span className="mt-1 w-3 h-3 rounded-full shrink-0 bg-ink-3" style={s.color ? { background: s.color } : undefined} aria-hidden="true" />
|
||||
<span className="flex-1 min-w-0 grid gap-0.5">
|
||||
<span className="text-body-lg font-semibold text-ink truncate">{s.name}</span>
|
||||
{s.description && <span className="text-label text-ink-2">{s.description}</span>}
|
||||
</span>
|
||||
<Switch checked={s.active} aria-label={t('scenes.on')} data-testid="scene-switch"
|
||||
onChange={on => act(() => api.setSceneActive(s.id, on, on ? untilOf(forOf[s.id]) : null), t(on ? 'scenes.turnedOn' : 'scenes.turnedOff', { name: s.name }))} />
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{s.active
|
||||
? <span className="text-label text-success-ink font-medium flex-1">{s.until ? t('scenes.onUntil', { time: formatDateTime(s.until, 'datetimeShort') }) : t('scenes.onNow')}</span>
|
||||
: <Dropdown size="sm" className="flex-1 min-w-40" value={forOf[s.id] ?? ''} onChange={v => setForOf(f => ({ ...f, [s.id]: v }))} aria-label={t('scenes.for')}
|
||||
options={FOR.map(k => ({ value: k, label: t(`scenes.forOptions.${k || 'off'}`) }))} />}
|
||||
<IconButton size="sm" tone="accent" label={t('scenes.edit')} onClick={() => setEditing(s)}><Pencil size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="danger" label={t('scenes.delete')} onClick={() => setRemoving(s)}><Trash2 size={16} /></IconButton>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{editing && <SceneDialog scene={editing} onClose={() => setEditing(null)}
|
||||
onSave={body => act(() => (editing.id ? api.updateScene(editing.id, body) : api.createScene(body)), t('scenes.saved')).then(ok => ok && setEditing(null))} />}
|
||||
{removing && (
|
||||
<Dialog open size="sm" title={t('scenes.deleteTitle', { name: removing.name })} onClose={() => setRemoving(null)}
|
||||
footer={<>
|
||||
<Button variant="secondary" onClick={() => setRemoving(null)}>{t('fees.cancel')}</Button>
|
||||
<Button variant="danger" data-testid="scene-delete-confirm"
|
||||
onClick={() => act(() => api.deleteScene(removing.id), t('scenes.deleted')).then(() => setRemoving(null))}>{t('scenes.delete')}</Button>
|
||||
</>}>
|
||||
<p className="text-body text-ink-2">{t('scenes.deleteBody')}</p>
|
||||
</Dialog>
|
||||
)}
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
function SceneDialog({ scene, onClose, onSave }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [name, setName] = useState(scene.name ?? '')
|
||||
const [description, setDescription] = useState(scene.description ?? '')
|
||||
const [color, setColor] = useState(scene.color ?? CATEGORY_COLOURS[0])
|
||||
const [busy, setBusy] = useState(false)
|
||||
return (
|
||||
<Dialog open size="sm" title={scene.id ? t('scenes.edit') : t('scenes.new')} onClose={onClose}
|
||||
footer={<>
|
||||
<Button variant="secondary" onClick={onClose}>{t('fees.cancel')}</Button>
|
||||
<Button disabled={!name.trim()} loading={busy} data-testid="scene-save"
|
||||
onClick={async () => { setBusy(true); await onSave({ name: name.trim(), description: description.trim() || null, color }); setBusy(false) }}>{t('fees.save')}</Button>
|
||||
</>}>
|
||||
<div className="grid gap-3">
|
||||
<Field label={t('scenes.name')}><Input value={name} maxLength={60} autoFocus onChange={e => setName(e.target.value)} placeholder={t('scenes.namePh')} data-testid="scene-name" /></Field>
|
||||
<Field label={t('scenes.description')}><Input value={description} maxLength={200} onChange={e => setDescription(e.target.value)} placeholder={t('scenes.descriptionPh')} /></Field>
|
||||
<div className="grid gap-2">
|
||||
<span className="text-label font-medium text-ink-2">{t('scenes.colour')}</span>
|
||||
<div className="flex flex-wrap gap-2" role="radiogroup" aria-label={t('scenes.colour')}>
|
||||
{CATEGORY_COLOURS.map(c => (
|
||||
<button key={c} type="button" role="radio" aria-checked={color === c} aria-label={c} onClick={() => setColor(c)}
|
||||
className={cx('w-8 h-8 rounded-full ring-offset-2 ring-offset-[var(--x-surface)]', color === c && 'ring-2 ring-[var(--x-ink)]')} style={{ background: c }} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Scenes (owner 2026-11-21): backend local_backend/routers/scenes.py.
|
||||
import client from '../../api/client'
|
||||
|
||||
const data = r => r.data
|
||||
|
||||
export const SCENE_EVENTS = ['scenes.changed']
|
||||
export const listScenes = () => client.get('/api/scenes').then(data)
|
||||
export const createScene = body => client.post('/api/scenes', body).then(data)
|
||||
export const updateScene = (id, body) => client.put(`/api/scenes/${id}`, body).then(data)
|
||||
export const deleteScene = id => client.delete(`/api/scenes/${id}`)
|
||||
export const setSceneActive = (id, active, until = null) => client.put(`/api/scenes/${id}/active`, { active, until }).then(data)
|
||||
|
||||
// how long a scene stays on when turned on: until turned off, or for a while
|
||||
export const FOR = ['', '1', '2', '3', '4', '6', 'day']
|
||||
|
||||
/** The moment a scene turned on now goes off ("day": the end of today on this device's clock). */
|
||||
export function untilOf(choice, now = new Date()) {
|
||||
if (!choice) return null
|
||||
if (choice === 'day') { const d = new Date(now); d.setHours(23, 59, 0, 0); return d.toISOString() }
|
||||
return new Date(now.getTime() + Number(choice) * 3600_000).toISOString()
|
||||
}
|
||||
@@ -1,20 +1,43 @@
|
||||
// One playlist (plan step 5.6a): its name, orientation and default transition; the timeline of
|
||||
// slides (drag or arrows to reorder, duplicate, remove, on / off); a slide's settings with a live
|
||||
// preview at the playlist's shape; new slides blank or from a template; a warning on slides whose
|
||||
// picture or video doesn't fit the orientation.
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
// One playlist (plan step 5.6a; reworked 2026-11-21): its name, orientation and default transition
|
||||
// (the toolbar); a horizontal timeline of slides, like a video editor's (cards of one size that
|
||||
// scroll sideways: drag or ← → to reorder, duplicate, remove); under it the picked slide's basics
|
||||
// (name, seconds, on / off, transition, when it shows) beside its live preview, the same height;
|
||||
// then what the slide shows. New slides blank or from a template; a warning on slides whose
|
||||
// picture or video doesn't fit the orientation. A slide's "when it shows" narrows its playlist's
|
||||
// schedule: outside both, it doesn't play.
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { AlertTriangle, ArrowDown, ArrowUp, Copy, Film, GripVertical, ImageIcon, LayoutList, Plus, Trash2, Type } from 'lucide-react'
|
||||
import { AlertTriangle, ArrowLeft, ArrowRight, Copy, Film, ImageIcon, LayoutList, Plus, Trash2, Type } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Field, IconButton, Input, Select, Spinner } from '@xenia/ui'
|
||||
import * as api from './signageApi'
|
||||
import { mediaEntry, mediaLookup, misfits, moved, slideBody, slideFromTemplate, TEMPLATES, totalSeconds, TRANSITIONS, windowParts } from './signageLogic'
|
||||
import SlideEditor from './SlideEditor'
|
||||
import SlideEditor, { SlideBasics } from './SlideEditor'
|
||||
import SlidePreview from './SlidePreview'
|
||||
|
||||
const KIND_ICON = { image: ImageIcon, video: Film, text: Type, menu: LayoutList }
|
||||
|
||||
/** The preview as big as its box allows (the box is as tall as the basics beside it). */
|
||||
function FitPreview({ orientation, children }) {
|
||||
const box = useRef(null)
|
||||
const [size, setSize] = useState({ w: 0, h: 0 })
|
||||
useLayoutEffect(() => {
|
||||
const el = box.current
|
||||
if (!el) return undefined
|
||||
const ro = new ResizeObserver(([e]) => setSize({ w: e.contentRect.width, h: e.contentRect.height }))
|
||||
ro.observe(el)
|
||||
return () => ro.disconnect()
|
||||
}, [])
|
||||
const ratio = orientation === 'portrait' ? 9 / 16 : 16 / 9
|
||||
const width = Math.max(0, Math.min(size.w, size.h * ratio))
|
||||
return (
|
||||
<div ref={box} className="h-full min-h-[16rem] grid place-items-center" data-testid="signage-preview-box">
|
||||
{width > 0 && <div style={{ width }}>{children}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [pl, setPl] = useState(null)
|
||||
@@ -109,71 +132,76 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) {
|
||||
{pl.screens.length > 0 && <> · {t('signage.playingOn', { names: pl.screens.map(s => s.name).join(', ') })}</>}
|
||||
</p>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-[minmax(16rem,22rem)_1fr]">
|
||||
{/* the timeline */}
|
||||
<section className="grid gap-2 content-start" aria-label={t('signage.timeline')}>
|
||||
<ol className="grid gap-2" data-testid="signage-timeline">
|
||||
{pl.slides.map((s, i) => {
|
||||
const Icon = KIND_ICON[s.kind] || ImageIcon
|
||||
const parts = windowParts(s)
|
||||
return (
|
||||
<li key={s.id} draggable onDragStart={() => setDragFrom(i)} onDragOver={e => e.preventDefault()}
|
||||
onDrop={() => { if (dragFrom != null) reorder(dragFrom, i); setDragFrom(null) }}
|
||||
data-testid="signage-slide-card" data-id={s.id} data-kind={s.kind}
|
||||
className={`rounded-card border bg-surface flex gap-2 p-2 items-center cursor-pointer transition-colors duration-fast
|
||||
${s.id === selected ? 'border-accent ring-2 ring-accent' : 'border-line hover:border-line-strong'} ${s.enabled ? '' : 'opacity-60'}`}
|
||||
onClick={() => pick(s)}>
|
||||
<GripVertical size={16} className="text-ink-3 shrink-0 cursor-grab" aria-hidden="true" />
|
||||
<div className="w-24 shrink-0 pointer-events-none">
|
||||
{/* the timeline: cards of one size, scrolling sideways (2026-11-21) */}
|
||||
<section className="rounded-card border border-line bg-surface-2 p-3" aria-label={t('signage.timeline')}>
|
||||
<ol className="flex gap-3 overflow-x-auto pb-2 snap-x" data-testid="signage-timeline">
|
||||
{pl.slides.map((s, i) => {
|
||||
const Icon = KIND_ICON[s.kind] || ImageIcon
|
||||
const parts = windowParts(s)
|
||||
return (
|
||||
<li key={s.id} draggable onDragStart={() => setDragFrom(i)} onDragOver={e => e.preventDefault()}
|
||||
onDrop={() => { if (dragFrom != null) reorder(dragFrom, i); setDragFrom(null) }}
|
||||
data-testid="signage-slide-card" data-id={s.id} data-kind={s.kind}
|
||||
className={`w-52 shrink-0 snap-start rounded-card border bg-surface grid gap-2 p-2 cursor-pointer transition-colors duration-fast
|
||||
${s.id === selected ? 'border-accent ring-2 ring-accent' : 'border-line hover:border-line-strong'} ${s.enabled ? '' : 'opacity-60'}`}
|
||||
onClick={() => pick(s)}>
|
||||
<div className="pointer-events-none h-28 grid place-items-center rounded-control bg-surface-2">
|
||||
<div style={{ width: pl.orientation === 'portrait' ? 63 : '100%' }}>
|
||||
<SlidePreview slide={s} media={mediaLookup(media)} venue={venue} orientation={pl.orientation} testid="signage-card-preview" />
|
||||
</div>
|
||||
<div className="grid gap-0.5 min-w-0 flex-1">
|
||||
<span className="text-label font-medium text-ink truncate flex items-center gap-1.5">
|
||||
<Icon size={14} className="text-ink-2 shrink-0" aria-hidden="true" />{s.name || t(`signage.kinds.${s.kind}`)}
|
||||
{bad[s.id] && <AlertTriangle size={14} className="text-warning-ink" aria-label={t('signage.misfit')} data-testid="signage-card-misfit" />}
|
||||
</span>
|
||||
<span className="text-caption text-ink-3">
|
||||
{s.kind === 'video' && s.video_to_end ? t('signage.toTheEnd') : t('signage.seconds', { count: s.duration_s })}
|
||||
{!s.enabled && <> · {t('signage.off')}</>}
|
||||
{parts.map(p => <span key={p.key}> · {p.key === 'days' ? p.params.days.map(d => t(`signage.weekdays.${d}`)).join(' ') : t(`signage.window.${p.key}`, p.params)}</span>)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-col" onClick={e => e.stopPropagation()}>
|
||||
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={i === 0 || busy} onClick={() => reorder(i, i - 1)} data-testid="signage-up"><ArrowUp size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={i === pl.slides.length - 1 || busy} onClick={() => reorder(i, i + 1)} data-testid="signage-down"><ArrowDown size={14} /></IconButton>
|
||||
</div>
|
||||
<div className="flex flex-col" onClick={e => e.stopPropagation()}>
|
||||
<IconButton size="sm" variant="ghost" label={t('signage.duplicateSlide')} disabled={busy}
|
||||
onClick={() => run(() => api.duplicateSlide(s.id), t('signage.duplicated'))}><Copy size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('fees.delete')} disabled={busy} data-testid="signage-slide-delete"
|
||||
onClick={() => window.confirm(t('signage.deleteSlide')) && run(() => api.deleteSlide(s.id), t('signage.removed'), s.id === selected ? null : selected)}><Trash2 size={14} /></IconButton>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ol>
|
||||
<Button variant="secondary" icon={<Plus size={16} />} onClick={() => setAdding(true)} data-testid="signage-add-slide">{t('signage.addSlide')}</Button>
|
||||
</section>
|
||||
</div>
|
||||
<div className="grid gap-0.5 min-w-0">
|
||||
<span className="text-label font-medium text-ink truncate flex items-center gap-1.5">
|
||||
<span className="text-caption text-ink-3 tabular-nums">{i + 1}</span>
|
||||
<Icon size={14} className="text-ink-2 shrink-0" aria-hidden="true" />
|
||||
<span className="truncate">{s.name || t(`signage.kinds.${s.kind}`)}</span>
|
||||
{bad[s.id] && <AlertTriangle size={14} className="text-warning-ink shrink-0" aria-label={t('signage.misfit')} data-testid="signage-card-misfit" />}
|
||||
</span>
|
||||
<span className="text-caption text-ink-3 truncate">
|
||||
{s.kind === 'video' && s.video_to_end ? t('signage.toTheEnd') : t('signage.seconds', { count: s.duration_s })}
|
||||
{!s.enabled && <> · {t('signage.off')}</>}
|
||||
{parts.map(p => <span key={p.key}> · {p.key === 'days' ? p.params.days.map(d => t(`signage.weekdays.${d}`)).join(' ') : t(`signage.window.${p.key}`, p.params)}</span>)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-4 gap-1" onClick={e => e.stopPropagation()}>
|
||||
<IconButton size="sm" tone="accent" className="!w-full" label={t('display.earlier')} disabled={i === 0 || busy} onClick={() => reorder(i, i - 1)} data-testid="signage-up"><ArrowLeft size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="accent" className="!w-full" label={t('display.later')} disabled={i === pl.slides.length - 1 || busy} onClick={() => reorder(i, i + 1)} data-testid="signage-down"><ArrowRight size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="info" className="!w-full" label={t('signage.duplicateSlide')} disabled={busy}
|
||||
onClick={() => run(() => api.duplicateSlide(s.id), t('signage.duplicated'))}><Copy size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="danger" className="!w-full" label={t('fees.delete')} disabled={busy} data-testid="signage-slide-delete"
|
||||
onClick={() => window.confirm(t('signage.deleteSlide')) && run(() => api.deleteSlide(s.id), t('signage.removed'), s.id === selected ? null : selected)}><Trash2 size={16} /></IconButton>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
<li className="w-52 shrink-0 snap-start">
|
||||
<button type="button" onClick={() => setAdding(true)} data-testid="signage-add-slide"
|
||||
className="w-full h-full min-h-[12rem] rounded-card border-2 border-dashed border-line-strong text-ink-2 hover:text-accent-ink hover:border-accent grid place-items-center gap-1 text-label font-medium transition-colors duration-fast">
|
||||
<span className="grid justify-items-center gap-1"><Plus size={20} aria-hidden="true" />{t('signage.addSlide')}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
{/* the slide being edited */}
|
||||
<section className="grid gap-4 content-start">
|
||||
{draft ? <>
|
||||
{/* the preview stays in view while the settings below scroll */}
|
||||
<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) }))}
|
||||
misfit={draftBad} />
|
||||
<div className="flex gap-2 items-center sticky bottom-0 bg-canvas py-2">
|
||||
<Button loading={busy} disabled={!dirty} onClick={() => run(() => api.updateSlide(draft.id, slideBody(draft)), t('settings.saved'))}
|
||||
data-testid="signage-slide-save">{t('fees.save')}</Button>
|
||||
<Button variant="secondary" disabled={!dirty || busy} onClick={() => setDraft(structuredClone(saved))}>{t('signage.undo')}</Button>
|
||||
{dirty && <span className="text-label text-ink-3">{t('display.looks.unsaved')}</span>}
|
||||
</div>
|
||||
</> : <p className="text-body text-ink-3 p-6 text-center">{t(pl.slides.length ? 'signage.pickSlide' : 'signage.noSlides')}</p>}
|
||||
{/* the picked slide: its basics beside its preview (one height), then what it shows */}
|
||||
{draft ? <>
|
||||
<section className="grid gap-4 lg:grid-cols-2 items-stretch rounded-card border border-line bg-surface shadow-raised p-card" data-testid="signage-slide-top">
|
||||
<SlideBasics slide={draft} onChange={setDraft} />
|
||||
<FitPreview orientation={pl.orientation}>
|
||||
<SlidePreview slide={draft} media={mediaLookup(media)} venue={venue} orientation={pl.orientation} playing />
|
||||
</FitPreview>
|
||||
</section>
|
||||
</div>
|
||||
<section className="rounded-card border border-line bg-surface shadow-raised p-card">
|
||||
<SlideEditor slide={draft} onChange={setDraft} media={media} onMedia={item => setMedia(m => ({ ...m, [String(item.id)]: mediaEntry(item) }))}
|
||||
misfit={draftBad} />
|
||||
</section>
|
||||
<div className="flex gap-2 items-center sticky bottom-0 bg-canvas py-2 z-10">
|
||||
<Button loading={busy} disabled={!dirty} onClick={() => run(() => api.updateSlide(draft.id, slideBody(draft)), t('settings.saved'))}
|
||||
data-testid="signage-slide-save">{t('fees.save')}</Button>
|
||||
<Button variant="secondary" disabled={!dirty || busy} onClick={() => setDraft(structuredClone(saved))}>{t('signage.undo')}</Button>
|
||||
{dirty && <span className="text-label text-ink-3">{t('display.looks.unsaved')}</span>}
|
||||
</div>
|
||||
</> : <p className="text-body text-ink-3 p-6 text-center">{t(pl.slides.length ? 'signage.pickSlide' : 'signage.noSlides')}</p>}
|
||||
|
||||
{adding && (
|
||||
<Dialog open size="lg" title={t('signage.addSlide')} onClose={() => setAdding(false)}
|
||||
|
||||
@@ -1,136 +1,137 @@
|
||||
// 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.
|
||||
// Signage → Schedules (plan step 5.6c; lines with their screens, owner 2026-11-21): which playlist
|
||||
// plays when, on which screens. Each line: a playlist, its screens (none picked = every screen), a
|
||||
// priority; its days (with shortcuts), smart days (1st / last of the month, first / last week,
|
||||
// public holidays or not), hours that may pass midnight, dates, and optionally a scene it plays in
|
||||
// (party mode). When two lines match on a screen, the higher priority wins, then the more specific
|
||||
// one; no line → the screen's default playlist (Screens). Saved together; the TVs switch by
|
||||
// themselves, 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 { MONTH_DAYS } from '@xenia/signage'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, IconButton, Input, Select, Spinner } from '@xenia/ui'
|
||||
import { Button, Dropdown, EmptyState, Field, FilterChip, IconButton, InfoTip, Input, Spinner, Switch } from '@xenia/ui'
|
||||
import * as api from './signageApi'
|
||||
import { listScenes } from '../scenes/scenesApi'
|
||||
|
||||
const emptyEntry = playlistId => ({ playlist_id: playlistId, days: [], time_from: null, time_to: null, date_from: null, date_to: null, priority: 0 })
|
||||
const DAYS = [0, 1, 2, 3, 4, 5, 6]
|
||||
const SHORTCUTS = { everyday: [], weekdays: [0, 1, 2, 3, 4], weekend: [5, 6] }
|
||||
const KEYS = ['id', 'name', 'playlist_id', 'screen_ids', 'priority', 'enabled', 'days', 'month_days', 'time_from', 'time_to', 'date_from', 'date_to', 'scene_id']
|
||||
const bodyOf = lines => lines.map(l => Object.fromEntries(KEYS.map(k => [k, l[k] ?? (k === 'screen_ids' || k === 'days' || k === 'month_days' ? [] : null)])))
|
||||
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
||||
|
||||
export default function SchedulesTab() {
|
||||
const { t } = useTranslation('manager')
|
||||
const [list, setList] = useState(null)
|
||||
const [saved, setSaved] = useState(null)
|
||||
const [lines, setLines] = useState(null)
|
||||
const [playlists, setPlaylists] = useState([])
|
||||
const [current, setCurrent] = useState(null)
|
||||
const [draft, setDraft] = useState(null)
|
||||
const [screens, setScreens] = useState([])
|
||||
const [scenes, setScenes] = useState([])
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [confirm, setConfirm] = useState(false)
|
||||
|
||||
const load = useCallback(async (pick) => {
|
||||
const load = useCallback(async () => {
|
||||
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)
|
||||
const [l, p, s, sc] = await Promise.all([api.listSchedules(), api.listPlaylists(), api.listScreens(), listScenes().catch(() => [])])
|
||||
setSaved(l); setLines(l); setPlaylists(p); setScreens(s); setScenes(sc)
|
||||
} 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 dirty = useMemo(() => !!(saved && lines && !same(bodyOf(saved), bodyOf(lines))), [saved, lines])
|
||||
if (!lines) return <div className="flex justify-center p-6"><Spinner /></div>
|
||||
|
||||
const act = async (fn, done, pick = current) => {
|
||||
const set = (i, patch) => setLines(ls => ls.map((l, j) => (j === i ? { ...l, ...patch } : l)))
|
||||
const add = () => setLines(ls => [...ls, { playlist_id: playlists[0]?.id, screen_ids: [], priority: 0, enabled: true, days: [], month_days: [], scene_id: null }])
|
||||
const save = async () => {
|
||||
setBusy(true)
|
||||
try { const r = await fn(); toast.success(done); await load(r?.id ?? pick) } catch (err) { toast.error(errorMessage(err, t)) }
|
||||
try { const l = await api.saveSchedules(bodyOf(lines)); setSaved(l); setLines(l); toast.success(t('settings.saved')) }
|
||||
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 className="grid gap-4" data-testid="signage-schedules">
|
||||
<p className="text-label text-ink-2 max-w-4xl">{t('signage.schedules.how')}</p>
|
||||
{!playlists.length && <p className="text-label text-warning-ink">{t('signage.schedules.needPlaylist')}</p>}
|
||||
{lines.length === 0 && <EmptyState title={t('signage.schedules.none')} description={t('signage.schedules.noneHint')} />}
|
||||
<ol className="grid gap-3" data-testid="signage-schedule-entries">
|
||||
{lines.map((l, i) => (
|
||||
<Line key={l.id ?? `new-${i}`} line={l} set={patch => set(i, patch)} playlists={playlists} screens={screens} scenes={scenes}
|
||||
onRemove={() => setLines(ls => ls.filter((_, j) => j !== i))} />
|
||||
))}
|
||||
</ol>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Button variant="secondary" icon={<Plus size={16} />} onClick={add} disabled={!playlists.length || lines.length >= 200} data-testid="signage-add-entry">{t('signage.schedules.addLine')}</Button>
|
||||
<span className="flex-1" />
|
||||
{dirty && <span className="text-label text-ink-3">{t('display.looks.unsaved')}</span>}
|
||||
<Button variant="secondary" disabled={!dirty || busy} onClick={() => setLines(saved)}>{t('signage.undo')}</Button>
|
||||
<Button loading={busy} disabled={!dirty} onClick={save} data-testid="signage-schedule-save">{t('fees.save')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Line({ line: l, set, playlists, screens, scenes, onRemove }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const days = l.days || []
|
||||
const md = l.month_days || []
|
||||
const shortcut = Object.entries(SHORTCUTS).find(([, v]) => same(v, days))?.[0]
|
||||
return (
|
||||
<li className={`rounded-card border border-line bg-surface shadow-raised p-card grid gap-4 ${l.enabled ? '' : 'opacity-70'}`} data-testid="signage-schedule-entry">
|
||||
{/* playlist · screens · priority · delete: one height, one line (2026-11-21) */}
|
||||
<div className="grid gap-3 items-end sm:grid-cols-[1fr_1fr_1fr_auto]">
|
||||
<Field label={t('signage.schedules.plays')}>
|
||||
<Dropdown value={l.playlist_id} onChange={v => set({ playlist_id: Number(v) })} data-testid="signage-entry-playlist"
|
||||
options={playlists.map(p => ({ value: p.id, label: p.name, hint: t(`signage.orientations.${p.orientation}`) }))} />
|
||||
</Field>
|
||||
<Field label={t('signage.schedules.onScreens')}>
|
||||
<Dropdown multiple value={l.screen_ids || []} onChange={v => set({ screen_ids: v.map(Number) })} allLabel={t('signage.schedules.allScreens')}
|
||||
data-testid="signage-entry-screens" options={screens.map(s => ({ value: s.id, label: s.name }))} />
|
||||
</Field>
|
||||
<Field label={<span className="inline-flex items-center gap-1">{t('signage.schedules.priority')}<InfoTip>{t('signage.schedules.priorityHint')}</InfoTip></span>}>
|
||||
<Input inputMode="numeric" value={String(l.priority || 0)} data-testid="signage-entry-priority"
|
||||
onChange={ev => set({ priority: Math.min(100, Number(ev.target.value.replace(/\D/g, '')) || 0) })} />
|
||||
</Field>
|
||||
<IconButton tone="danger" label={t('fees.delete')} onClick={onRemove} data-testid="signage-entry-delete"><Trash2 size={16} /></IconButton>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-2">
|
||||
<span className="text-label font-medium text-ink-2">{t('signage.days')}</span>
|
||||
<div className="flex flex-wrap items-center gap-1.5" role="group" aria-label={t('signage.days')}>
|
||||
{DAYS.map(d => (
|
||||
<FilterChip key={d} size="sm" tone="accent" pressed={days.includes(d)} data-testid={`signage-entry-day-${d}`}
|
||||
onClick={() => set({ days: days.includes(d) ? days.filter(x => x !== d) : [...days, d].sort() })}>{t(`signage.weekdays.${d}`)}</FilterChip>
|
||||
))}
|
||||
<span className="w-px h-6 bg-line mx-1" aria-hidden="true" />
|
||||
{Object.entries(SHORTCUTS).map(([k, v]) => (
|
||||
<FilterChip key={k} size="sm" tone="info" pressed={shortcut === k} onClick={() => set({ days: v })} data-testid={`signage-entry-${k}`}>{t(`signage.schedules.shortcuts.${k}`)}</FilterChip>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-1.5" role="group" aria-label={t('signage.schedules.smartDays')}>
|
||||
<span className="text-caption text-ink-3 mr-1">{t('signage.schedules.smartDays')}</span>
|
||||
{MONTH_DAYS.map(k => (
|
||||
<FilterChip key={k} size="sm" tone={k === 'not_holiday' ? 'warning' : 'success'} pressed={md.includes(k)} data-testid={`signage-entry-md-${k}`}
|
||||
onClick={() => set({ month_days: md.includes(k) ? md.filter(x => x !== k) : [...md, k] })}>{t(`signage.schedules.monthDays.${k}`)}</FilterChip>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3 grid-cols-2 lg:grid-cols-5 items-end">
|
||||
<Field label={t('signage.timeFrom')}><Input type="time" value={l.time_from || ''} onChange={ev => set({ time_from: ev.target.value || null })} data-testid="signage-entry-from" /></Field>
|
||||
<Field label={t('signage.timeTo')}><Input type="time" value={l.time_to || ''} onChange={ev => set({ time_to: ev.target.value || null })} data-testid="signage-entry-to" /></Field>
|
||||
<Field label={t('signage.dateFrom')}><Input type="date" value={l.date_from || ''} onChange={ev => set({ date_from: ev.target.value || null })} /></Field>
|
||||
<Field label={t('signage.dateTo')}><Input type="date" value={l.date_to || ''} onChange={ev => set({ date_to: ev.target.value || null })} /></Field>
|
||||
<Field label={t('signage.schedules.scene')}>
|
||||
<Dropdown value={l.scene_id ?? ''} onChange={v => set({ scene_id: v === '' ? null : Number(v) })} data-testid="signage-entry-scene"
|
||||
options={[{ value: '', label: t('signage.schedules.anyScene') }, ...scenes.map(s => ({ value: s.id, label: s.name, dot: s.color || undefined }))]} />
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Switch checked={l.enabled !== false} onChange={v => set({ enabled: v })} label={t('signage.schedules.enabled')} />
|
||||
<span className="flex-1" />
|
||||
{l.playing_on?.length > 0 && <span className="text-label text-success-ink" data-testid="signage-entry-playing">{t('signage.schedules.playingNow', { names: l.playing_on.map(s => s.name).join(', ') })}</span>}
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
// 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.
|
||||
// Signage → Screens (plan step 5.6c; 2026-11-21): every paired signage TV with its default playlist,
|
||||
// its shape and how its picture is turned, and what plays on it now. A schedule line for a screen
|
||||
// (Schedules) wins over its default while it matches. A warning when a playlist it may play 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 { AlertTriangle, CalendarClock, Monitor, Smartphone } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { EmptyState, Field, Select, Spinner } from '@xenia/ui'
|
||||
import { Dropdown, EmptyState, Field, 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)
|
||||
const [s, p] = await Promise.all([api.listScreens(), api.listPlaylists()])
|
||||
setScreens(s); setPlaylists(p)
|
||||
} catch (err) { toast.error(errorMessage(err, t)) }
|
||||
}, [t])
|
||||
useEffect(() => { load() }, [load])
|
||||
@@ -32,40 +32,44 @@ export default function ScreensTab() {
|
||||
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>
|
||||
<div className="grid gap-3">
|
||||
<p className="text-label text-ink-2 max-w-3xl">{t('signage.screens.intro')}</p>
|
||||
<ul className="grid gap-3 xl:grid-cols-2" data-testid="signage-screens">
|
||||
{screens.map(s => {
|
||||
const Icon = s.orientation === 'portrait' ? Smartphone : Monitor
|
||||
return (
|
||||
<li key={s.id} className="rounded-card border border-line bg-surface shadow-raised p-card grid gap-4" data-testid="signage-screen" data-id={s.id} data-name={s.name}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Icon size={18} className="text-ink-2" aria-hidden="true" />
|
||||
<span className="text-body-lg 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>
|
||||
<p className="text-label text-ink-2 flex items-center gap-1.5" data-testid="signage-screen-now">
|
||||
{s.now?.scheduled && <CalendarClock size={14} className="text-accent-ink" aria-hidden="true" />}
|
||||
{s.now ? t(s.now.scheduled ? 'signage.screens.nowScheduled' : 'signage.screens.nowDefault', { name: s.now.name }) : t('signage.screens.nowNothing')}
|
||||
</p>
|
||||
<div className="grid gap-3 sm:grid-cols-3">
|
||||
<Field label={t('signage.screens.defaultPlaylist')}>
|
||||
<Dropdown value={s.playlist_id ?? ''} data-testid="signage-screen-playlist" onChange={v => save(s.id, { playlist_id: v === '' ? null : Number(v) })}
|
||||
options={[{ value: '', label: t('signage.screens.nothing') }, ...playlists.map(p => ({ value: p.id, label: p.name }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.screens.shape')}>
|
||||
<Dropdown value={s.orientation} onChange={v => save(s.id, { orientation: v })} data-testid="signage-screen-orientation"
|
||||
options={['landscape', 'portrait'].map(o => ({ value: o, label: t(`signage.orientations.${o}`) }))} />
|
||||
</Field>
|
||||
<Field label={t('signage.screens.rotation')}>
|
||||
<Dropdown value={s.rotation} onChange={v => save(s.id, { rotation: Number(v) })} data-testid="signage-screen-rotation"
|
||||
options={[0, 90, 180, 270].map(r => ({ value: r, label: t(`signage.screens.rotations.${r}`) }))} />
|
||||
</Field>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,27 +1,32 @@
|
||||
// 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.
|
||||
// Signage (plan steps 5.6a-c; 2026-11-21): the screens (each one's default playlist, shape and
|
||||
// turn), the playlists (pick one to edit its timeline and slides; make a new one for a landscape or
|
||||
// a portrait screen), the schedules (which playlist plays when on which screens, scenes), the
|
||||
// slides library (single slides to reuse, coming next), the message of the day and the weather's
|
||||
// town: one tab each, in that order; the tab is in the address (?tab=).
|
||||
// Backend: /api/signage (routers/signage.py).
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import toast from 'react-hot-toast'
|
||||
import { Monitor, Plus, Smartphone } from 'lucide-react'
|
||||
import { Layers, Monitor, Plus, Smartphone } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, Input, Page, Select, Spinner } from '@xenia/ui'
|
||||
import { Button, Dialog, EmptyState, Field, Input, Page, PageHeader, Select, Spinner, Tabs } 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']
|
||||
const TABS = ['screens', 'playlists', 'schedules', 'slides', '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 [params, setParams] = useSearchParams()
|
||||
const tab = TABS.includes(params.get('tab')) ? params.get('tab') : 'screens'
|
||||
const setTab = v => setParams(p => { const n = new URLSearchParams(p); n.set('tab', v); return n }, { replace: true })
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try { const l = await api.listPlaylists(); setList(l); return l } catch (err) { toast.error(errorMessage(err, t)); return null }
|
||||
@@ -29,21 +34,11 @@ export default function SignagePage() {
|
||||
useEffect(() => { load().then(l => { if (l?.length) setCurrent(c => c ?? l[0].id) }) }, [load])
|
||||
|
||||
return (
|
||||
<Page testId="signage-page">
|
||||
<header className="grid gap-1">
|
||||
<h1 className="text-heading font-semibold text-ink">{t('signage.pageTitle')}</h1>
|
||||
<p className="text-body text-ink-2 max-w-3xl">{t('signage.intro')}</p>
|
||||
</header>
|
||||
<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>
|
||||
<Page testId="signage-page" header={<PageHeader title={t('signage.pageTitle')} subtitle={t('signage.intro')} />}
|
||||
top={<Tabs size="lg" value={tab} onChange={setTab} aria-label={t('signage.pageTitle')}
|
||||
tabs={TABS.map(k => ({ id: k, label: t(`signage.tabs.${k}`), testId: `signage-tab-${k}` }))} />}>
|
||||
{tab === 'screens' && <ScreensTab />}
|
||||
{tab === 'slides' && <EmptyState icon={<Layers size={28} />} title={t('signage.slidesTab.title')} description={t('signage.slidesTab.body')} />}
|
||||
{tab === 'schedules' && <SchedulesTab />}
|
||||
{tab === 'settings' && <SignageSettingsTab />}
|
||||
{tab !== 'playlists' ? null : !list ? <div className="flex justify-center p-6"><Spinner /></div> : (
|
||||
|
||||
@@ -1,29 +1,37 @@
|
||||
// One slide's settings (plan step 5.6a): its name, time on screen, transition, on / off, when it
|
||||
// may show (days, hours, dates), and what it shows (picture, video, text, menu board's look).
|
||||
// The parent keeps the draft and saves it; the preview follows every change.
|
||||
// 2026-11-21: in two parts: SlideBasics (beside the preview) and SlideEditor (what it shows, below).
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Field, Input, Select, Switch, Textarea } from '@xenia/ui'
|
||||
import { Dropdown, Field, FilterChip, Input, Select, Switch, Textarea } from '@xenia/ui'
|
||||
import { FONT_KEYS, TRANSITIONS } from './signageLogic'
|
||||
import { BackgroundField, ColourField, MediaPick } from './SignageFields'
|
||||
import MenuEditor from './MenuEditor'
|
||||
import WidgetsEditor from './WidgetsEditor'
|
||||
|
||||
export default function SlideEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
||||
/** The slide's basics, beside its preview: name, seconds on screen, on / off, transition, when it shows. */
|
||||
export function SlideBasics({ slide, onChange }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const set = patch => onChange({ ...slide, ...patch })
|
||||
const c = slide.content || {}
|
||||
const setC = patch => set({ content: { ...c, ...patch } })
|
||||
const days = slide.days || []
|
||||
const toggleDay = d => set({ days: days.includes(d) ? days.filter(x => x !== d) : [...days, d].sort() })
|
||||
const bad = id => misfit.includes(id)
|
||||
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="signage-slide-editor" data-kind={slide.kind}>
|
||||
<div className="grid gap-4 content-start" data-testid="signage-slide-basics">
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<Field label={t('signage.slideName')} hint={t('signage.slideNameHint')}>
|
||||
<Field label={t('signage.slideName')}>
|
||||
<Input value={slide.name || ''} maxLength={80} onChange={e => set({ name: e.target.value })} data-testid="signage-slide-name" />
|
||||
</Field>
|
||||
<div className="flex items-end pb-1">
|
||||
{!(slide.kind === 'video' && slide.video_to_end) ? (
|
||||
<Field label={t('signage.duration')}>
|
||||
<Input inputMode="numeric" value={String(slide.duration_s ?? 10)} data-testid="signage-duration"
|
||||
onChange={e => set({ duration_s: Math.min(3600, Number(e.target.value.replace(/\D/g, '')) || 0) })} />
|
||||
</Field>
|
||||
) : <span />}
|
||||
<Field label={t('signage.transition')}>
|
||||
<Dropdown value={slide.transition || ''} onChange={v => set({ transition: v || null })} data-testid="signage-transition"
|
||||
options={[{ value: '', label: t('signage.transitionDefault') }, ...TRANSITIONS.map(x => ({ value: x, label: t(`signage.transitions.${x}`) }))]} />
|
||||
</Field>
|
||||
<div className="flex items-end pb-2.5">
|
||||
<Switch checked={!!slide.enabled} onChange={on => set({ enabled: on })} label={t('signage.enabled')} data-testid="signage-slide-enabled" />
|
||||
</div>
|
||||
{slide.kind === 'video' && (
|
||||
@@ -32,16 +40,6 @@ export default function SlideEditor({ slide, onChange, media, onMedia, misfit =
|
||||
description={t('signage.videoToEndHint')} data-testid="signage-video-to-end" />
|
||||
</div>
|
||||
)}
|
||||
{!(slide.kind === 'video' && slide.video_to_end) && (
|
||||
<Field label={t('signage.duration')} hint={slide.kind === 'menu' ? t('signage.durationMenuHint') : undefined}>
|
||||
<Input inputMode="numeric" value={String(slide.duration_s ?? 10)} data-testid="signage-duration"
|
||||
onChange={e => set({ duration_s: Math.min(3600, Number(e.target.value.replace(/\D/g, '')) || 0) })} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label={t('signage.transition')}>
|
||||
<Select value={slide.transition || ''} onChange={e => set({ transition: e.target.value || null })} data-testid="signage-transition"
|
||||
options={[{ value: '', label: t('signage.transitionDefault') }, ...TRANSITIONS.map(x => ({ value: x, label: t(`signage.transitions.${x}`) }))]} />
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<fieldset className="grid gap-3 rounded-control border border-line p-3">
|
||||
@@ -49,11 +47,9 @@ export default function SlideEditor({ slide, onChange, media, onMedia, misfit =
|
||||
<p className="text-caption text-ink-3">{t('signage.whenHint')}</p>
|
||||
<div className="flex flex-wrap gap-1.5" role="group" aria-label={t('signage.days')}>
|
||||
{[0, 1, 2, 3, 4, 5, 6].map(d => (
|
||||
<button key={d} type="button" aria-pressed={days.includes(d)} onClick={() => toggleDay(d)} data-testid={`signage-day-${d}`}
|
||||
className={`px-2.5 py-1 rounded-control border text-label transition-colors duration-fast
|
||||
${days.includes(d) ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface-2 text-ink hover:bg-surface-3'}`}>
|
||||
<FilterChip key={d} size="sm" tone="accent" pressed={days.includes(d)} onClick={() => toggleDay(d)} data-testid={`signage-day-${d}`}>
|
||||
{t(`signage.weekdays.${d}`)}
|
||||
</button>
|
||||
</FilterChip>
|
||||
))}
|
||||
</div>
|
||||
<div className="grid gap-3 grid-cols-2">
|
||||
@@ -63,7 +59,20 @@ export default function SlideEditor({ slide, onChange, media, onMedia, misfit =
|
||||
<Field label={t('signage.dateTo')}><Input type="date" value={slide.date_to || ''} onChange={e => set({ date_to: e.target.value || null })} data-testid="signage-date-to" /></Field>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** What the slide shows (below the basics and the preview): picture, video, text, menu board. */
|
||||
export default function SlideEditor({ slide, onChange, media, onMedia, misfit = [] }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const set = patch => onChange({ ...slide, ...patch })
|
||||
const c = slide.content || {}
|
||||
const setC = patch => set({ content: { ...c, ...patch } })
|
||||
const bad = id => misfit.includes(id)
|
||||
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="signage-slide-editor" data-kind={slide.kind}>
|
||||
{slide.kind === 'image' && (
|
||||
<div className="grid gap-3">
|
||||
<MediaPick kind="image" label={t('signage.picture')} value={c.media_id} entry={media[String(c.media_id)]} misfit={bad(c.media_id)}
|
||||
|
||||
@@ -22,10 +22,9 @@ export const previewMenu = content => client.post('/api/signage/preview/menu', {
|
||||
export const listScreens = () => client.get('/api/signage/screens').then(data)
|
||||
export const updateScreen = (id, body) => client.put(`/api/signage/screens/${id}`, body).then(data)
|
||||
|
||||
// the schedule lines (2026-11-21): all of them, saved together
|
||||
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 saveSchedules = lines => client.put('/api/signage/schedules', { lines }).then(data)
|
||||
|
||||
export const getMessage = () => client.get('/api/signage/message').then(data)
|
||||
export const putMessage = text => client.put('/api/signage/message', { text }).then(data)
|
||||
|
||||
@@ -12,13 +12,7 @@
|
||||
// converts those routers.
|
||||
// anyPerm instead of perm: any one of these keys is enough (the media library)
|
||||
// label a key in the i18n `manager` namespace
|
||||
import {
|
||||
LayoutDashboard, LayoutGrid, ShoppingBag,
|
||||
BookUser, Users, Receipt, CreditCard,
|
||||
Package, TableProperties, UserCog, CalendarDays, Trash2, Boxes,
|
||||
BarChart2, TrendingUp, Users2, ShoppingCart, Tag, Activity, Printer, ConciergeBell, FileText,
|
||||
AppWindow, Settings, CookingPot, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, Images, Tv,
|
||||
} from 'lucide-react'
|
||||
import { Activity, AppWindow, BadgeCheck, BarChart2, BookUser, Boxes, CalendarDays, ConciergeBell, CookingPot, CreditCard, FileText, Images, LayoutDashboard, LayoutGrid, LogIn, MonitorSmartphone, Package, PartyPopper, Percent, Plug, Printer, Receipt, Settings, ShieldCheck, ShoppingBag, ShoppingCart, StickyNote, TableProperties, Tag, Trash2, TrendingUp, Tv, UserCog, Users, Users2 } from 'lucide-react'
|
||||
|
||||
const DASH = 'core.dashboard.access'
|
||||
// The media library: whoever manages something that shows pictures (routers/media.py MANAGE)
|
||||
@@ -68,6 +62,7 @@ export const NAV = [
|
||||
{ to: '/management/schedule', icon: CalendarDays, label: 'nav.schedule', module: 'staff_planning', perm: 'core.staff.manage' },
|
||||
{ to: '/management/prep-zones', icon: CookingPot, label: 'nav.prepZones', module: 'catalog', perm: 'catalog.menu.manage' },
|
||||
{ to: '/management/pricing', icon: Percent, label: 'nav.pricing', module: 'pricing', perm: 'pricing.manage' },
|
||||
{ to: '/management/scenes', icon: PartyPopper, label: 'nav.scenes', module: 'core', perm: 'core.scenes.manage' },
|
||||
{ to: '/notes', icon: StickyNote, label: 'nav.notes', module: 'notes', perm: 'notes.use' },
|
||||
{ to: '/management/sessions', icon: LogIn, label: 'nav.sessions', module: 'core', perm: 'core.staff.manage' },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user