feat(signage): Slides library, widgets placed on the preview, blank slides, slide editor rework
- Slides library (Alembic 0044, /api/signage/library): slides kept with a name and a
description, added to playlists as copies ("Add a slide" → Your slides, "Keep in Slides"),
or shown alone as a screen's default (device config `slide`, played as "slide:<id>",
also as a schedule's fallback). Signage → Slides: gallery + a two-pane editor.
- Widgets moved and sized by hand on the preview (WidgetCanvas: handles, snapping, arrow
keys): position/size "custom" with a box the TV draws the same; alignment per widget.
- Blank slides (background + widgets); menu boards narrower and placed left/centre/right.
- Slide editor reworked: name | show, transition effect | seconds; sections; text look on
one row with ready colours; one card per widget, settings on one row.
- Questions inside the page (@xenia/ui ConfirmDialog/useConfirm), Switch boxed, Segmented
fill; the timeline's drop line; schedule lines run on weekdays or smart days, not both;
the playlist editor stays within 1080p with a long timeline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
"""The signage Slides library and what came with it (owner 2026-11-21): slides kept with a name and a
|
||||
description, added to playlists as copies, shown alone as a screen's default (also behind a
|
||||
schedule); blank slides (a background and widgets); widgets moved and sized by hand (their own
|
||||
box); a menu board narrower than the screen, placed left / centre / right."""
|
||||
from tests.test_live import err, owner_h, pair # noqa: F401 (fixtures)
|
||||
from tests.test_media import jpeg, media_dir, up # noqa: F401 (fixture + helpers)
|
||||
from tests.test_signage import playlist, screens, sent, slide # noqa: F401 (fixtures + helpers)
|
||||
|
||||
|
||||
def keep(client, h, **body):
|
||||
r = client.post("/api/signage/library", headers=h, json={"name": "Logo", "kind": "blank", **body})
|
||||
assert r.status_code == 201, r.text
|
||||
return r.json()
|
||||
|
||||
|
||||
def test_the_library_keeps_slides(client, owner_h):
|
||||
s = keep(client, owner_h, description=" Our logo, big ", orientation="portrait", duration_s=15,
|
||||
content={"background": {"kind": "colour", "colour": "#102030"}, "widgets": [{"kind": "name", "position": "top-center"}]})
|
||||
assert s["kind"] == "blank" and s["orientation"] == "portrait" and s["description"] == "Our logo, big" and s["duration_s"] == 15
|
||||
assert s["content"]["widgets"][0]["size"] == "medium" and s["screens"] == []
|
||||
r = client.put(f"/api/signage/library/{s['id']}", headers=owner_h, json={"name": "Logo 2", "description": "", "days": [5, 6]})
|
||||
assert r.json()["name"] == "Logo 2" and r.json()["description"] is None and r.json()["days"] == [5, 6]
|
||||
assert err(client.put(f"/api/signage/library/{s['id']}", headers=owner_h, json={"kind": "text"})) == "signage.content_invalid"
|
||||
assert err(client.put(f"/api/signage/library/{s['id']}", headers=owner_h, json={"name": " "})) == "signage.content_invalid"
|
||||
assert err(client.post("/api/signage/library", headers=owner_h, json={"name": "x"})) == "signage.content_invalid" # no kind
|
||||
copy = client.post(f"/api/signage/library/{s['id']}/duplicate", headers=owner_h).json()
|
||||
assert copy["name"] == "Logo 2 (2)" and copy["content"] == r.json()["content"]
|
||||
listed = client.get("/api/signage/library", headers=owner_h).json()
|
||||
assert [x["name"] for x in listed["slides"]] == ["Logo 2", "Logo 2 (2)"] and listed["media"] == {}
|
||||
assert client.delete(f"/api/signage/library/{copy['id']}", headers=owner_h).status_code == 204
|
||||
assert err(client.get(f"/api/signage/library/{copy['id']}", headers=owner_h)) == "signage.slide_unknown"
|
||||
|
||||
|
||||
def test_a_library_slide_protects_its_pictures(client, owner_h, media_dir):
|
||||
pic = up(client, owner_h, jpeg(800, 800)).json()
|
||||
keep(client, owner_h, kind="image", name="Promo", content={"media_id": pic["id"]})
|
||||
r = client.delete(f"/api/media/{pic['id']}", headers=owner_h)
|
||||
assert r.status_code == 409, r.text
|
||||
|
||||
|
||||
def test_a_screen_shows_a_library_slide_when_nothing_else_plays(client, owner_h, screens, sent):
|
||||
s = keep(client, owner_h, content={"widgets": [{"kind": "qr", "position": "bottom-right"}]})
|
||||
tv = screens[1]
|
||||
r = client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"slide_id": s["id"]})
|
||||
assert r.status_code == 200, r.text
|
||||
assert r.json()["slide_id"] == s["id"] and r.json()["playlist_id"] is None
|
||||
assert r.json()["now"] == {"id": f"slide:{s['id']}", "name": "Logo", "scheduled": False, "slide": True}
|
||||
got = client.get("/api/signage/screen", headers=tv["h"]).json()
|
||||
pl = got["playlist"]
|
||||
assert pl["id"] == f"slide:{s['id']}" and [x["id"] for x in pl["slides"]] == [s["id"]]
|
||||
assert pl["slides"][0]["content"]["widgets"][0]["link"] # the QR's address, as in a playlist
|
||||
# a change to it reaches that screen only
|
||||
sent.clear()
|
||||
client.put(f"/api/signage/library/{s['id']}", headers=owner_h, json={"duration_s": 20})
|
||||
assert sent == [("signage.changed", [tv["id"]])]
|
||||
# behind a schedule: the slide is the fallback, under its own key
|
||||
p = playlist(client, owner_h, "Lunch")
|
||||
slide(client, owner_h, p["id"], "text", content={"title": "Lunch"})
|
||||
client.put("/api/signage/schedules", headers=owner_h, json={"lines": [
|
||||
{"playlist_id": p["id"], "screen_ids": [tv["id"]], "date_from": "2000-01-01", "date_to": "2000-01-02"}]})
|
||||
got = client.get("/api/signage/screen", headers=tv["h"]).json()
|
||||
assert got["schedule"]["fallback_playlist_id"] == f"slide:{s['id']}" and f"slide:{s['id']}" in got["playlists"]
|
||||
assert got["playlist"]["id"] == f"slide:{s['id']}"
|
||||
# a playlist as the default takes its place (one or the other)
|
||||
r = client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"playlist_id": p["id"]})
|
||||
assert r.json()["playlist_id"] == p["id"] and r.json()["slide_id"] is None
|
||||
r = client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"slide_id": s["id"]})
|
||||
assert r.json()["playlist_id"] is None and r.json()["slide_id"] == s["id"]
|
||||
# deleting the slide: the screen shows nothing and is told
|
||||
sent.clear()
|
||||
client.delete(f"/api/signage/library/{s['id']}", headers=owner_h)
|
||||
assert ("signage.changed", [tv["id"]]) in sent
|
||||
assert client.get("/api/signage/screens", headers=owner_h).json()[0]["slide_id"] is None
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"title": "x"}})
|
||||
assert err(r) == "signage.content_invalid" # a blank slide has no title
|
||||
|
||||
|
||||
def test_a_menu_board_narrower_than_the_screen(client, owner_h):
|
||||
p = playlist(client, owner_h)
|
||||
s = slide(client, owner_h, p["id"], "menu", content={"select": "all", "board_width": 60, "board_align": "center"})
|
||||
assert s["content"]["board_width"] == 60 and s["content"]["board_align"] == "center"
|
||||
assert slide(client, owner_h, p["id"], "menu")["content"]["board_width"] == 100
|
||||
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"board_width": 20}})
|
||||
assert err(r) == "signage.content_invalid"
|
||||
Reference in New Issue
Block a user