From aa8ba5d1d40e76a38cde3963a8bb148b3655c6f4 Mon Sep 17 00:00:00 2001 From: bonamin Date: Sat, 21 Nov 2026 15:11:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(signage):=20menus=20play=20whole=20rounds,?= =?UTF-8?q?=20seconds=20fields=20with=20=E2=88=92=20/=20+,=20widget=20limi?= =?UTF-8?q?t=20setting,=20widgets=20as=20big=20as=20their=20content=20(own?= =?UTF-8?q?er=20review=206)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - A menu board with pages plays whole rounds (menuMs rounds its seconds up); the editor says how long it really plays under "Seconds on screen", the card and the playlist total use it. - Seconds on screen / per page: shared NumberInput (− / +, may be emptied: an error under the field and Save blocked until filled; 1 s at least, server ge=1). - Performance (Signage -> Message & settings): widgets per slide (signage.max_widgets, 10 recommended, up to 50), checked by the server (signage.too_many_widgets) and the editor. - Text, clock, date, QR, weather, logo placed by hand: the box is exactly the content (its height x text size sets the size, the width follows; handles scale keeping the shape; text size grows the box); a slide's widget may run off the slide while 5 % stays on it. - Slider: the value as close to the slider as the frame's padding; floor and table-colour sliders use the shared Slider. Timeline cards' ring no longer clipped; larger playlist buttons. Co-Authored-By: Claude Opus 5.5 --- docs/DESIGN.md | 3 +- local_backend/core/errors.py | 1 + local_backend/routers/signage.py | 57 ++++++++++++++----- local_backend/tests/test_signage_library.py | 9 ++- local_backend/tests/test_signage_stacks.py | 16 ++++++ .../pages/Settings/sections/TableColours.jsx | 6 +- .../src/pages/floor/FloorEditor.jsx | 7 +-- .../src/pages/signage/MenuEditor.jsx | 7 ++- .../src/pages/signage/PerformanceSettings.jsx | 46 +++++++++++++++ .../src/pages/signage/PlaylistEditor.jsx | 14 +++-- .../src/pages/signage/SignagePage.jsx | 4 +- .../src/pages/signage/SignageSettingsTab.jsx | 2 + .../src/pages/signage/SlideEditor.jsx | 29 ++++++++-- .../src/pages/signage/SlidesTab.jsx | 8 +-- .../src/pages/signage/WidgetCanvas.jsx | 28 +++++++-- .../src/pages/signage/WidgetsEditor.jsx | 7 ++- .../src/pages/signage/signageApi.js | 4 ++ .../src/pages/signage/signageLogic.js | 38 ++++++++++++- manager_dashboard/src/pages/signage/timing.js | 16 ++++++ .../src/pages/signage/usePerformance.js | 23 ++++++++ manager_dashboard/tests/signage.test.mjs | 14 +++++ packages/i18n/locales/el/errors.json | 3 +- packages/i18n/locales/el/manager.json | 18 +++++- packages/i18n/locales/en/errors.json | 3 +- packages/i18n/locales/en/manager.json | 18 +++++- packages/signage/src/Slides.jsx | 30 ++++++++-- packages/signage/src/logic.js | 15 +++-- packages/signage/tests/logic.test.mjs | 5 ++ packages/ui/src/components.css | 24 +++++++- packages/ui/src/components/NumberInput.jsx | 46 +++++++++++++++ packages/ui/src/components/Slider.jsx | 3 +- packages/ui/src/index.js | 1 + tests/e2e/signage.mjs | 6 ++ 33 files changed, 436 insertions(+), 75 deletions(-) create mode 100644 manager_dashboard/src/pages/signage/PerformanceSettings.jsx create mode 100644 manager_dashboard/src/pages/signage/timing.js create mode 100644 manager_dashboard/src/pages/signage/usePerformance.js create mode 100644 packages/ui/src/components/NumberInput.jsx diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 226fa64..b94d763 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -51,7 +51,8 @@ Every page is on `` except Inventory → Stock (a placeholder). Two-column | A small panel under a button | `Popover` (`open`, `anchor` = the button's ref, `onClose`) | a colour picker, an "Add…" menu. Drawn over everything (portal), flips above, stays inside the window: **never an `absolute` panel inside a section** (it is clipped and makes the section scroll) | | A colour (a venue's: data) | `ColourField` (`auto`, `opacity`, `presets`) | a field with its swatch and code; its panel (over the page) has 12 ready colours, the picker, the opacity (`#rrggbbaa`) and the code. `auto` = a first choice that leaves it to something else ("As the slide"). **Never** a bare `` | | An icon from a set | `IconPicker` (`icons` = { key: component }) | a field showing the icon; a grid of the set over the page, "No icon" first | -| A slider with its value | `Slider` (`suffix`) | framed and as tall as the fields beside it | +| A whole number (seconds, counts) | `NumberInput` (`min`, `max`, `suffix`) | − / + on its sides, as tall as an input; it may be emptied while typing (`onChange(null)`): the form shows the error and blocks saving. **Never** clamp on every key (the user can't clear the field) | +| A slider with its value | `Slider` (`suffix`) | framed and as tall as the fields beside it; the value sits as close to it as the frame's padding. **Never** a bare `` | | Fields that should wrap | `FieldRow` (`min`, `shade` on every other row) | each field keeps its least width; a row that wraps is framed (and tinted with `shade`), a row on one line looks like any row | | Toggles that go together (bold / italic / underline) | `Segmented multiple` | value is an array | | A toggle filter (a state) | `FilterChip` (`tone`, `count`) | | diff --git a/local_backend/core/errors.py b/local_backend/core/errors.py index 7248bc9..f0701dd 100644 --- a/local_backend/core/errors.py +++ b/local_backend/core/errors.py @@ -110,6 +110,7 @@ CODES: dict[str, tuple[int, str]] = { "signage.not_a_screen": (404, "Device {device_id} isn't a signage screen."), "signage.schedule_unknown": (404, "Schedule {schedule_id} not found."), "signage.not_a_video": (422, "Pick a video for this slide."), + "signage.too_many_widgets": (422, "A slide holds at most {max} widgets (Signage → Message & settings → Performance)."), "signage.content_invalid": (422, "This slide's setting isn't valid ({field}: {reason})."), "signage.order_mismatch": (409, "The playlist changed in the meantime. Reload it and try again."), "signage.weather_offline": (503, "The weather service can't be reached: the venue's server needs internet for it."), diff --git a/local_backend/routers/signage.py b/local_backend/routers/signage.py index 4051732..f760f70 100644 --- a/local_backend/routers/signage.py +++ b/local_backend/routers/signage.py @@ -49,6 +49,8 @@ from services.ws_bus import broadcast_sync router = APIRouter() KEY = "signage.manage" MESSAGE = "signage.message" +MAX_WIDGETS = "signage.max_widgets" # widgets a slide may hold (owner review 6: Performance; 10 recommended) +MAX_WIDGETS_CAP = 50 # never more, whatever the setting HEX = r"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$" # #rrggbb, or #rrggbbaa (see-through, 2026-11-21) TIME = r"^([01]\d|2[0-3]):[0-5]\d$" DATE = r"^\d{4}-\d{2}-\d{2}$" @@ -130,7 +132,7 @@ class MenuList(_Strict): # pages (the player pages through what doesn't fit, 5.5b) columns: int = Field(default=2, ge=1, le=3) page_size: Optional[int] = Field(default=None, ge=3, le=60) # items per page; None = as many as fit - page_seconds: int = Field(default=10, ge=3, le=120) + page_seconds: int = Field(default=10, ge=1, le=120) font: Font = "sans" text_colour: str = Field(default="#ffffff", pattern=HEX) accent_colour: str = Field(default="#f59e0b", pattern=HEX) # page dots; headings and prices until their own @@ -183,19 +185,20 @@ class MenuList(_Strict): class Box(_Strict): - """Where a widget moved by hand sits (2026-11-21): % of the slide's width / height.""" - x: float = Field(ge=0, le=100) - y: float = Field(ge=0, le=100) - w: float = Field(ge=2, le=100) - h: float = Field(ge=2, le=100) + """Where a widget moved by hand sits (2026-11-21): % of the slide's (or its stack place's) width / + height. Owner review 6: it may run off the slide, as long as a strip of it (5 %) stays on it to + grab it back; a text, clock, QR… is as big as its content (its height sets the size).""" + x: float = Field(ge=-100, le=100) + y: float = Field(ge=-100, le=100) + w: float = Field(ge=1, le=100) + h: float = Field(ge=1, le=100) @model_validator(mode="after") def _inside(self): - # kept on the slide: a box never runs past its right or bottom edge self.w = round(min(self.w, 100), 2) self.h = round(min(self.h, 100), 2) - self.x = round(min(self.x, 100 - self.w), 2) - self.y = round(min(self.y, 100 - self.h), 2) + self.x = round(min(max(self.x, 5 - self.w), 95), 2) + self.y = round(min(max(self.y, 5 - self.h), 95), 2) return self @@ -324,13 +327,13 @@ class TextContent(_Strict): text_colour: str = Field(default="#ffffff", pattern=HEX) text_size: int = Field(default=100, ge=50, le=250) # % background: Background = Field(default_factory=Background) - widgets: List[Widget] = Field(default_factory=list, max_length=10) + widgets: List[Widget] = Field(default_factory=list, max_length=MAX_WIDGETS_CAP) # the venue's limit: _content class BlankContent(_Strict): """A blank slide (2026-11-21): only its background and its widgets.""" background: Background = Field(default_factory=Background) - widgets: List[Widget] = Field(default_factory=list, max_length=10) + widgets: List[Widget] = Field(default_factory=list, max_length=MAX_WIDGETS_CAP) # the venue's limit: _content class MenuContent(MenuList): @@ -341,7 +344,7 @@ class MenuContent(MenuList): board_align: Literal["left", "center", "right"] = "left" # where a narrower list sits, and its title board_valign: Literal["top", "middle", "bottom"] = "top" # where a shorter list sits (owner review 5) background: Background = Field(default_factory=Background) - widgets: List[Widget] = Field(default_factory=list, max_length=10) + widgets: List[Widget] = Field(default_factory=list, max_length=MAX_WIDGETS_CAP) # the venue's limit: _content CONTENT = {"image": ImageContent, "video": VideoContent, "text": TextContent, "menu": MenuContent, "blank": BlankContent} @@ -364,7 +367,7 @@ class PlaylistUpdate(BaseModel): class SlideFields(BaseModel): name: Optional[str] = Field(default=None, max_length=80) - duration_s: Optional[int] = Field(default=None, ge=2, le=3600) + duration_s: Optional[int] = Field(default=None, ge=1, le=3600) transition: Optional[Transition] = None # None: the playlist's video_to_end: Optional[bool] = None enabled: Optional[bool] = None @@ -566,6 +569,9 @@ def _content(db, kind: str, raw: dict | None) -> dict: first = e.errors()[0] raise XeniaError("signage.content_invalid", field=".".join(str(x) for x in first["loc"]), reason=first["msg"]) data = model.model_dump() + most = max_widgets(db) + if len(data.get("widgets") or []) > most: + raise XeniaError("signage.too_many_widgets", max=most) from models.media import Media for mid in media_ids(data): m = db.get(Media, mid) @@ -1240,6 +1246,31 @@ def put_message(body: MessageBody, db: Session = Depends(get_db), user=Depends(r return {"text": (body.text or "").strip() or None} +def max_widgets(db) -> int: + """How many widgets a slide may hold: the venue's setting (Performance), 10 until it changes it.""" + try: + return max(1, min(MAX_WIDGETS_CAP, int(_setting(db, MAX_WIDGETS, "10") or 10))) + except ValueError: + return 10 + + +class PerformanceBody(BaseModel): + max_widgets: int = Field(ge=1, le=MAX_WIDGETS_CAP) + + +@router.get("/performance") +def get_performance(db: Session = Depends(get_db), user=Depends(require(KEY))): + """Limits that keep the TVs smooth (owner review 6): widgets per slide (10 recommended).""" + return {"max_widgets": max_widgets(db), "recommended": 10, "cap": MAX_WIDGETS_CAP} + + +@router.put("/performance") +def put_performance(body: PerformanceBody, db: Session = Depends(get_db), user=Depends(require(KEY))): + _save_setting(db, MAX_WIDGETS, str(body.max_widgets)) + db.commit() + return {"max_widgets": body.max_widgets, "recommended": 10, "cap": MAX_WIDGETS_CAP} + + class BadgesBody(BaseModel): badges: list = Field(default_factory=list) diff --git a/local_backend/tests/test_signage_library.py b/local_backend/tests/test_signage_library.py index 6f7614b..47f38ff 100644 --- a/local_backend/tests/test_signage_library.py +++ b/local_backend/tests/test_signage_library.py @@ -77,9 +77,12 @@ def test_blank_slides_and_widgets_placed_by_hand(client, owner_h): p = playlist(client, owner_h) s = slide(client, owner_h, p["id"], "blank", content={"widgets": [ {"kind": "clock", "position": "custom", "box": {"x": 90, "y": 5, "w": 20, "h": 10}, "align": "right"}, - {"kind": "date", "position": "top-left", "size": "custom", "box": {"x": 1, "y": 1, "w": 5, "h": 5}}]}) - clock, date = s["content"]["widgets"] - assert clock["size"] == "custom" and clock["box"] == {"x": 80, "y": 5, "w": 20, "h": 10} and clock["align"] == "right" # kept on the slide + {"kind": "date", "position": "top-left", "size": "custom", "box": {"x": 1, "y": 1, "w": 5, "h": 5}}, + {"kind": "text", "text": "Big", "position": "custom", "box": {"x": 99, "y": -50, "w": 30, "h": 20}}]}) + clock, date, big = s["content"]["widgets"] + # owner review 6: a box may run off the slide (here past the right edge), a strip of it stays on it + assert clock["size"] == "custom" and clock["box"] == {"x": 90, "y": 5, "w": 20, "h": 10} and clock["align"] == "right" + assert big["box"] == {"x": 95, "y": -15, "w": 30, "h": 20} assert date["size"] == "medium" and date["box"] is None # a corner: no box, a real size r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [{"kind": "clock", "position": "custom"}]}}) assert err(r) == "signage.content_invalid" # placed by hand needs its box diff --git a/local_backend/tests/test_signage_stacks.py b/local_backend/tests/test_signage_stacks.py index 5419a05..084235d 100644 --- a/local_backend/tests/test_signage_stacks.py +++ b/local_backend/tests/test_signage_stacks.py @@ -173,3 +173,19 @@ def test_the_venues_badges_and_a_widgets_own_look(client, owner_h, menu, screens url = f"/api/signage/playlists/{p['id']}/slides" for bad in ({"badges": {sid: ["a", "b", "c", "d", "e"]}}, {"board_valign": "centre"}, {"widgets": [{"kind": "clock", "text_size": 400}]}): assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": bad})) == "signage.content_invalid", bad + + +def test_how_many_widgets_a_slide_may_hold_is_the_venues(client, owner_h): + """Owner review 6 (2026-11-21): 10 widgets a slide (recommended), more when the venue allows them + (Signage → Message & settings → Performance), never over 50; a menu with pages may now turn them + every second.""" + assert client.get("/api/signage/performance", headers=owner_h).json() == {"max_widgets": 10, "recommended": 10, "cap": 50} + p = playlist(client, owner_h) + url = f"/api/signage/playlists/{p['id']}/slides" + eleven = [{"kind": "clock"}] * 11 + assert err(client.post(url, headers=owner_h, json={"kind": "blank", "content": {"widgets": eleven}})) == "signage.too_many_widgets" + assert client.put("/api/signage/performance", headers=owner_h, json={"max_widgets": 12}).json()["max_widgets"] == 12 + assert client.post(url, headers=owner_h, json={"kind": "blank", "content": {"widgets": eleven}}).status_code == 201 + assert err(client.put("/api/signage/performance", headers=owner_h, json={"max_widgets": 51})) is not None + s = slide(client, owner_h, p["id"], "menu", content={"page_seconds": 1}, duration_s=1) + assert s["content"]["page_seconds"] == 1 and s["duration_s"] == 1 diff --git a/manager_dashboard/src/pages/Settings/sections/TableColours.jsx b/manager_dashboard/src/pages/Settings/sections/TableColours.jsx index 9672cec..d870c2a 100644 --- a/manager_dashboard/src/pages/Settings/sections/TableColours.jsx +++ b/manager_dashboard/src/pages/Settings/sections/TableColours.jsx @@ -6,7 +6,7 @@ import { useEffect, useState } from 'react' import { RotateCcw } from 'lucide-react' import { useTranslation } from '@xenia/i18n' -import { Button, Dialog, Field, Input, Spinner, Switch } from '@xenia/ui' +import { Button, Dialog, Field, Input, Slider, Spinner, Switch } from '@xenia/ui' import { SettingsCard } from './SettingsCard' import { buildColour, mergeColours, parseColour, readJson, setSlot } from './settingsLogic' import { useSettings } from './useSettings' @@ -137,9 +137,7 @@ function ColourDialog({ slot, value, title, onClose, onSave }) { setHex(e.target.value.trim())} data-testid="colour-hex" /> - - setAlpha(Number(e.target.value))} className="w-full accent-accent" /> - + setAlpha(v / 100)} /> {(QUICK_SWATCHES[slot] ?? []).map(c => ( diff --git a/manager_dashboard/src/pages/floor/FloorEditor.jsx b/manager_dashboard/src/pages/floor/FloorEditor.jsx index bace9ed..45ecc68 100644 --- a/manager_dashboard/src/pages/floor/FloorEditor.jsx +++ b/manager_dashboard/src/pages/floor/FloorEditor.jsx @@ -23,7 +23,7 @@ import { nearestEdge, outlineOf, removeCorner, resizeBox, toPlan, } from '@xenia/floorplan' import { useTranslation } from '@xenia/i18n' -import { Button, Dialog, Dropdown, Field, IconButton, Input, Segmented, Stepper, Switch, cx } from '@xenia/ui' +import { Button, Dialog, Dropdown, Field, IconButton, Input, Segmented, Slider, Stepper, Switch, cx } from '@xenia/ui' import MediaField from '../media/MediaField' import * as api from './floorApi' import { WALL_THICKNESS, addItem, addable, cellOf, find, fitOutline, layoutBody, layoutOf, nudge, placeTable, planBody, remove, resizeCells, rotate, sameLayout, toCells, update } from './editorLogic' @@ -329,9 +329,8 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele setF('background', img)} label={t('floor.background')} testid="floor-background" /> {form.background && ( - + setF('background_opacity', v / 100)} /> )} diff --git a/manager_dashboard/src/pages/signage/MenuEditor.jsx b/manager_dashboard/src/pages/signage/MenuEditor.jsx index 9302e20..4a0b201 100644 --- a/manager_dashboard/src/pages/signage/MenuEditor.jsx +++ b/manager_dashboard/src/pages/signage/MenuEditor.jsx @@ -20,7 +20,7 @@ import { AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVe import { MENU_LANGUAGES, SALES_POINTS } from '@xenia/access' import { useFormat, useLanguage, useTranslation } from '@xenia/i18n' import { badgeName } from '@xenia/signage' -import { Dropdown, Field, IconButton, Input, Segmented, Slider, Switch } from '@xenia/ui' +import { Dropdown, Field, IconButton, Input, NumberInput, Segmented, Slider, Switch } from '@xenia/ui' import client from '../../api/client' import { boardOrder, moveGroup, moveItem, toggled } from './signageLogic' import { useBadges } from './useBadges' @@ -227,8 +227,9 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [ { const n = digits(e.target.value); setC({ page_size: n ? Math.min(60, Math.max(3, n)) : null }) }} data-testid="signage-menu-per-page" /> - - setC({ page_seconds: Math.min(120, Math.max(3, digits(e.target.value) || 3)) })} /> + + setC({ page_seconds: v })} data-testid="signage-page-seconds" /> diff --git a/manager_dashboard/src/pages/signage/PerformanceSettings.jsx b/manager_dashboard/src/pages/signage/PerformanceSettings.jsx new file mode 100644 index 0000000..51b518a --- /dev/null +++ b/manager_dashboard/src/pages/signage/PerformanceSettings.jsx @@ -0,0 +1,46 @@ +// Signage → Message & settings → Performance (owner review 6, 2026-11-21): how many widgets a slide +// may hold. 10 is strongly recommended: every widget is drawn on the TV many times a second, and +// small TV computers slow down with many; the venue may still allow more (up to 50). +import { useEffect, useState } from 'react' +import toast from 'react-hot-toast' +import { AlertTriangle } from 'lucide-react' +import { errorMessage } from '@xenia/api' +import { useTranslation } from '@xenia/i18n' +import { Button, Field, NumberInput } from '@xenia/ui' +import * as api from './signageApi' +import { setPerformance, usePerformance } from './usePerformance' + +export default function PerformanceSettings() { + const { t } = useTranslation('manager') + const saved = usePerformance() + const [most, setMost] = useState(saved.max_widgets) + const [busy, setBusy] = useState(false) + useEffect(() => { setMost(saved.max_widgets) }, [saved.max_widgets]) + const save = async () => { + setBusy(true) + try { setPerformance(await api.putPerformance({ max_widgets: most })); toast.success(t('settings.saved')) } + catch (err) { toast.error(errorMessage(err, t)) } + setBusy(false) + } + const over = most != null && most > saved.recommended + return ( +
+

{t('signage.performance.title')}

+

{t('signage.performance.hint', { n: saved.recommended })}

+
+ + + + + {most !== saved.recommended && ( + + )} +
+ {over && ( +

+

+ )} +
+ ) +} diff --git a/manager_dashboard/src/pages/signage/PlaylistEditor.jsx b/manager_dashboard/src/pages/signage/PlaylistEditor.jsx index 96d9bca..a32f4b1 100644 --- a/manager_dashboard/src/pages/signage/PlaylistEditor.jsx +++ b/manager_dashboard/src/pages/signage/PlaylistEditor.jsx @@ -14,7 +14,8 @@ import { errorMessage } from '@xenia/api' import { useTranslation } from '@xenia/i18n' import { Button, Dialog, Dropdown, Field, IconButton, Input, Spinner, Textarea, useConfirm } from '@xenia/ui' import * as api from './signageApi' -import { mediaEntry, mediaLookup, misfits, moved, slideBody, totalSeconds, TRANSITIONS, windowParts } from './signageLogic' +import { mediaEntry, mediaLookup, misfits, moved, secondsMissing, slideBody, totalSeconds, TRANSITIONS, windowParts } from './signageLogic' +import { playSeconds } from './timing' import AddSlideDialog, { KIND_ICON } from './AddSlideDialog' import SlideEditor, { SlideBasics } from './SlideEditor' import SlidePreview from './SlidePreview' @@ -92,6 +93,7 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) { const how = await confirm({ title: t('signage.discardTitle'), body: t('signage.discard'), confirmLabel: t('signage.discardYes'), tone: 'danger', altLabel: t('signage.saveAndLeave'), testId: 'signage-discard' }) if (how !== 'alt') return how + if (secondsMissing(draft)) { toast.error(t('signage.secondsEmpty')); return false } return (await run(() => api.updateSlide(draft.id, slideBody(draft)), t('settings.saved'))) != null } const pick = async s => { @@ -133,7 +135,7 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) { const made = await run(() => api.addSlide(pl.id, body), t('signage.added')) if (made) await load(made.id) } - const total = totalSeconds(pl.slides, media) + const total = totalSeconds(pl.slides, media, s => playSeconds(s, pl.orientation)) const marker = i => drag && drag.at === i && drag.at !== drag.from && drag.at !== drag.from + 1 return ( @@ -163,7 +165,7 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) { {/* the timeline: cards of one size, scrolling sideways; a line shows where a dragged card lands */}
-
    { if (!e.currentTarget.contains(e.relatedTarget)) setDrag(d => (d ? { ...d, at: null } : d)) }}> +
      { if (!e.currentTarget.contains(e.relatedTarget)) setDrag(d => (d ? { ...d, at: null } : d)) }}> {pl.slides.map((s, i) => { const Icon = KIND_ICON[s.kind] || ImageIcon const parts = windowParts(s) @@ -189,7 +191,7 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) { {bad[s.id] && } - {s.kind === 'video' && s.video_to_end ? t('signage.toTheEnd') : t('signage.seconds', { count: s.duration_s })} + {s.kind === 'video' && s.video_to_end ? t('signage.toTheEnd') : t('signage.seconds', { count: playSeconds(s, pl.orientation) })} {!s.enabled && <> · {t('signage.off')}} {parts.map(p => · {p.key === 'days' ? p.params.days.map(d => t(`signage.weekdays.${d}`)).join(' ') : t(`signage.window.${p.key}`, p.params)})} @@ -217,7 +219,7 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) { {/* the picked slide: its basics beside its preview (one height), then what it shows */} {draft ? <>
      - + @@ -227,7 +229,7 @@ export default function PlaylistEditor({ playlistId, onChanged, onDeleted }) { misfit={draftBad} widget={widget} onWidget={setWidget} />
      - {dirty && {t('display.looks.unsaved')}} diff --git a/manager_dashboard/src/pages/signage/SignagePage.jsx b/manager_dashboard/src/pages/signage/SignagePage.jsx index 095241b..03eef52 100644 --- a/manager_dashboard/src/pages/signage/SignagePage.jsx +++ b/manager_dashboard/src/pages/signage/SignagePage.jsx @@ -57,10 +57,10 @@ export default function SignagePage() {
    1. diff --git a/manager_dashboard/src/pages/signage/SignageSettingsTab.jsx b/manager_dashboard/src/pages/signage/SignageSettingsTab.jsx index 102b459..9777c86 100644 --- a/manager_dashboard/src/pages/signage/SignageSettingsTab.jsx +++ b/manager_dashboard/src/pages/signage/SignageSettingsTab.jsx @@ -10,6 +10,7 @@ import { useFormat, useLanguage, useTranslation } from '@xenia/i18n' import { Button, Dropdown, Field, Input, Spinner } from '@xenia/ui' import BadgesSettings from './BadgesSettings' import MessageOfTheDay from './MessageOfTheDay' +import PerformanceSettings from './PerformanceSettings' import * as api from './signageApi' export default function SignageSettingsTab() { @@ -87,6 +88,7 @@ export default function SignageSettingsTab() {
+ ) } diff --git a/manager_dashboard/src/pages/signage/SlideEditor.jsx b/manager_dashboard/src/pages/signage/SlideEditor.jsx index a93b018..965c802 100644 --- a/manager_dashboard/src/pages/signage/SlideEditor.jsx +++ b/manager_dashboard/src/pages/signage/SlideEditor.jsx @@ -9,17 +9,36 @@ // font, size in a frame, colour as a field that opens its colours). import { AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart } from 'lucide-react' import { useTranslation } from '@xenia/i18n' -import { ColourField, Dropdown, Field, FilterChip, Input, Segmented, Slider, Switch, Textarea } from '@xenia/ui' +import { ColourField, Dropdown, Field, FilterChip, Input, NumberInput, Segmented, Slider, Switch, Textarea } from '@xenia/ui' +import { pagesOn, playSeconds } from './timing' import { FONT_KEYS, TRANSITIONS } from './signageLogic' import { BackgroundField, MediaPick, Section } from './SignageFields' import MenuEditor from './MenuEditor' import WidgetsEditor from './WidgetsEditor' +/** + * How long a menu board really plays (owner review 6): whole rounds of its pages, so its seconds on + * screen are rounded up; said under the field when they differ (with why). + */ +function PlayNote({ slide, orientation }) { + const { t } = useTranslation('manager') + if (slide.kind !== 'menu' || slide.duration_s == null || slide.content?.page_seconds == null) return null + const pages = pagesOn(slide, orientation) + const real = playSeconds(slide, orientation) + if (pages <= 1 || real === slide.duration_s) return null + const per = slide.content.page_seconds || 10 + return ( +

+ {t('signage.playNote', { real, rounds: real / (pages * per), pages, per, set: slide.duration_s })} +

+ ) +} + /** * The slide's basics: name (unless `showName` is off: the Slides library has its own), show it or * not, its transition, seconds on screen (or a video to its end), and when it shows. */ -export function SlideBasics({ slide, onChange, showName = true }) { +export function SlideBasics({ slide, onChange, showName = true, orientation = 'landscape' }) { const { t } = useTranslation('manager') const set = patch => onChange({ ...slide, ...patch }) const days = slide.days || [] @@ -39,11 +58,11 @@ export function SlideBasics({ slide, onChange, showName = true }) { options={[{ value: '', label: t('signage.transitionDefault') }, ...TRANSITIONS.map(x => ({ value: x, label: t(`signage.transitions.${x}`) }))]} />
{!toEnd && ( - - set({ duration_s: Math.min(3600, Number(e.target.value.replace(/\D/g, '')) || 0) })} /> + + set({ duration_s: v })} data-testid="signage-duration" /> )} + {!toEnd && } {slide.kind === 'video' && ( set({ video_to_end: on })} label={t('signage.videoToEnd')} description={t('signage.videoToEndHint')} data-testid="signage-video-to-end" /> diff --git a/manager_dashboard/src/pages/signage/SlidesTab.jsx b/manager_dashboard/src/pages/signage/SlidesTab.jsx index 43264d0..ed758d6 100644 --- a/manager_dashboard/src/pages/signage/SlidesTab.jsx +++ b/manager_dashboard/src/pages/signage/SlidesTab.jsx @@ -11,7 +11,7 @@ import { errorMessage } from '@xenia/api' import { useTranslation } from '@xenia/i18n' import { Button, EmptyState, Field, IconButton, Input, Pane, Segmented, Spinner, Textarea, useConfirm } from '@xenia/ui' import * as api from './signageApi' -import { mediaEntry, mediaLookup, misfits, savedBody } from './signageLogic' +import { mediaEntry, mediaLookup, misfits, savedBody, secondsMissing } from './signageLogic' import AddSlideDialog, { KIND_ICON } from './AddSlideDialog' import SlideEditor, { SlideBasics } from './SlideEditor' import SlidePreview from './SlidePreview' @@ -126,7 +126,7 @@ function SavedSlideEditor({ id, venue, onClose }) { if (dirty) { const how = await confirm({ title: t('signage.discardTitle'), body: t('signage.discard'), confirmLabel: t('signage.discardYes'), tone: 'danger', altLabel: t('signage.saveAndLeave'), testId: 'signage-discard' }) - if (!how || (how === 'alt' && (!draft.name?.trim() || !(await save())))) return + if (!how || (how === 'alt' && (!draft.name?.trim() || secondsMissing(draft) || !(await save())))) return } onClose() } @@ -140,7 +140,7 @@ function SavedSlideEditor({ id, venue, onClose }) {

{draft.name || t('signage.library.untitled')}

{dirty && {t('display.looks.unsaved')}} - + }>
@@ -167,7 +167,7 @@ function SavedSlideEditor({ id, venue, onClose }) { {t('signage.library.settings')}}>
- + setMedia(m => ({ ...m, [String(item.id)]: mediaEntry(item) }))} misfit={draftBad} widget={widget} onWidget={setWidget} />
diff --git a/manager_dashboard/src/pages/signage/WidgetCanvas.jsx b/manager_dashboard/src/pages/signage/WidgetCanvas.jsx index 3c999fe..3f73116 100644 --- a/manager_dashboard/src/pages/signage/WidgetCanvas.jsx +++ b/manager_dashboard/src/pages/signage/WidgetCanvas.jsx @@ -10,9 +10,13 @@ // Owner review 5 (2026-11-21): widgets inside a stack's parts too. Pick the stack, then click a // widget in it: it moves and sizes inside its place (it can't leave the stack; its box is % of its // place). The picked widget is a path: "2", or "2.1.0" (stack 2, part 1, its first widget). +// Owner review 6: a text, clock, QR… placed by hand is exactly as big as what it shows (its box is +// its content: sized by its handles keeping its shape; its text size makes it bigger too); a slide's +// widget may be moved off the slide as long as a strip of it stays to grab it back. import { useEffect, useLayoutEffect, useRef, useState } from 'react' import { useTranslation } from '@xenia/i18n' -import { boxFromRect, moveBox, resizeBox, snapBox, stackOf, widgetAt } from './signageLogic' +import { TIGHT } from '@xenia/signage' +import { boxFromRect, moveBox, moveLoose, resizeBox, scaleBox, snapBox, stackOf, widgetAt } from './signageLogic' const HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'] const CURSOR = { n: 'ns-resize', s: 'ns-resize', e: 'ew-resize', w: 'ew-resize', nw: 'nwse-resize', se: 'nwse-resize', ne: 'nesw-resize', sw: 'nesw-resize' } @@ -46,9 +50,10 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl const sel = selected != null ? String(selected) : null // a widget's box in its own frame: the slide's (%), or its place's for a widget in a stack + const tight = path => TIGHT.includes(widgetAt(widgets, path)?.kind) const own = path => { const w = widgetAt(widgets, path) - if (w?.position === 'custom' && w.box) return w.box + if (w?.position === 'custom' && w.box && !tight(path)) return w.box const r = rects[path] const place = stackOf(path) != null ? rects[`place:${path}`] : null if (!r || stackOf(path) == null) return r || null @@ -63,6 +68,16 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl return { x: place.x + b.x * place.w / 100, y: place.y + b.y * place.h / 100, w: b.w * place.w / 100, h: b.h * place.h / 100 } } + // what is stored for a tight widget: where it sits and its height before its text size (the + // height scaled as the drawn one was, so it never creeps); others: the box as drawn + const stored = (path, from, to) => { + const w = widgetAt(widgets, path) + if (!tight(path)) return to + const ts = (w.text_size || 100) / 100 + const h0 = w.position === 'custom' && w.box ? w.box.h : from.h / ts + return { ...to, h: Math.max(1, Math.round(h0 * (to.h / from.h) * 100) / 100) } + } + const start = (e, path, handle = null) => { e.preventDefault() e.stopPropagation() @@ -84,11 +99,12 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl moved = true const dx = (ev.clientX - x0) / width * 100 const dy = (ev.clientY - y0) / height * 100 - const next = handle ? resizeBox(base, handle, dx, dy) : moveBox(base, dx, dy) - if (inside) { onPlace(path, next); return } + const shaped = tight(path) + const next = handle ? (shaped ? scaleBox(base, handle, dx, dy) : resizeBox(base, handle, dx, dy)) : inside ? moveBox(base, dx, dy) : moveLoose(base, dx, dy) + if (inside || (handle && shaped)) { onPlace(path, stored(path, base, next)); return } const snapped = snapBox(next, handle) setGuides(snapped.guides) - onPlace(path, snapped.box) + onPlace(path, stored(path, base, snapped.box)) } const up = () => { window.removeEventListener('pointermove', move) @@ -112,7 +128,7 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl if (!d) return e.preventDefault() const base = own(sel) - if (base) onPlace(sel, moveBox(base, d[0], d[1])) + if (base) onPlace(sel, stored(sel, base, (stackOf(sel) != null ? moveBox : moveLoose)(base, d[0], d[1]))) } window.addEventListener('keydown', on) return () => window.removeEventListener('keydown', on) diff --git a/manager_dashboard/src/pages/signage/WidgetsEditor.jsx b/manager_dashboard/src/pages/signage/WidgetsEditor.jsx index 2cba307..97bb730 100644 --- a/manager_dashboard/src/pages/signage/WidgetsEditor.jsx +++ b/manager_dashboard/src/pages/signage/WidgetsEditor.jsx @@ -18,7 +18,7 @@ // has every setting a slide's widget has, aligned both ways in its place or moved and sized there on // the preview (Custom); the message of the day changed from its widget. The picked widget is a path // ("2", "2.1.0": see WidgetCanvas). -// Up to 10 (the server's limit). +// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance). import { Fragment, useEffect, useRef, useState } from 'react' import { AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Bold, Italic, Palette, RotateCcw, Underline, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical, @@ -28,6 +28,7 @@ import { cellWidgets, evenShares, setShare } from '@xenia/signage' import { useTranslation } from '@xenia/i18n' import { Button, ColourField, Dialog, Dropdown, Field, FieldRow, IconButton, Input, Popover, Segmented, Slider, Switch } from '@xenia/ui' import MessageOfTheDay from './MessageOfTheDay' +import { usePerformance } from './usePerformance' import * as api from './signageApi' import MenuEditor from './MenuEditor' import { MediaPick, Section } from './SignageFields' @@ -52,6 +53,7 @@ function useLibrary() { export default function WidgetsEditor({ widgets = [], onChange, media, onMedia, selected = null, onSelect, extras = {} }) { const { t } = useTranslation('manager') + const most = usePerformance().max_widgets // the venue's limit (Performance; 10 recommended) const [drag, setDrag] = useState(null) // { from, at }: the card dragged and where it would land const set = (i, patch) => onChange(widgets.map((w, j) => (j === i ? { ...w, ...patch } : w))) const add = kind => { @@ -129,7 +131,7 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia, ) })} {line(widgets.length)} - {widgets.length < 10 && ( + {widgets.length < most && (
{[...WIDGET_KINDS, 'hstack', 'vstack'].map(k => { const Icon = ICON[k] @@ -141,6 +143,7 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia, })}
)} + {widgets.length >= most &&

{t('signage.widgets.full', { count: most })}

} ) } diff --git a/manager_dashboard/src/pages/signage/signageApi.js b/manager_dashboard/src/pages/signage/signageApi.js index fe7dffe..0318258 100644 --- a/manager_dashboard/src/pages/signage/signageApi.js +++ b/manager_dashboard/src/pages/signage/signageApi.js @@ -46,3 +46,7 @@ export const refreshWeather = () => client.post('/api/signage/weather/refresh'). // the venue's badges (owner review 5): their names, colours and icons export const getBadges = () => client.get('/api/signage/badges').then(data) export const putBadges = badges => client.put('/api/signage/badges', { badges }).then(data) + +// limits that keep the TVs smooth (owner review 6): widgets per slide +export const getPerformance = () => client.get('/api/signage/performance').then(data) +export const putPerformance = body => client.put('/api/signage/performance', body).then(data) diff --git a/manager_dashboard/src/pages/signage/signageLogic.js b/manager_dashboard/src/pages/signage/signageLogic.js index 8ec146f..58a8f21 100644 --- a/manager_dashboard/src/pages/signage/signageLogic.js +++ b/manager_dashboard/src/pages/signage/signageLogic.js @@ -77,18 +77,30 @@ export function windowParts(slide) { } /** The playlist's total time for one round (videos to their end count by their length if known). */ -export function totalSeconds(slides, media) { +export function totalSeconds(slides, media, secondsOf = s => s.duration_s || 10) { let total = 0 for (const s of slides || []) { if (!s.enabled) continue if (s.kind === 'video' && s.video_to_end) { const ms = media?.[String(s.content?.media_id)]?.duration_ms total += ms ? Math.round(ms / 1000) : s.duration_s || 10 - } else total += s.duration_s || 10 + } else total += secondsOf(s) } return total } +/** A seconds field left empty (owner review 6: it may be emptied while typing; the slide can't be + * saved until it is filled): seconds on screen, a menu board's or a menu widget's seconds per page. */ +export function secondsMissing(slide) { + if (!slide) return false + if (slide.duration_s == null && !(slide.kind === 'video' && slide.video_to_end)) return true + const c = slide.content || {} + if (slide.kind === 'menu' && c.page_seconds === null) return true + const boards = ws => (ws || []).some(w => (w.kind === 'menu' && w.board?.page_seconds === null) + || (w.cells || []).some(x => boards(x.widgets || (x.widget ? [x.widget] : [])))) + return boards(c.widgets) +} + /** Move the item at `from` to `to` in a copy of `list`. */ export function moved(list, from, to) { const out = [...list] @@ -233,6 +245,28 @@ export function resizeBox(b, handle, dx, dy, min = MIN_BOX) { return { x: round(x), y: round(y), w: round(w), h: round(h) } } +/** A box moved off the slide as far as a strip of it (5 %) stays on it, to grab it back (owner review 6). */ +export function moveLoose(b, dx, dy) { + return { ...b, x: round(clamp(b.x + dx, 5 - b.w, 95)), y: round(clamp(b.y + dy, 5 - b.h, 95)) } +} + +/** + * A box that is exactly its content (a text, a clock, a QR…; owner review 6) scaled from a handle: + * it keeps its shape (width and height grow together); the handle's opposite corner or edge stays. + * `aspect` = the box's width / height in % of the slide (as measured). A side handle scales by its + * own direction, a corner by the larger of the two. + */ +export function scaleBox(b, handle, dx, dy, aspect = b.w / b.h, min = 1) { + const byW = handle.includes('e') ? (b.w + dx) / b.w : handle.includes('w') ? (b.w - dx) / b.w : null + const byH = handle.includes('s') ? (b.h + dy) / b.h : handle.includes('n') ? (b.h - dy) / b.h : null + const k = byW == null ? byH : byH == null ? byW : Math.max(byW, byH) + const h = Math.max(min, b.h * k) + const w = h * aspect + const x = handle.includes('w') ? b.x + b.w - w : handle.includes('e') ? b.x : b.x + (b.w - w) / 2 + const y = handle.includes('n') ? b.y + b.h - h : handle.includes('s') ? b.y : b.y + (b.h - h) / 2 + return { x: round(x), y: round(y), w: round(w), h: round(h) } +} + /** * A moved box pulled onto the slide's edges and middle lines when it comes within `near` %: * → { box, guides: ['x:50', 'y:0', …] } (the lines it sits on, for the editor to draw). diff --git a/manager_dashboard/src/pages/signage/timing.js b/manager_dashboard/src/pages/signage/timing.js new file mode 100644 index 0000000..b1de96f --- /dev/null +++ b/manager_dashboard/src/pages/signage/timing.js @@ -0,0 +1,16 @@ +// How long a slide really plays (owner review 6, 2026-11-21): a menu board with pages plays whole +// rounds of them, so its seconds on screen are rounded up (the TV does the same: menuMs). +import { boardPages, menuMs } from '@xenia/signage' + +/** A menu board's pages on a TV of this shape (1 when it fits, or without its products yet). */ +export function pagesOn(slide, orientation = 'landscape') { + if (slide?.kind !== 'menu' || !slide.menu) return 1 + const [w, h] = orientation === 'portrait' ? [1080, 1920] : [1920, 1080] + return Math.max(1, boardPages(slide, 0, w, h).length) +} + +/** The seconds a slide stays on a TV of this shape. */ +export function playSeconds(slide, orientation = 'landscape') { + if (slide?.kind !== 'menu') return slide?.duration_s || 10 + return Math.round(menuMs({ ...slide, duration_s: slide.duration_s || 10 }, pagesOn(slide, orientation)) / 1000) +} diff --git a/manager_dashboard/src/pages/signage/usePerformance.js b/manager_dashboard/src/pages/signage/usePerformance.js new file mode 100644 index 0000000..fc2833e --- /dev/null +++ b/manager_dashboard/src/pages/signage/usePerformance.js @@ -0,0 +1,23 @@ +// The venue's signage limits (owner review 6, 2026-11-21: widgets per slide, 10 recommended), read +// once for the page; saving them (Message & settings → Performance) updates every editor at once. +import { useEffect, useState } from 'react' +import * as api from './signageApi' + +const DEFAULTS = { max_widgets: 10, recommended: 10, cap: 50 } +let cache = null +const listeners = new Set() + +export function setPerformance(p) { + cache = p + listeners.forEach(f => f(p)) +} + +export function usePerformance() { + const [p, setP] = useState(cache || DEFAULTS) + useEffect(() => { + listeners.add(setP) + if (!cache) api.getPerformance().then(setPerformance).catch(() => {}) + return () => { listeners.delete(setP) } + }, []) + return p +} diff --git a/manager_dashboard/tests/signage.test.mjs b/manager_dashboard/tests/signage.test.mjs index 682b09c..9e57c34 100644 --- a/manager_dashboard/tests/signage.test.mjs +++ b/manager_dashboard/tests/signage.test.mjs @@ -102,3 +102,17 @@ test('the Slides library: what is saved, and a copy for a playlist', async () => assert.equal(saved.content.widgets[0].kind, 'name') // a copy, never the kept slide }) + +test('owner review 6: a box off the slide (a strip stays), a tight box scaled keeping its shape', async () => { + const { moveLoose, scaleBox, secondsMissing } = await import('../src/pages/signage/signageLogic.js') + assert.deepEqual(moveLoose({ x: 50, y: 10, w: 20, h: 10 }, 60, -30), { x: 95, y: -5, w: 20, h: 10 }) + assert.deepEqual(moveLoose({ x: 50, y: 10, w: 20, h: 10 }, -100, 0), { x: -15, y: 10, w: 20, h: 10 }) + assert.deepEqual(scaleBox({ x: 10, y: 10, w: 20, h: 10 }, 'se', 20, 0), { x: 10, y: 10, w: 40, h: 20 }) // twice as wide → twice as tall + assert.deepEqual(scaleBox({ x: 10, y: 10, w: 20, h: 10 }, 'n', 0, -10), { x: 0, y: 0, w: 40, h: 20 }) // the bottom stays, centred across + assert.deepEqual(scaleBox({ x: 10, y: 10, w: 20, h: 10 }, 'nw', 10, 2), { x: 14, y: 12, w: 16, h: 8 }) // a corner: the larger of the two (0.5, 0.8) + assert.equal(secondsMissing({ kind: 'menu', duration_s: 10, content: { page_seconds: null } }), true) + assert.equal(secondsMissing({ kind: 'text', duration_s: null, content: {} }), true) + assert.equal(secondsMissing({ kind: 'video', video_to_end: true, duration_s: null, content: {} }), false) + assert.equal(secondsMissing({ kind: 'blank', duration_s: 5, content: { widgets: [{ kind: 'stack', cells: [{ widgets: [{ kind: 'menu', board: { page_seconds: null } }] }] }] } }), true) + assert.equal(secondsMissing({ kind: 'menu', duration_s: 5, content: { page_seconds: 3 } }), false) +}) diff --git a/packages/i18n/locales/el/errors.json b/packages/i18n/locales/el/errors.json index f5c06a2..caf66c2 100644 --- a/packages/i18n/locales/el/errors.json +++ b/packages/i18n/locales/el/errors.json @@ -189,7 +189,8 @@ "weather_offline": "Η υπηρεσία καιρού δεν είναι διαθέσιμη: ο διακομιστής του καταστήματος χρειάζεται internet γι' αυτήν.", "schedule_unknown": "Το πρόγραμμα {{schedule_id}} δεν βρέθηκε.", "scene_unknown": "Αυτή η σκηνή δεν υπάρχει πια.", - "screen_unknown": "Αυτή η οθόνη δεν υπάρχει πια." + "screen_unknown": "Αυτή η οθόνη δεν υπάρχει πια.", + "too_many_widgets": "Μια διαφάνεια έχει το πολύ {{max}} widgets (Προβολή → Μήνυμα & ρυθμίσεις → Απόδοση)." }, "menu_tablet": { "no_table": "Αυτό το tablet δεν είναι σε τραπέζι, οπότε δεν καλεί σερβιτόρο.", diff --git a/packages/i18n/locales/el/manager.json b/packages/i18n/locales/el/manager.json index de67db0..298bf54 100644 --- a/packages/i18n/locales/el/manager.json +++ b/packages/i18n/locales/el/manager.json @@ -1557,7 +1557,9 @@ "textSize": "Μέγεθος κειμένου", "qrColour": "Χρώμα κωδικού QR", "qrBackground": "Φόντο κωδικού QR", - "changeMessage": "Αλλαγή μηνύματος" + "changeMessage": "Αλλαγή μηνύματος", + "full_one": "Αυτή η διαφάνεια έχει τα περισσότερα widgets που επιτρέπονται ({{count}}). Προβολή → Μήνυμα & ρυθμίσεις → Απόδοση.", + "full_other": "Αυτή η διαφάνεια έχει τα περισσότερα widgets που επιτρέπονται ({{count}}). Προβολή → Μήνυμα & ρυθμίσεις → Απόδοση." }, "tabs": { "playlists": "Λίστες", @@ -1768,6 +1770,16 @@ "removeTitle": "Αφαίρεση του σήματος «{{name}}»;", "removeBody": "Οι πίνακες που το χρησιμοποιούν σταματούν να το δείχνουν. Τίποτα δεν αλλάζει μέχρι να αποθηκεύσετε.", "needName": "Κάθε σήμα χρειάζεται όνομα (στα ελληνικά ή στα αγγλικά)." + }, + "secondsEmpty": "Συμπληρώστε τα δευτερόλεπτα (1 ή περισσότερα) για να αποθηκεύσετε.", + "playNote": "Παίζει {{real}} δλ., όχι {{set}} δλ.: ένα μενού με σελίδες παίζει ολόκληρους γύρους ({{rounds}} × {{pages}} σελίδες των {{per}} δλ.), ώστε να μη σταματά στη μέση.", + "performance": { + "title": "Απόδοση", + "hint": "Πόσα widgets μπορεί να έχει μια διαφάνεια. Συνιστούμε έντονα {{n}}: κάθε widget ξανασχεδιάζεται συνεχώς στην τηλεόραση, και οι μικροί υπολογιστές των τηλεοράσεων καθυστερούν με πολλά.", + "maxWidgets": "Widgets ανά διαφάνεια", + "empty": "Συμπληρώστε έναν αριθμό (1 ή περισσότερα).", + "backTo": "Πίσω στα {{n}}", + "warning": "Πάνω από {{n}} widgets μπορεί να κάνουν τις τηλεοράσεις να κολλάνε (διαφάνειες που αλλάζουν αργά, βίντεο που κόβονται). Ελέγξτε τις οθόνες σας αφού τα προσθέσετε." } }, "overview": { @@ -2855,7 +2867,6 @@ "width": "Πλάτος", "height": "Ύψος", "background": "Εικόνα φόντου", - "backgroundOpacity": "Ένταση: {{value}}%", "table": "Τραπέζι {{name}}", "shape": "Σχήμα", "shapes": { @@ -2896,7 +2907,8 @@ "decimal": ",", "length": "Μήκος", "thickness": "Πάχος", - "cellsHint": "Σε κελιά του πλέγματος (ανά μισό κελί): ένα κελί είναι το μέγεθος του πλέγματος, οπότε τα μεγέθη ακολουθούν την ανάλυσή του. Ή σύρετε τις λαβές στις πλευρές και τις γωνίες." + "cellsHint": "Σε κελιά του πλέγματος (ανά μισό κελί): ένα κελί είναι το μέγεθος του πλέγματος, οπότε τα μεγέθη ακολουθούν την ανάλυσή του. Ή σύρετε τις λαβές στις πλευρές και τις γωνίες.", + "backgroundOpacityLabel": "Ένταση" }, "orders": { "back": "Πίσω", diff --git a/packages/i18n/locales/en/errors.json b/packages/i18n/locales/en/errors.json index 5b1cb25..dfef242 100644 --- a/packages/i18n/locales/en/errors.json +++ b/packages/i18n/locales/en/errors.json @@ -189,7 +189,8 @@ "weather_offline": "The weather service can't be reached: the venue's server needs internet for it.", "schedule_unknown": "Schedule {{schedule_id}} not found.", "scene_unknown": "That scene doesn't exist any more.", - "screen_unknown": "That screen doesn't exist any more." + "screen_unknown": "That screen doesn't exist any more.", + "too_many_widgets": "A slide holds at most {{max}} widgets (Signage → Message & settings → Performance)." }, "menu_tablet": { "no_table": "This tablet isn't at a table, so it can't call a waiter.", diff --git a/packages/i18n/locales/en/manager.json b/packages/i18n/locales/en/manager.json index 6c4cf71..bd0ebab 100644 --- a/packages/i18n/locales/en/manager.json +++ b/packages/i18n/locales/en/manager.json @@ -1557,7 +1557,9 @@ "textSize": "Text size", "qrColour": "QR code colour", "qrBackground": "QR code background", - "changeMessage": "Change the message" + "changeMessage": "Change the message", + "full_one": "This slide holds the most widgets allowed ({{count}}). Signage → Message & settings → Performance.", + "full_other": "This slide holds the most widgets allowed ({{count}}). Signage → Message & settings → Performance." }, "tabs": { "playlists": "Playlists", @@ -1768,6 +1770,16 @@ "removeTitle": "Remove the badge \"{{name}}\"?", "removeBody": "Boards that use it stop showing it. Nothing changes until you save.", "needName": "Every badge needs a name (in Greek or in English)." + }, + "secondsEmpty": "Fill in the seconds (1 or more) to save.", + "playNote": "Plays {{real}} s, not {{set}} s: a menu with pages plays whole rounds ({{rounds}} × {{pages}} pages of {{per}} s), so it never stops in the middle of one.", + "performance": { + "title": "Performance", + "hint": "How many widgets a slide may hold. We strongly recommend {{n}}: every widget is redrawn on the TV all the time, and small TV computers slow down with many.", + "maxWidgets": "Widgets per slide", + "empty": "Fill in a number (1 or more).", + "backTo": "Back to {{n}}", + "warning": "More than {{n}} widgets can make the TVs stutter (slides turning late, videos jerking). Check your screens after you add them." } }, "overview": { @@ -2855,7 +2867,6 @@ "width": "Width", "height": "Height", "background": "Background picture", - "backgroundOpacity": "How strong: {{value}}%", "table": "Table {{name}}", "shape": "Shape", "shapes": { @@ -2896,7 +2907,8 @@ "decimal": ".", "length": "Length", "thickness": "Thickness", - "cellsHint": "In grid cells (by half cells): a cell is the grid's size, so sizes follow the grid resolution. Or drag the handles on its sides and corners." + "cellsHint": "In grid cells (by half cells): a cell is the grid's size, so sizes follow the grid resolution. Or drag the handles on its sides and corners.", + "backgroundOpacityLabel": "How strong" }, "orders": { "back": "Back", diff --git a/packages/signage/src/Slides.jsx b/packages/signage/src/Slides.jsx index 86c0a66..282260f 100644 --- a/packages/signage/src/Slides.jsx +++ b/packages/signage/src/Slides.jsx @@ -6,7 +6,7 @@ import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, Cloud import { QRCodeSVG } from 'qrcode.react' import { BADGE_ICONS } from './badges' import { useFormat, useTranslation } from '@xenia/i18n' -import { badgeColours, badgeName, cellWidgets, fitUnit, FONTS, itemBadges, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic' +import { badgeColours, badgeName, cellWidgets, TIGHT, fitUnit, FONTS, itemBadges, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic' /** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */ export function Background({ bg, media }) { @@ -165,6 +165,7 @@ const CORNER = { 'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' }, } const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' } +const placedBy = w => (w.position === 'custom' && w.box ? (TIGHT.includes(w.kind) ? 'tight' : true) : false) const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: 'center' } /** A widget's own colour and the plate behind it (owner review 5); `pad`: a plate that hugs it. */ const plate = (w, pad) => ({ @@ -186,7 +187,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) { const fmt = useFormat() if (!widgets?.length) return null const ctx = { media, venue, now, fmt, extras: extras || {}, embed } - const shown = widgets.map((w, i) => [w, i, widgetBody(w, ctx, w.position === 'custom' && !!w.box, String(i))]).filter(([, , body]) => body) + const shown = widgets.map((w, i) => [w, i, widgetBody(w, ctx, placedBy(w), String(i))]).filter(([, , body]) => body) const bar = where => shown.filter(([w]) => w.position === where) const bars = [['top-bar', { top: 0 }], ['bottom-bar', { bottom: 0 }]] return ( @@ -201,6 +202,16 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
))} {shown.filter(([w]) => CORNER[w.position] || (w.position === 'custom' && w.box)).map(([w, i, body]) => { + if (w.position === 'custom' && TIGHT.includes(w.kind)) { + // as big as what it shows, from its box's top-left corner (it may run off the slide) + return ( +
+ {body} +
+ ) + } if (w.position === 'custom') { return (
{ if (!fit) return n => `${+(n * s).toFixed(3)}cqmin` + if (fit === 'tight') return n => `${+(n * (w.box.h / height) * ts).toFixed(4)}cqh` const f = fitUnit(height, width) return n => f(n * Math.min(1, ts)) } @@ -255,6 +269,7 @@ function widgetBody(w, ctx, fit, path) { if (w.kind === 'logo') { const m = media(w.media_id) if (!m) return null + if (fit === 'tight') return return fit ? : @@ -381,12 +396,15 @@ function Stack({ w, path, ctx }) { const wp = `${cp}.${k}` const own = cw.position === 'custom' && cw.box const align = cw.align && cw.align !== 'auto' ? cw.align : 'center' - const body = widgetBody(cw, ctx, true, wp) + const body = widgetBody(cw, ctx, own && TIGHT.includes(cw.kind) ? 'tight' : true, wp) return (
- {body && (own ? ( + {body && (own && TIGHT.includes(cw.kind) ? ( +
{body}
+ ) : own ? (
{body}
diff --git a/packages/signage/src/logic.js b/packages/signage/src/logic.js index 3aa1147..1703e50 100644 --- a/packages/signage/src/logic.js +++ b/packages/signage/src/logic.js @@ -130,7 +130,7 @@ export function nextSlide(slides, current, local) { /** How long a slide stays, in ms; null = until its video ends (with a safety limit in the player). */ export function slideMs(slide) { if (slide.kind === 'video' && slide.video_to_end) return null - return Math.max(2, slide.duration_s || 10) * 1000 + return Math.max(1, slide.duration_s || 10) * 1000 } /** The frame's size and turn for a screen: CSS for the box that holds the slides. */ @@ -215,14 +215,17 @@ export function menuPages(groups, perPage, headings = true) { /** A menu slide's time: every page for its seconds, at least the slide's own time. */ export function menuMs(slide, pageCount) { - const per = Math.max(3, slide.content?.page_seconds || 10) * 1000 - return Math.max(slideMs(slide), pageCount > 1 ? pageCount * per : 0) + // owner review 6 (2026-11-21): a board with pages plays whole rounds of them, never cut in the + // middle: its seconds on screen rounded up to the next full round (10 s, 2 pages of 3 s → 12 s) + if (!(pageCount > 1)) return slideMs(slide) + const round = pageCount * Math.max(1, slide.content?.page_seconds || 10) * 1000 + return Math.max(1, Math.ceil(slideMs(slide) / round)) * round } /** The page on screen `elapsedMs` into the slide (the pages go round while the slide lasts). */ export function pageAt(pageCount, pageSeconds, elapsedMs) { if (pageCount <= 1 || !(elapsedMs > 0)) return 0 // the clock's last tick may be just before the slide began - return Math.floor(elapsedMs / (Math.max(3, pageSeconds || 10) * 1000)) % pageCount // round and round while the slide lasts + return Math.floor(elapsedMs / (Math.max(1, pageSeconds || 10) * 1000)) % pageCount // round and round while the slide lasts } /** A weather code (WMO, as Open-Meteo sends it) → an icon name for the widget. */ @@ -258,6 +261,10 @@ export function visibleGroups(groups) { // ── widgets placed by hand (owner 2026-11-21) ───────────────────────────────── +/** Widgets whose box, placed by hand, is exactly their content (owner review 6): its height (× the + * widget's text size) sets the size, its width follows. A menu or a stack fills its box. */ +export const TIGHT = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather'] + /** The slide kinds that carry widgets. */ export const WIDGET_HOSTS = ['text', 'menu', 'blank'] diff --git a/packages/signage/tests/logic.test.mjs b/packages/signage/tests/logic.test.mjs index 82695df..df356bc 100644 --- a/packages/signage/tests/logic.test.mjs +++ b/packages/signage/tests/logic.test.mjs @@ -101,6 +101,11 @@ test('a menu slide stays for all its pages; the page on screen', () => { const slide = { kind: 'menu', duration_s: 10, content: { page_seconds: 8 } } assert.equal(menuMs(slide, 1), 10_000) assert.equal(menuMs(slide, 3), 24_000) + // owner review 6: whole rounds only (10 s, 2 pages of 3 s → 2 rounds of 6 s = 12 s; 7 s of 2 × 3 s → 12 s; 12 s → 12 s) + assert.equal(menuMs({ kind: 'menu', duration_s: 10, content: { page_seconds: 3 } }, 2), 12_000) + assert.equal(menuMs({ kind: 'menu', duration_s: 7, content: { page_seconds: 3 } }, 2), 12_000) + assert.equal(menuMs({ kind: 'menu', duration_s: 12, content: { page_seconds: 3 } }, 2), 12_000) + assert.equal(menuMs({ kind: 'menu', duration_s: 2, content: { page_seconds: 5 } }, 3), 15_000) assert.equal(pageAt(3, 8, 0), 0) assert.equal(pageAt(3, 8, 8_100), 1) assert.equal(pageAt(3, 8, 16_500), 2) diff --git a/packages/ui/src/components.css b/packages/ui/src/components.css index 430e692..1bfb157 100644 --- a/packages/ui/src/components.css +++ b/packages/ui/src/components.css @@ -475,13 +475,35 @@ .x-field-row--wrapped { border-color: var(--x-line); background: var(--x-surface); } .x-field-row--wrapped.x-field-row--shade { background: var(--x-surface-2); } +/* ── NumberInput (2026-11-21): a whole number with − / + on its sides ──────────── */ +.x-number { + display: flex; align-items: stretch; width: 100%; min-width: 0; min-height: var(--x-control-md); box-sizing: border-box; + border: var(--x-border-width) solid var(--x-line-strong); border-radius: var(--x-radius-control); background: var(--x-surface); overflow: hidden; +} +.x-number--sm { min-height: var(--x-control-sm); } +.x-number:hover:not(.x-number--disabled) { border-color: var(--x-ink-3); } +.x-number--focus { border-color: var(--x-accent); box-shadow: var(--x-focus-ring); } +.x-number--invalid { border-color: var(--x-danger); } +.x-number--invalid.x-number--focus { box-shadow: 0 0 0 3px rgb(var(--x-danger-rgb) / 0.3); } +.x-number--disabled { background: var(--x-surface-2); } +.x-number__btn { + flex-shrink: 0; width: var(--x-control-sm); display: grid; place-items: center; border: 0; background: none; color: var(--x-ink-2); cursor: pointer; +} +.x-number__btn:hover:not(:disabled) { background: var(--x-surface-2); color: var(--x-ink); } +.x-number__btn:disabled { opacity: 0.4; cursor: default; } +.x-number__input { + flex: 1; min-width: 0; width: 100%; border: 0; outline: none; background: transparent; color: var(--x-ink); + font: inherit; font-size: var(--x-text-body); text-align: center; font-variant-numeric: tabular-nums; +} +.x-number__suffix { align-self: center; padding-right: var(--x-space-1); color: var(--x-ink-3); font-size: var(--x-text-label); } + /* ── Slider (2026-11-21): framed like a field, its value beside it ──────────────── */ .x-slider { min-height: var(--x-control-md); display: flex; align-items: center; gap: var(--x-space-3); padding: 0 var(--x-space-3); border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control); background: var(--x-surface); } .x-slider__input { flex: 1; min-width: 0; accent-color: var(--x-accent); } -.x-slider__value { width: 3rem; text-align: right; font-size: var(--x-text-label); color: var(--x-ink-2); font-variant-numeric: tabular-nums; } +.x-slider__value { flex-shrink: 0; text-align: right; font-size: var(--x-text-label); color: var(--x-ink-2); font-variant-numeric: tabular-nums; } /* ── ColourField (2026-11-21): a colour as a field; its panel over the page ──────── */ .x-swatch { diff --git a/packages/ui/src/components/NumberInput.jsx b/packages/ui/src/components/NumberInput.jsx new file mode 100644 index 0000000..5f18470 --- /dev/null +++ b/packages/ui/src/components/NumberInput.jsx @@ -0,0 +1,46 @@ +import { useState } from 'react' +import { cx } from '../internal/cx.js' +import { useLabels } from './labels.js' + +const Icon = ({ d }) => ( + +) + +/** + * A whole number typed or stepped with − / + on its sides (2026-11-21), as tall as an input. + * + * The field may be emptied while typing: onChange(null). The form shows its own error for an empty + * value and keeps it from being saved. A value over `max` is brought down; under `min`, brought up + * when the field is left. Inside a it takes the field's id. + */ +export function NumberInput({ value, onChange, min = 0, max = Infinity, step = 1, suffix, size = 'md', invalid = false, disabled = false, className, id, ...rest }) { + const labels = useLabels() + const [focus, setFocus] = useState(false) + const n = value === '' || value == null ? null : Number(value) + const clamp = v => Math.min(max, Math.max(min, v)) + const stepBy = d => onChange?.(clamp((n ?? min) + d)) + return ( + + + { + const digits = e.target.value.replace(/\D/g, '') + onChange?.(digits === '' ? null : Math.min(max, Number(digits))) + }} + onFocus={() => setFocus(true)} + onBlur={() => { setFocus(false); if (n != null && n < min) onChange?.(min) }} + onKeyDown={e => { + if (e.key === 'ArrowUp') { e.preventDefault(); stepBy(step) } + if (e.key === 'ArrowDown') { e.preventDefault(); stepBy(-step) } + }} + {...rest} /> + {suffix && } + + + ) +} diff --git a/packages/ui/src/components/Slider.jsx b/packages/ui/src/components/Slider.jsx index cc3255b..29d20c4 100644 --- a/packages/ui/src/components/Slider.jsx +++ b/packages/ui/src/components/Slider.jsx @@ -11,7 +11,8 @@ export function Slider({ label, value, min = 0, max = 100, step = 1, onChange, s onChange?.(Number(e.target.value))} className="x-slider__input" aria-label={label} data-testid={testId} /> - {value}{suffix} + {/* as wide as its widest value, no wider: the gap to it is the frame's padding (owner review 6) */} + {value}{suffix} ) diff --git a/packages/ui/src/index.js b/packages/ui/src/index.js index 0125c2e..a7d4dc9 100644 --- a/packages/ui/src/index.js +++ b/packages/ui/src/index.js @@ -27,6 +27,7 @@ export { ColourField, Swatch } from './components/ColourField.jsx' export { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './components/colour.js' export { FieldRow } from './components/FieldRow.jsx' export { Slider } from './components/Slider.jsx' +export { NumberInput } from './components/NumberInput.jsx' export { IconPicker } from './components/IconPicker.jsx' export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx' export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx' diff --git a/tests/e2e/signage.mjs b/tests/e2e/signage.mjs index 757911c..5b2dba2 100644 --- a/tests/e2e/signage.mjs +++ b/tests/e2e/signage.mjs @@ -418,6 +418,12 @@ try { await mgr.mouse.down() await mgr.mouse.move(se.x + 60, se.y + 30, { steps: 5 }) await mgr.mouse.up() + r.check('2026-11-21 (6): a clock placed by hand is exactly as big as what it shows (its outline is the clock)', + await waitFor(async () => { + const box = await mgr.getByTestId('signage-preview').locator('[data-tight]').last().boundingBox() + const sel = await mgr.getByTestId('signage-canvas-selected').boundingBox() + return box && sel && Math.abs(box.width - sel.width) < 3 && Math.abs(box.height - sel.height) < 3 + }, 4000, 200) === true) r.check('2026-11-21: a widget dragged on the preview reads "Custom" in its card', (await mgr.locator('[data-testid="signage-widget"][data-selected="true"]').getByTestId('signage-widget-position').textContent()).includes('Custom')) await mgr.getByTestId('signage-slide-save').click()