feat(backend): signage schedules: which playlist plays when, switching by itself (platform-v2 step 5.4d)

- signage_schedules (Alembic 0030): entries {playlist, days, hours (may pass
  midnight), dates, priority} and a fallback playlist. A screen's `schedule`
  (ref) wins over its single playlist.
- services/signage_schedule.pick (pure): highest priority, then the most
  specific (dates > days > hours), then the later entry; no match → fallback.
- GET /api/signage/screen with a schedule: the schedule (with the venue's time
  zone) and every playlist in it, `playlist` = the one playing now, so the
  player can switch while the server is down.
- schedule_worker (signage module, 30 s) tells a screen when its pick changes.
- /api/signage/schedules CRUD (playing now, the screens on it); deleting a
  playlist takes it out of schedules; changes reach screens through schedules.
- Devices page: a signage screen's Schedule.
- tests: test_signage_schedule.py (6); 526 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 18:47:33 +02:00
co-authored by Claude Opus 5.5
parent b5951ba373
commit 0d766d3c86
15 changed files with 493 additions and 30 deletions
@@ -10,7 +10,7 @@ import client from '../../api/client'
import { configGroups, configValue, refOptions } from './devicesLogic'
// Where a `ref` field's choices come from (the device list is passed in)
const REF_URLS = { prep_zones: '/api/prep-zones', categories: '/api/products/categories', printers: '/api/system/printers', display_looks: '/api/display/looks', signage_playlists: '/api/signage/playlists' }
const REF_URLS = { prep_zones: '/api/prep-zones', categories: '/api/products/categories', printers: '/api/system/printers', display_looks: '/api/display/looks', signage_playlists: '/api/signage/playlists', signage_schedules: '/api/signage/schedules' }
export default function DeviceConfigFields({ appKey, fields = [], value, onChange, devices = [], selfId = null }) {
const { t } = useTranslation('manager')
@@ -30,6 +30,7 @@ export default function DeviceConfigFields({ appKey, fields = [], value, onChang
const printers = lists.printers ?? []
const looks = lists.display_looks ?? []
const playlists = lists.signage_playlists ?? []
const schedules = lists.signage_schedules ?? []
if (!fields.length) return null
const base = key => `modules:${appKey}.config.${key}`
@@ -55,7 +56,7 @@ export default function DeviceConfigFields({ appKey, fields = [], value, onChang
<Field key={f.key} label={label} hint={hint}>
<Select value={v == null ? '' : String(v)} onChange={e => set(f, e.target.value)} data-config={f.key}
options={[{ value: '', label: t(`${base(f.key)}.none`, { defaultValue: t('devices.form.none') }) },
...refOptions(f, { zones, categories, printers, looks, playlists, devices, selfId })]} />
...refOptions(f, { zones, categories, printers, looks, playlists, schedules, devices, selfId })]} />
</Field>
)
}
@@ -86,7 +86,8 @@ export function configGroups(fields = []) {
}
/** Options of a `ref` field: prep zones, categories, printers, customer display looks, or live devices of one app ("devices:<app>"). */
export function refOptions(field, { zones = [], categories = [], printers = [], looks = [], playlists = [], devices = [], selfId = null } = {}) {
export function refOptions(field, { zones = [], categories = [], printers = [], looks = [], playlists = [], schedules = [], devices = [], selfId = null } = {}) {
if (field.choices_from === 'signage_schedules') return schedules.map(s => ({ value: String(s.id), label: s.name }))
if (field.choices_from === 'signage_playlists') return playlists.map(p => ({ value: String(p.id), label: p.name }))
if (field.choices_from === 'display_looks') return looks.map(l => ({ value: String(l.id), label: l.name }))
if (field.choices_from === 'prep_zones') return zones.map(z => ({ value: String(z.id), label: z.name }))