feat(signage): reviews typed in by hand and their widget; Add a widget at the top of the widgets, the list in layers (new widgets on top)
Reviews (name, stars, text, date, where) under Signage -> Message & settings, shown one at a time by the reviews widget (a minimum of stars, seconds each); not pulled from Google (owner's choice). The widgets section: one "Add a widget" menu at its top instead of a button per kind; the cards are layers, the top one drawn over the others, so a new widget goes on top; the arrows bring forward / send backward. Plan 6R.19, F-113. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -17,6 +17,7 @@ MODULE = Module(
|
|||||||
),
|
),
|
||||||
settings=(
|
settings=(
|
||||||
SettingDef('signage.message', '', 'The message of the day on every signage screen with a message widget (Signage > Message of the day).'),
|
SettingDef('signage.message', '', 'The message of the day on every signage screen with a message widget (Signage > Message of the day).'),
|
||||||
|
SettingDef('signage.reviews', '[]', 'The reviews the venue typed in for the reviews widget (6R.19; JSON list; Signage > Message & settings).', type='json'),
|
||||||
SettingDef('signage.weather.place', '', 'The place whose weather the screens show (picked from a town search in Signage).'),
|
SettingDef('signage.weather.place', '', 'The place whose weather the screens show (picked from a town search in Signage).'),
|
||||||
SettingDef('signage.weather.latitude', '', 'Latitude of the weather place.'),
|
SettingDef('signage.weather.latitude', '', 'Latitude of the weather place.'),
|
||||||
SettingDef('signage.weather.longitude', '', 'Longitude of the weather place.'),
|
SettingDef('signage.weather.longitude', '', 'Longitude of the weather place.'),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Manager side (signage.manage):
|
|||||||
PUT /api/signage/library/{id} change it (a screen showing it is told)
|
PUT /api/signage/library/{id} change it (a screen showing it is told)
|
||||||
DELETE /api/signage/library/{id} screens that had it as their default show nothing
|
DELETE /api/signage/library/{id} screens that had it as their default show nothing
|
||||||
POST /api/signage/library/{id}/duplicate a copy
|
POST /api/signage/library/{id}/duplicate a copy
|
||||||
|
GET /api/signage/reviews the venue's reviews (6R.19); PUT: all of them at once
|
||||||
GET /api/signage/screens the paired screens: playlist or slide, orientation, rotation,
|
GET /api/signage/screens the paired screens: playlist or slide, orientation, rotation,
|
||||||
picture area (insets), fit, the window size it reported
|
picture area (insets), fit, the window size it reported
|
||||||
PUT /api/signage/screens/{id} {playlist_id | slide_id, orientation, rotation, area_*, fit}
|
PUT /api/signage/screens/{id} {playlist_id | slide_id, orientation, rotation, area_*, fit}
|
||||||
@@ -52,6 +53,7 @@ from services.ws_bus import broadcast_sync
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
KEY = "signage.manage"
|
KEY = "signage.manage"
|
||||||
MESSAGE = "signage.message"
|
MESSAGE = "signage.message"
|
||||||
|
REVIEWS = "signage.reviews" # the venue's reviews, typed in by hand (6R.19)
|
||||||
MAX_WIDGETS = "signage.max_widgets" # widgets a slide may hold (owner review 6: Performance; 10 recommended)
|
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
|
MAX_WIDGETS_CAP = 50 # never more, whatever the setting
|
||||||
AREA_MAX = 4000 # px a screen's picture area may cut off one edge (6R.13)
|
AREA_MAX = 4000 # px a screen's picture area may cut off one edge (6R.13)
|
||||||
@@ -83,7 +85,8 @@ class Background(_Strict):
|
|||||||
|
|
||||||
|
|
||||||
WidgetKind = Literal["logo", "name", "date", "clock", "message", "qr", "weather", "text", "menu", "stack",
|
WidgetKind = Literal["logo", "name", "date", "clock", "message", "qr", "weather", "text", "menu", "stack",
|
||||||
"shape", "ticker", "countdown", "hours", "wifi", "contact"] # 6R.15
|
"shape", "ticker", "countdown", "hours", "wifi", "contact", # 6R.15
|
||||||
|
"reviews"] # 6R.19
|
||||||
WHEN = r"^(\d{4}-\d{2}-\d{2}T)?([01]\d|2[0-3]):[0-5]\d$" # a countdown's moment: "HH:MM" (every day) or "YYYY-MM-DDTHH:MM"
|
WHEN = r"^(\d{4}-\d{2}-\d{2}T)?([01]\d|2[0-3]):[0-5]\d$" # a countdown's moment: "HH:MM" (every day) or "YYYY-MM-DDTHH:MM"
|
||||||
ContactKey = Literal["phone", "phone2", "email", "address", "website", "google", "facebook", "instagram", "tiktok", "tripadvisor", "whatsapp", "viber"]
|
ContactKey = Literal["phone", "phone2", "email", "address", "website", "google", "facebook", "instagram", "tiktok", "tripadvisor", "whatsapp", "viber"]
|
||||||
Position = Literal["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right", "top-bar", "bottom-bar", "custom"]
|
Position = Literal["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right", "top-bar", "bottom-bar", "custom"]
|
||||||
@@ -308,6 +311,11 @@ class Widget(_Strict):
|
|||||||
wifi_password: bool = True
|
wifi_password: bool = True
|
||||||
# contact details (from the identity): which, in this order
|
# contact details (from the identity): which, in this order
|
||||||
contact_fields: List[ContactKey] = Field(default_factory=lambda: ["phone", "website", "instagram"], max_length=12)
|
contact_fields: List[ContactKey] = Field(default_factory=lambda: ["phone", "website", "instagram"], max_length=12)
|
||||||
|
# reviews (6R.19): the venue's, typed in under Message & settings; one at a time, turning
|
||||||
|
reviews_seconds: int = Field(default=8, ge=3, le=120)
|
||||||
|
reviews_min: int = Field(default=4, ge=1, le=5) # only reviews with at least these stars
|
||||||
|
reviews_stars: bool = True
|
||||||
|
reviews_name: bool = True
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def _place(self):
|
def _place(self):
|
||||||
@@ -1434,6 +1442,46 @@ def put_performance(body: PerformanceBody, db: Session = Depends(get_db), user=D
|
|||||||
return {"max_widgets": body.max_widgets, "recommended": 10, "cap": MAX_WIDGETS_CAP}
|
return {"max_widgets": body.max_widgets, "recommended": 10, "cap": MAX_WIDGETS_CAP}
|
||||||
|
|
||||||
|
|
||||||
|
class Review(_Strict):
|
||||||
|
"""A review the venue typed in (6R.19): who, how many stars, what they wrote, when, where it was posted."""
|
||||||
|
name: str = Field(min_length=1, max_length=60)
|
||||||
|
stars: int = Field(ge=1, le=5)
|
||||||
|
text: str = Field(min_length=1, max_length=400)
|
||||||
|
date: Optional[str] = Field(default=None, pattern=DATE)
|
||||||
|
source: Optional[str] = Field(default=None, max_length=40) # "Google", "Tripadvisor"…
|
||||||
|
|
||||||
|
@field_validator("name", "text", "source")
|
||||||
|
@classmethod
|
||||||
|
def _trim(cls, v):
|
||||||
|
v = " ".join(str(v).split()) if v is not None else None
|
||||||
|
return v or None
|
||||||
|
|
||||||
|
|
||||||
|
class ReviewsBody(BaseModel):
|
||||||
|
reviews: List[Review] = Field(default_factory=list, max_length=100)
|
||||||
|
|
||||||
|
|
||||||
|
def reviews(db) -> list:
|
||||||
|
"""The venue's reviews as stored (a broken value reads as none)."""
|
||||||
|
try:
|
||||||
|
return ReviewsBody(reviews=json.loads(_setting(db, REVIEWS) or "[]")).model_dump()["reviews"]
|
||||||
|
except Exception:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/reviews")
|
||||||
|
def get_reviews(db: Session = Depends(get_db), user=Depends(require(KEY))):
|
||||||
|
return {"reviews": reviews(db)}
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/reviews")
|
||||||
|
def put_reviews(body: ReviewsBody, db: Session = Depends(get_db), user=Depends(require(KEY))):
|
||||||
|
_save_setting(db, REVIEWS, json.dumps(body.model_dump()["reviews"], ensure_ascii=False))
|
||||||
|
db.commit()
|
||||||
|
tell_all_screens(db)
|
||||||
|
return {"reviews": reviews(db)}
|
||||||
|
|
||||||
|
|
||||||
class BadgesBody(BaseModel):
|
class BadgesBody(BaseModel):
|
||||||
badges: list = Field(default_factory=list)
|
badges: list = Field(default_factory=list)
|
||||||
|
|
||||||
@@ -1531,7 +1579,7 @@ def _venue(db) -> dict:
|
|||||||
ident.pop("name", None)
|
ident.pop("name", None)
|
||||||
return {"name": _setting(db, "venue.name") or None, "message": _setting(db, MESSAGE) or None,
|
return {"name": _setting(db, "venue.name") or None, "message": _setting(db, MESSAGE) or None,
|
||||||
"weather": weather.current(db), "badges": signage_badges.load(db), "identity": ident, "timezone": venue_tz().key,
|
"weather": weather.current(db), "badges": signage_badges.load(db), "identity": ident, "timezone": venue_tz().key,
|
||||||
"hours": hours_out(db)}
|
"hours": hours_out(db), "reviews": reviews(db)}
|
||||||
|
|
||||||
|
|
||||||
class SlidePreviewBody(BaseModel):
|
class SlidePreviewBody(BaseModel):
|
||||||
|
|||||||
@@ -84,3 +84,18 @@ def test_new_widgets_are_typed(client, owner_h):
|
|||||||
bad = client.post(f"/api/signage/playlists/{p['id']}/slides", headers=owner_h,
|
bad = client.post(f"/api/signage/playlists/{p['id']}/slides", headers=owner_h,
|
||||||
json={"kind": "blank", "content": {"widgets": [{"kind": "contact", "contact_fields": ["fax"]}]}})
|
json={"kind": "blank", "content": {"widgets": [{"kind": "contact", "contact_fields": ["fax"]}]}})
|
||||||
assert err(bad) == "signage.content_invalid"
|
assert err(bad) == "signage.content_invalid"
|
||||||
|
|
||||||
|
|
||||||
|
def test_reviews_typed_in_by_hand(client, owner_h, screens, sent):
|
||||||
|
body = {"reviews": [{"name": " Maria K. ", "stars": 5, "text": "Best octopus on the island", "date": "2026-11-01", "source": "Google"},
|
||||||
|
{"name": "John", "stars": 3, "text": "OK"}]}
|
||||||
|
sent.clear()
|
||||||
|
r = client.put("/api/signage/reviews", headers=owner_h, json=body)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
got = r.json()["reviews"]
|
||||||
|
assert got[0]["name"] == "Maria K." and got[0]["text"] == "Best octopus on the island" and got[1]["date"] is None
|
||||||
|
assert ("signage.changed", sorted([screens[1]["id"], screens[2]["id"]])) in sent
|
||||||
|
assert client.get("/api/signage/screen", headers=screens[1]["h"]).json()["venue"]["reviews"][0]["stars"] == 5
|
||||||
|
assert client.get("/api/signage/reviews", headers=owner_h).json()["reviews"][1]["name"] == "John"
|
||||||
|
assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 6, "text": "y"}]}).status_code == 422
|
||||||
|
assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 5, "text": ""}]}).status_code == 422
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
// The settings of the widgets added in 6R.15 (owner 2026-11-22): a shape, a scrolling text, a
|
// The settings of the widgets added in 6R.15 (owner 2026-11-22): a shape, a scrolling text, a
|
||||||
// countdown, the opening hours, the guests' Wi-Fi and the contact details. The last three read the
|
// countdown, the opening hours, the guests' Wi-Fi and the contact details; the reviews (6R.19). The last three read the
|
||||||
// venue (Settings → Identity, the Schedule page's opening hours): when that is missing the card says
|
// venue (Settings → Identity, the Schedule page's opening hours): when that is missing the card says
|
||||||
// so with a link to where it is set. Used by WidgetsEditor (its row and the part under it).
|
// so with a link to where it is set. Used by WidgetsEditor (its row and the part under it).
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { ColourField, Dropdown, Field, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
|
import { ColourField, Dropdown, Field, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
|
||||||
import { useHours, useIdentity } from '../../shell/useIdentity'
|
import { useHours, useIdentity } from '../../shell/useIdentity'
|
||||||
|
import * as api from './signageApi'
|
||||||
import { CONTACT_KEYS, WIDGET_COLOURS } from './signageLogic'
|
import { CONTACT_KEYS, WIDGET_COLOURS } from './signageLogic'
|
||||||
|
|
||||||
const SHAPES = ['rectangle', 'circle', 'triangle', 'polygon', 'star', 'custom']
|
const SHAPES = ['rectangle', 'circle', 'triangle', 'polygon', 'star', 'custom']
|
||||||
@@ -77,6 +79,17 @@ export function MoreInlineFields({ w, set }) {
|
|||||||
</Field>
|
</Field>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (w.kind === 'reviews') {
|
||||||
|
return (<>
|
||||||
|
<Field label={t(`${k}.reviews.min`)}>
|
||||||
|
<Segmented fill value={w.reviews_min || 4} onChange={reviews_min => set({ reviews_min })} data-testid="signage-widget-reviews-min"
|
||||||
|
options={[1, 2, 3, 4, 5].map(n => ({ value: n, label: `${n}+` }))} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t(`${k}.reviews.seconds`)}>
|
||||||
|
<NumberInput value={w.reviews_seconds ?? 8} min={3} max={120} suffix="s" onChange={v => set({ reviews_seconds: v ?? 3 })} />
|
||||||
|
</Field>
|
||||||
|
</>)
|
||||||
|
}
|
||||||
if (w.kind === 'contact') {
|
if (w.kind === 'contact') {
|
||||||
return (
|
return (
|
||||||
<Field label={t(`${k}.contact.shows`)} className="col-span-2">
|
<Field label={t(`${k}.contact.shows`)} className="col-span-2">
|
||||||
@@ -159,6 +172,17 @@ export function MoreBelowFields({ w, set }) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (w.kind === 'reviews') {
|
||||||
|
return (
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<div className="flex gap-2 flex-wrap">
|
||||||
|
<Switch boxed className="h-control" checked={w.reviews_stars !== false} onChange={on => set({ reviews_stars: on })} label={t(`${k}.reviews.stars`)} />
|
||||||
|
<Switch boxed className="h-control" checked={w.reviews_name !== false} onChange={on => set({ reviews_name: on })} label={t(`${k}.reviews.name`)} />
|
||||||
|
</div>
|
||||||
|
<ReviewsNote />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
if (w.kind === 'wifi' || w.kind === 'contact') {
|
if (w.kind === 'wifi' || w.kind === 'contact') {
|
||||||
const missing = w.kind === 'wifi' ? identity && !identity.wifi?.ssid : identity && !(w.contact_fields || ['phone', 'website', 'instagram']).some(x => identity.contact?.[x])
|
const missing = w.kind === 'wifi' ? identity && !identity.wifi?.ssid : identity && !(w.contact_fields || ['phone', 'website', 'instagram']).some(x => identity.contact?.[x])
|
||||||
return missing
|
return missing
|
||||||
@@ -171,3 +195,14 @@ export function MoreBelowFields({ w, set }) {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Where the reviews come from, or a warning (with the way there) while there are none. */
|
||||||
|
function ReviewsNote() {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [count, setCount] = useState(null)
|
||||||
|
useEffect(() => { api.getReviews().then(r => setCount(r.reviews.length)).catch(() => {}) }, [])
|
||||||
|
const link = <Link to="/management/signage?tab=settings" className="text-accent-ink font-medium underline">{t('signage.widgets.reviews.where')}</Link>
|
||||||
|
return count === 0
|
||||||
|
? <Notice tone="warning" title={t('signage.widgets.reviews.missing')} data-testid="signage-widget-reviews-missing">{link}</Notice>
|
||||||
|
: <p className="text-caption text-ink-3 -mt-2">{t('signage.widgets.reviews.hint')} {link}</p>
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
// The venue's reviews (6R.19, owner 2026-11-22), under Signage → Message & settings: typed in by hand
|
||||||
|
// (who, stars, what they wrote, when, where it was posted) and shown one at a time by the reviews
|
||||||
|
// widget. Not pulled from Google (the owner's choice: no API key, no billing). Saved all at once.
|
||||||
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { ArrowDown, ArrowUp, Plus, Star, Trash2 } from 'lucide-react'
|
||||||
|
import { errorMessage } from '@xenia/api'
|
||||||
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, Field, FieldRow, IconButton, Input, Segmented, Spinner, Textarea } from '@xenia/ui'
|
||||||
|
import * as api from './signageApi'
|
||||||
|
import { moved } from './signageLogic'
|
||||||
|
|
||||||
|
const clean = list => list.map(r => ({ name: r.name.trim(), stars: r.stars, text: r.text.trim(), date: r.date || null, source: (r.source || '').trim() || null }))
|
||||||
|
|
||||||
|
export default function ReviewsSettings() {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [saved, setSaved] = useState(null)
|
||||||
|
const [list, setList] = useState(null)
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
useEffect(() => {
|
||||||
|
api.getReviews().then(r => { setSaved(r.reviews); setList(r.reviews) }).catch(err => toast.error(errorMessage(err, t)))
|
||||||
|
}, [t])
|
||||||
|
const dirty = useMemo(() => JSON.stringify(list) !== JSON.stringify(saved), [list, saved])
|
||||||
|
if (!list) return <section className="rounded-card border border-line bg-surface p-4 flex justify-center"><Spinner /></section>
|
||||||
|
const set = (i, patch) => setList(l => l.map((r, j) => (j === i ? { ...r, ...patch } : r)))
|
||||||
|
const bad = list.some(r => !r.name?.trim() || !r.text?.trim())
|
||||||
|
const save = async () => {
|
||||||
|
setBusy(true)
|
||||||
|
try { const r = await api.putReviews(clean(list)); setSaved(r.reviews); setList(r.reviews); toast.success(t('settings.saved')) }
|
||||||
|
catch (err) { toast.error(errorMessage(err, t)) }
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<section className="rounded-card border border-line bg-surface p-4 grid gap-3" data-testid="signage-reviews">
|
||||||
|
<div className="flex flex-wrap items-start gap-3">
|
||||||
|
<div className="grid gap-1 flex-1 min-w-[16rem]">
|
||||||
|
<h2 className="text-body font-semibold text-ink">{t('signage.reviews.title')}</h2>
|
||||||
|
<p className="text-label text-ink-2">{t('signage.reviews.hint')}</p>
|
||||||
|
</div>
|
||||||
|
<Button variant="secondary" disabled={!dirty || busy} onClick={() => setList(saved)}>{t('signage.undo')}</Button>
|
||||||
|
<Button loading={busy} disabled={!dirty || bad} onClick={save} data-testid="signage-reviews-save">{t('fees.save')}</Button>
|
||||||
|
</div>
|
||||||
|
{list.length === 0 && <p className="text-label text-ink-3">{t('signage.reviews.none')}</p>}
|
||||||
|
<div className="grid gap-2">
|
||||||
|
{list.map((r, i) => (
|
||||||
|
<div key={i} className="grid gap-2 rounded-control border border-line bg-surface-2 p-3" data-testid="signage-review-row">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Segmented value={r.stars} onChange={stars => set(i, { stars })} aria-label={t('signage.reviews.stars')} data-testid="signage-review-stars"
|
||||||
|
options={[1, 2, 3, 4, 5].map(n => ({ value: n, label: String(n), icon: <Star size={14} aria-hidden="true" /> }))} />
|
||||||
|
<span className="flex-1" />
|
||||||
|
<IconButton size="sm" label={t('display.earlier')} disabled={i === 0} onClick={() => setList(l => moved(l, i, i - 1))}><ArrowUp size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" label={t('display.later')} disabled={i === list.length - 1} onClick={() => setList(l => moved(l, i, i + 1))}><ArrowDown size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" tone="danger" label={t('fees.delete')} onClick={() => setList(l => l.filter((_, j) => j !== i))}><Trash2 size={14} /></IconButton>
|
||||||
|
</div>
|
||||||
|
<Field label={t('signage.reviews.text')} error={!r.text?.trim() ? ' ' : undefined}>
|
||||||
|
<Textarea rows={2} value={r.text} maxLength={400} onChange={e => set(i, { text: e.target.value })} data-testid="signage-review-text" />
|
||||||
|
</Field>
|
||||||
|
<FieldRow className="-mx-3 -mb-3" min="11rem">
|
||||||
|
<Field label={t('signage.reviews.name')} error={!r.name?.trim() ? ' ' : undefined}>
|
||||||
|
<Input value={r.name} maxLength={60} onChange={e => set(i, { name: e.target.value })} data-testid="signage-review-name" />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.reviews.source')}>
|
||||||
|
<Input value={r.source || ''} maxLength={40} placeholder="Google" onChange={e => set(i, { source: e.target.value })} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.reviews.date')}>
|
||||||
|
<Input type="date" value={r.date || ''} onChange={e => set(i, { date: e.target.value || null })} />
|
||||||
|
</Field>
|
||||||
|
</FieldRow>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{list.length < 100 && (
|
||||||
|
<div><Button variant="secondary" icon={<Plus size={14} />} onClick={() => setList(l => [...l, { name: '', stars: 5, text: '', date: null, source: null }])} data-testid="signage-review-add">
|
||||||
|
{t('signage.reviews.add')}
|
||||||
|
</Button></div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import { errorMessage } from '@xenia/api'
|
|||||||
import { useFormat, useLanguage, useTranslation } from '@xenia/i18n'
|
import { useFormat, useLanguage, useTranslation } from '@xenia/i18n'
|
||||||
import { Button, Dropdown, Field, Input, Spinner } from '@xenia/ui'
|
import { Button, Dropdown, Field, Input, Spinner } from '@xenia/ui'
|
||||||
import BadgesSettings from './BadgesSettings'
|
import BadgesSettings from './BadgesSettings'
|
||||||
|
import ReviewsSettings from './ReviewsSettings'
|
||||||
import MessageOfTheDay from './MessageOfTheDay'
|
import MessageOfTheDay from './MessageOfTheDay'
|
||||||
import PerformanceSettings from './PerformanceSettings'
|
import PerformanceSettings from './PerformanceSettings'
|
||||||
import * as api from './signageApi'
|
import * as api from './signageApi'
|
||||||
@@ -88,6 +89,7 @@ export default function SignageSettingsTab() {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<BadgesSettings />
|
<BadgesSettings />
|
||||||
|
<ReviewsSettings />
|
||||||
<PerformanceSettings />
|
<PerformanceSettings />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,12 +20,15 @@
|
|||||||
// ("2", "2.1.0": see WidgetCanvas).
|
// ("2", "2.1.0": see WidgetCanvas).
|
||||||
// 6R.15 (owner 2026-11-22): a shape, a scrolling text, a countdown, the opening hours, Wi-Fi and contact
|
// 6R.15 (owner 2026-11-22): a shape, a scrolling text, a countdown, the opening hours, Wi-Fi and contact
|
||||||
// details (MoreWidgetFields).
|
// details (MoreWidgetFields).
|
||||||
|
// Owner 2026-11-22: "Add a widget" at the top of the section (a menu of every kind), and the list is
|
||||||
|
// in layers: the card at the top is the widget drawn over the others, so a new widget goes on top
|
||||||
|
// (last in the slide's list, first here); the arrows bring a widget forward / send it backward.
|
||||||
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
|
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
|
||||||
import { Fragment, useEffect, useRef, useState } from 'react'
|
import { Fragment, useEffect, useRef, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Bold, Italic, Palette, RotateCcw, Underline, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Bold, Italic, Palette, RotateCcw, Underline, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
||||||
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
|
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
|
||||||
CalendarClock, Contact, MoveHorizontal, Shapes, Timer, Wifi,
|
CalendarClock, Contact, MessageSquareQuote, MoveHorizontal, Shapes, Timer, Wifi,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
|
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
@@ -41,7 +44,8 @@ import {
|
|||||||
} from './signageLogic'
|
} from './signageLogic'
|
||||||
|
|
||||||
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
|
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
|
||||||
shape: Shapes, ticker: MoveHorizontal, countdown: Timer, hours: CalendarClock, wifi: Wifi, contact: Contact }
|
shape: Shapes, ticker: MoveHorizontal, countdown: Timer, hours: CalendarClock, wifi: Wifi, contact: Contact, reviews: MessageSquareQuote }
|
||||||
|
const MORE_KINDS = ['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews'] // MoreWidgetFields
|
||||||
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
|
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
|
||||||
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
|
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
|
||||||
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
|
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
|
||||||
@@ -71,11 +75,12 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
|
|||||||
const top = selected != null && !String(selected).includes('.') ? Number(selected) : null
|
const top = selected != null && !String(selected).includes('.') ? Number(selected) : null
|
||||||
onSelect?.(top == null ? null : String(pickedAfterMove(top, from, to)))
|
onSelect?.(top == null ? null : String(pickedAfterMove(top, from, to)))
|
||||||
}
|
}
|
||||||
|
// the cards are shown top layer first: above a card is after it in the slide's list
|
||||||
const over = (e, i) => {
|
const over = (e, i) => {
|
||||||
if (!drag) return
|
if (!drag) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const r = e.currentTarget.getBoundingClientRect()
|
const r = e.currentTarget.getBoundingClientRect()
|
||||||
const at = e.clientY < r.top + r.height / 2 ? i : i + 1
|
const at = e.clientY < r.top + r.height / 2 ? i + 1 : i
|
||||||
if (at !== drag.at) setDrag(d => ({ ...d, at }))
|
if (at !== drag.at) setDrag(d => ({ ...d, at }))
|
||||||
}
|
}
|
||||||
const drop = () => {
|
const drop = () => {
|
||||||
@@ -85,16 +90,20 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
|
|||||||
const line = i => drag && drag.at === i && drag.at !== drag.from && drag.at !== drag.from + 1 && (
|
const line = i => drag && drag.at === i && drag.at !== drag.from && drag.at !== drag.from + 1 && (
|
||||||
<div className="h-0.5 -my-1.5 rounded-full bg-accent" data-testid="signage-widget-drop-line" aria-hidden="true" />
|
<div className="h-0.5 -my-1.5 rounded-full bg-accent" data-testid="signage-widget-drop-line" aria-hidden="true" />
|
||||||
)
|
)
|
||||||
|
const full = widgets.length >= most
|
||||||
return (
|
return (
|
||||||
<Section title={t('signage.widgets.title')} testid="signage-widgets">
|
<Section title={t('signage.widgets.title')} testid="signage-widgets"
|
||||||
|
aside={<AddWidgetMenu kinds={[...WIDGET_KINDS, 'hstack', 'vstack']} onPick={add} disabled={full} label={t('signage.widgets.add')} testid="signage-widget-add" />}>
|
||||||
<p className="text-caption text-ink-3 -mt-1">{t(widgets.length ? 'signage.widgets.dragHint' : 'signage.widgets.none')}</p>
|
<p className="text-caption text-ink-3 -mt-1">{t(widgets.length ? 'signage.widgets.dragHint' : 'signage.widgets.none')}</p>
|
||||||
{widgets.map((w, i) => {
|
{full && <p className="text-caption text-ink-3 -mt-1" data-testid="signage-widgets-full">{t('signage.widgets.full', { count: most })}</p>}
|
||||||
|
{[...widgets.keys()].reverse().map(i => {
|
||||||
|
const w = widgets[i]
|
||||||
const Icon = iconOf(w)
|
const Icon = iconOf(w)
|
||||||
const custom = w.position === 'custom'
|
const custom = w.position === 'custom'
|
||||||
const on = selected != null && (String(selected) === String(i) || String(selected).startsWith(`${i}.`))
|
const on = selected != null && (String(selected) === String(i) || String(selected).startsWith(`${i}.`))
|
||||||
return (
|
return (
|
||||||
<div key={i} className="grid gap-3">
|
<div key={i} className="grid gap-3">
|
||||||
{line(i)}
|
{line(i + 1)}
|
||||||
<div onPointerDown={() => onSelect?.(String(i))} onDragOver={e => over(e, i)} onDrop={drop}
|
<div onPointerDown={() => onSelect?.(String(i))} onDragOver={e => over(e, i)} onDrop={drop}
|
||||||
className={`grid gap-4 rounded-card border p-4 transition-colors duration-fast ${on ? 'border-accent bg-accent-soft/40 ring-1 ring-accent' : 'border-line bg-surface-2'}
|
className={`grid gap-4 rounded-card border p-4 transition-colors duration-fast ${on ? 'border-accent bg-accent-soft/40 ring-1 ring-accent' : 'border-line bg-surface-2'}
|
||||||
${drag?.from === i ? 'opacity-50' : ''}`}
|
${drag?.from === i ? 'opacity-50' : ''}`}
|
||||||
@@ -106,9 +115,9 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
|
|||||||
<Icon size={16} className="text-ink-2 shrink-0" aria-hidden="true" />
|
<Icon size={16} className="text-ink-2 shrink-0" aria-hidden="true" />
|
||||||
<span className="text-body font-semibold text-ink">{kindLabel(t, w)}</span>
|
<span className="text-body font-semibold text-ink">{kindLabel(t, w)}</span>
|
||||||
<span className="flex-1" />
|
<span className="flex-1" />
|
||||||
<IconButton size="sm" label={t('signage.widgets.earlier')} disabled={i === 0} onClick={e => { e.stopPropagation(); move(i, i - 1) }}
|
<IconButton size="sm" label={t('signage.widgets.forward')} disabled={i === widgets.length - 1} onClick={e => { e.stopPropagation(); move(i, i + 1) }}
|
||||||
data-testid="signage-widget-up"><ArrowUp size={16} /></IconButton>
|
data-testid="signage-widget-up"><ArrowUp size={16} /></IconButton>
|
||||||
<IconButton size="sm" label={t('signage.widgets.later')} disabled={i === widgets.length - 1} onClick={e => { e.stopPropagation(); move(i, i + 1) }}
|
<IconButton size="sm" label={t('signage.widgets.backward')} disabled={i === 0} onClick={e => { e.stopPropagation(); move(i, i - 1) }}
|
||||||
data-testid="signage-widget-down"><ArrowDown size={16} /></IconButton>
|
data-testid="signage-widget-down"><ArrowDown size={16} /></IconButton>
|
||||||
<IconButton size="sm" tone="danger" label={t('fees.delete')} data-testid="signage-widget-remove"
|
<IconButton size="sm" tone="danger" label={t('fees.delete')} data-testid="signage-widget-remove"
|
||||||
onClick={e => { e.stopPropagation(); onChange(widgets.filter((_, j) => j !== i)); onSelect?.(null) }}><Trash2 size={16} /></IconButton>
|
onClick={e => { e.stopPropagation(); onChange(widgets.filter((_, j) => j !== i)); onSelect?.(null) }}><Trash2 size={16} /></IconButton>
|
||||||
@@ -135,20 +144,7 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
{line(widgets.length)}
|
{line(0)}
|
||||||
{widgets.length < most && (
|
|
||||||
<div className="flex flex-wrap items-center gap-1.5">
|
|
||||||
{[...WIDGET_KINDS, 'hstack', 'vstack'].map(k => {
|
|
||||||
const Icon = ICON[k]
|
|
||||||
return (
|
|
||||||
<Button key={k} size="sm" variant="secondary" icon={<Plus size={14} />} onClick={() => add(k)} data-testid={`signage-widget-add-${k}`}>
|
|
||||||
<span className="inline-flex items-center gap-1.5"><Icon size={14} aria-hidden="true" />{t(`signage.widgets.kinds.${k}`)}</span>
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{widgets.length >= most && <p className="text-caption text-ink-3" data-testid="signage-widgets-full">{t('signage.widgets.full', { count: most })}</p>}
|
|
||||||
</Section>
|
</Section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -182,7 +178,7 @@ function VerticalField({ w, set }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// which widgets have text (their colour, font, style and size), a QR code's own colours, a plate
|
// which widgets have text (their colour, font, style and size), a QR code's own colours, a plate
|
||||||
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact']
|
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews']
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A widget's own look (owner review 5), folded under "Text and colours": its colour (text and
|
* A widget's own look (owner review 5), folded under "Text and colours": its colour (text and
|
||||||
@@ -254,7 +250,7 @@ function MessageHint() {
|
|||||||
/** The options only some widgets have, on the same row as where / size / alignment. */
|
/** The options only some widgets have, on the same row as where / size / alignment. */
|
||||||
function InlineFields({ w, set }) {
|
function InlineFields({ w, set }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
if (['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact'].includes(w.kind)) return <MoreInline w={w} set={set} />
|
if (MORE_KINDS.includes(w.kind)) return <MoreInline w={w} set={set} />
|
||||||
if (w.kind === 'message') {
|
if (w.kind === 'message') {
|
||||||
return (
|
return (
|
||||||
<Field label={t('signage.widgets.ownText')} className="col-span-2">
|
<Field label={t('signage.widgets.ownText')} className="col-span-2">
|
||||||
@@ -311,7 +307,7 @@ function InlineFields({ w, set }) {
|
|||||||
/** What needs more room, under the row: the picture, hints, the QR's own link, a menu's list, a stack's parts. */
|
/** What needs more room, under the row: the picture, hints, the QR's own link, a menu's list, a stack's parts. */
|
||||||
function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, onSelect }) {
|
function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, onSelect }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
if (['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact'].includes(w.kind)) return <MoreBelow w={w} set={set} />
|
if (MORE_KINDS.includes(w.kind)) return <MoreBelow w={w} set={set} />
|
||||||
if (w.kind === 'logo') {
|
if (w.kind === 'logo') {
|
||||||
return <MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
|
return <MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
|
||||||
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
|
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
|
||||||
@@ -532,23 +528,28 @@ function ShareBar({ column, shares, labels, onChange }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "Add a widget" to a part: every widget (and a slide from the Slides library) in a small panel
|
/** "Add a widget" to a part: every widget (and a slide from the Slides library); widgets add up, a slide takes the part's place. */
|
||||||
* over the page; widgets add up, a slide takes the part's place. */
|
|
||||||
function AddToPart({ kinds, onPick }) {
|
function AddToPart({ kinds, onPick }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
return <AddWidgetMenu kinds={[...kinds, 'slide']} onPick={onPick} label={t('signage.widgets.stack.add')} testid="signage-stack-add" />
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Add a widget": a button that opens every kind in a small panel over the page (the section's, owner 2026-11-22; a part's). */
|
||||||
|
function AddWidgetMenu({ kinds, onPick, label, testid, disabled = false }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const btn = useRef(null)
|
const btn = useRef(null)
|
||||||
const choose = k => { onPick(k); setOpen(false) }
|
const choose = k => { onPick(k); setOpen(false) }
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button ref={btn} size="sm" variant="secondary" icon={<Plus size={14} />} onClick={() => setOpen(o => !o)} aria-expanded={open} aria-haspopup="menu" data-testid="signage-stack-add">
|
<Button ref={btn} size="sm" variant="secondary" icon={<Plus size={14} />} disabled={disabled} onClick={() => setOpen(o => !o)} aria-expanded={open} aria-haspopup="menu" data-testid={testid}>
|
||||||
{t('signage.widgets.stack.add')}
|
{label}
|
||||||
</Button>
|
</Button>
|
||||||
<Popover open={open} anchor={btn} onClose={() => setOpen(false)} role="menu" className="w-[22rem] grid grid-cols-2 gap-1.5 p-2" data-testid="signage-stack-add-menu">
|
<Popover open={open} anchor={btn} onClose={() => setOpen(false)} role="menu" className="w-[22rem] grid grid-cols-2 gap-1.5 p-2" data-testid={`${testid}-menu`}>
|
||||||
{[...kinds, 'slide'].map(k => {
|
{kinds.map(k => {
|
||||||
const Icon = k === 'slide' ? BookImage : ICON[k]
|
const Icon = k === 'slide' ? BookImage : ICON[k]
|
||||||
return (
|
return (
|
||||||
<button key={k} type="button" role="menuitem" onClick={() => choose(k)} data-testid={`signage-stack-add-${k}`}
|
<button key={k} type="button" role="menuitem" onClick={() => choose(k)} data-testid={`${testid}-${k}`}
|
||||||
className={`flex items-center gap-2 px-2.5 py-2 rounded-control text-left text-label text-ink hover:bg-surface-2 ${k === 'slide' ? 'col-span-2' : ''}`}>
|
className={`flex items-center gap-2 px-2.5 py-2 rounded-control text-left text-label text-ink hover:bg-surface-2 ${k === 'slide' ? 'col-span-2' : ''}`}>
|
||||||
<Icon size={15} className="text-ink-2 shrink-0" aria-hidden="true" />
|
<Icon size={15} className="text-ink-2 shrink-0" aria-hidden="true" />
|
||||||
{k === 'slide' ? t('signage.widgets.stack.aSlideInstead') : t(`signage.widgets.kinds.${k}`)}
|
{k === 'slide' ? t('signage.widgets.stack.aSlideInstead') : t(`signage.widgets.kinds.${k}`)}
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ export const refreshWeather = () => client.post('/api/signage/weather/refresh').
|
|||||||
export const getBadges = () => client.get('/api/signage/badges').then(data)
|
export const getBadges = () => client.get('/api/signage/badges').then(data)
|
||||||
export const putBadges = badges => client.put('/api/signage/badges', { badges }).then(data)
|
export const putBadges = badges => client.put('/api/signage/badges', { badges }).then(data)
|
||||||
|
|
||||||
|
// the venue's reviews, typed in by hand (6R.19)
|
||||||
|
export const getReviews = () => client.get('/api/signage/reviews').then(data)
|
||||||
|
export const putReviews = reviews => client.put('/api/signage/reviews', { reviews }).then(data)
|
||||||
|
|
||||||
// limits that keep the TVs smooth (owner review 6): widgets per slide
|
// limits that keep the TVs smooth (owner review 6): widgets per slide
|
||||||
export const getPerformance = () => client.get('/api/signage/performance').then(data)
|
export const getPerformance = () => client.get('/api/signage/performance').then(data)
|
||||||
export const putPerformance = body => client.put('/api/signage/performance', body).then(data)
|
export const putPerformance = body => client.put('/api/signage/performance', body).then(data)
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ export function mediaLookup(map) {
|
|||||||
|
|
||||||
// ── menu boards and widgets (5.6b) ───────────────────────────────────────────
|
// ── menu boards and widgets (5.6b) ───────────────────────────────────────────
|
||||||
|
|
||||||
export const WIDGET_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu', 'shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact']
|
export const WIDGET_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu', 'shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews']
|
||||||
/** What a stack's part can show (2026-11-21): a widget, a stack one level deep, a library slide. */
|
/** What a stack's part can show (2026-11-21): a widget, a stack one level deep, a library slide. */
|
||||||
export const CELL_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu', 'shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact']
|
export const CELL_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu', 'shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews']
|
||||||
|
|
||||||
/** A new widget of a kind ('hstack' / 'vstack': a stack side by side / one over the other), where it
|
/** A new widget of a kind ('hstack' / 'vstack': a stack side by side / one over the other), where it
|
||||||
* usually goes: a menu or a stack in a box of its own (they fill a box). */
|
* usually goes: a menu or a stack in a box of its own (they fill a box). */
|
||||||
@@ -152,6 +152,7 @@ export function newWidget(kind) {
|
|||||||
return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 55, y: 10, w: 40, h: 80 }, board: { select: 'all', columns: 1, sales_point: 'in_store' } }
|
return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 55, y: 10, w: 40, h: 80 }, board: { select: 'all', columns: 1, sales_point: 'in_store' } }
|
||||||
}
|
}
|
||||||
if (kind === 'shape') return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 40, y: 30, w: 20, h: 35 }, shape: 'rectangle', radius: 10 }
|
if (kind === 'shape') return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 40, y: 30, w: 20, h: 35 }, shape: 'rectangle', radius: 10 }
|
||||||
|
if (kind === 'reviews') return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 25, y: 55, w: 50, h: 32 } }
|
||||||
return { kind, position: NEW_PLACE[kind] || 'top-right', size: 'medium', align: 'auto',
|
return { kind, position: NEW_PLACE[kind] || 'top-right', size: 'medium', align: 'auto',
|
||||||
...(kind === 'text' || kind === 'ticker' ? { text: '' } : {}), ...(kind === 'countdown' ? { countdown_to: '17:00' } : {}) }
|
...(kind === 'text' || kind === 'ticker' ? { text: '' } : {}), ...(kind === 'countdown' ? { countdown_to: '17:00' } : {}) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1486,7 +1486,8 @@
|
|||||||
"countdown": "Αντίστροφη μέτρηση",
|
"countdown": "Αντίστροφη μέτρηση",
|
||||||
"hours": "Ωράριο",
|
"hours": "Ωράριο",
|
||||||
"wifi": "Wi-Fi",
|
"wifi": "Wi-Fi",
|
||||||
"contact": "Στοιχεία επικοινωνίας"
|
"contact": "Στοιχεία επικοινωνίας",
|
||||||
|
"reviews": "Κριτικές"
|
||||||
},
|
},
|
||||||
"position": "Πού",
|
"position": "Πού",
|
||||||
"size": "Μέγεθος",
|
"size": "Μέγεθος",
|
||||||
@@ -1512,7 +1513,7 @@
|
|||||||
"seconds": "Με δευτερόλεπτα",
|
"seconds": "Με δευτερόλεπτα",
|
||||||
"weatherDays": "Μέρες",
|
"weatherDays": "Μέρες",
|
||||||
"weatherNeedsInternet": "Ο καιρός χρειάζεται internet: χωρίς αυτό (ή χωρίς πόλη) το στοιχείο κρύβεται.",
|
"weatherNeedsInternet": "Ο καιρός χρειάζεται internet: χωρίς αυτό (ή χωρίς πόλη) το στοιχείο κρύβεται.",
|
||||||
"dragHint": "Συμβουλή: διαλέξτε ένα widget στην προεπισκόπηση ή εδώ και σύρετέ το (ή με τα βελάκια) για να το μετακινήσετε, και τις λαβές του για το μέγεθος· η θέση και το μέγεθος γράφουν τότε «Προσαρμοσμένο». Η σειρά: ένα επόμενο widget σχεδιάζεται πάνω από ένα προηγούμενο.",
|
"dragHint": "Η λίστα είναι σε επίπεδα: το widget στην κορυφή σχεδιάζεται πάνω από τα από κάτω, και ένα νέο widget μπαίνει στην κορυφή. Διαλέξτε ένα widget στην προεπισκόπηση ή εδώ, σύρετέ το (ή με τα βέλη) για να το μετακινήσετε και από τις λαβές για να αλλάξετε το μέγεθος· η θέση και το μέγεθος γράφουν τότε «Προσαρμοσμένο».",
|
||||||
"custom": "Προσαρμοσμένο",
|
"custom": "Προσαρμοσμένο",
|
||||||
"align": "Στοίχιση",
|
"align": "Στοίχιση",
|
||||||
"alignAuto": "Αυτόματη",
|
"alignAuto": "Αυτόματη",
|
||||||
@@ -1662,7 +1663,19 @@
|
|||||||
"missing": "Κανένα από αυτά τα στοιχεία δεν έχει οριστεί ακόμη: το widget μένει κρυφό.",
|
"missing": "Κανένα από αυτά τα στοιχεία δεν έχει οριστεί ακόμη: το widget μένει κρυφό.",
|
||||||
"hint": "Τα στοιχεία έρχονται από την ταυτότητα του καταστήματος· τα κενά δεν εμφανίζονται."
|
"hint": "Τα στοιχεία έρχονται από την ταυτότητα του καταστήματος· τα κενά δεν εμφανίζονται."
|
||||||
},
|
},
|
||||||
"fromIdentity": "Ρυθμίσεις → Ταυτότητα"
|
"fromIdentity": "Ρυθμίσεις → Ταυτότητα",
|
||||||
|
"add": "Προσθήκη widget",
|
||||||
|
"forward": "Μπροστά (σχεδιάζεται πάνω από αυτό που είναι από πάνω του στη λίστα)",
|
||||||
|
"backward": "Πίσω (σχεδιάζεται κάτω από αυτό που είναι από κάτω του στη λίστα)",
|
||||||
|
"reviews": {
|
||||||
|
"min": "Μόνο κριτικές με",
|
||||||
|
"seconds": "Κάθε κριτική για",
|
||||||
|
"stars": "Τα αστέρια",
|
||||||
|
"name": "Ποιος την έγραψε",
|
||||||
|
"missing": "Δεν υπάρχουν κριτικές ακόμη: το widget μένει κρυφό.",
|
||||||
|
"hint": "Οι κριτικές που καταχωρίσατε, μία κάθε φορά.",
|
||||||
|
"where": "Προσθέστε τις στο Ψηφιακή σήμανση → Μήνυμα & ρυθμίσεις"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"playlists": "Λίστες",
|
"playlists": "Λίστες",
|
||||||
@@ -1922,6 +1935,17 @@
|
|||||||
"outside": "Έξω από την εικόνα η τηλεόραση μένει μαύρη.",
|
"outside": "Έξω από την εικόνα η τηλεόραση μένει μαύρη.",
|
||||||
"reset": "Ξανά όλη η οθόνη",
|
"reset": "Ξανά όλη η οθόνη",
|
||||||
"done": "Τέλος"
|
"done": "Τέλος"
|
||||||
|
},
|
||||||
|
"reviews": {
|
||||||
|
"title": "Κριτικές",
|
||||||
|
"hint": "Κριτικές που άφησαν οι πελάτες σας (στο Google, στο Tripadvisor…), καταχωρισμένες εδώ. Το widget κριτικών τις δείχνει μία κάθε φορά, μόνο τις καλύτερες αν θέλετε.",
|
||||||
|
"none": "Δεν υπάρχουν κριτικές ακόμη.",
|
||||||
|
"add": "Προσθήκη κριτικής",
|
||||||
|
"stars": "Αστέρια",
|
||||||
|
"text": "Τι έγραψαν",
|
||||||
|
"name": "Όνομα",
|
||||||
|
"source": "Πού",
|
||||||
|
"date": "Ημερομηνία"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overview": {
|
"overview": {
|
||||||
|
|||||||
@@ -1486,7 +1486,8 @@
|
|||||||
"countdown": "Countdown",
|
"countdown": "Countdown",
|
||||||
"hours": "Opening hours",
|
"hours": "Opening hours",
|
||||||
"wifi": "Wi-Fi",
|
"wifi": "Wi-Fi",
|
||||||
"contact": "Contact details"
|
"contact": "Contact details",
|
||||||
|
"reviews": "Reviews"
|
||||||
},
|
},
|
||||||
"position": "Where",
|
"position": "Where",
|
||||||
"size": "Size",
|
"size": "Size",
|
||||||
@@ -1512,7 +1513,7 @@
|
|||||||
"seconds": "With seconds",
|
"seconds": "With seconds",
|
||||||
"weatherDays": "Days",
|
"weatherDays": "Days",
|
||||||
"weatherNeedsInternet": "The weather needs internet: without it (or without a town set) the widget is hidden.",
|
"weatherNeedsInternet": "The weather needs internet: without it (or without a town set) the widget is hidden.",
|
||||||
"dragHint": "Tip: pick a widget on the preview or here, then drag it (or use the arrow keys) to move it and its handles to size it; where and size then read \"Custom\". The order: a later widget is drawn over an earlier one.",
|
"dragHint": "The list is in layers: the widget at the top is drawn over the ones below it, and a new widget goes on top. Pick a widget on the preview or here, then drag it (or use the arrow keys) to move it and its handles to size it; where and size then read \"Custom\".",
|
||||||
"custom": "Custom",
|
"custom": "Custom",
|
||||||
"align": "Alignment",
|
"align": "Alignment",
|
||||||
"alignAuto": "Auto",
|
"alignAuto": "Auto",
|
||||||
@@ -1662,7 +1663,19 @@
|
|||||||
"missing": "None of these contact details is set yet: the widget stays hidden.",
|
"missing": "None of these contact details is set yet: the widget stays hidden.",
|
||||||
"hint": "The details come from the venue's identity; empty ones don't show."
|
"hint": "The details come from the venue's identity; empty ones don't show."
|
||||||
},
|
},
|
||||||
"fromIdentity": "Settings → Identity"
|
"fromIdentity": "Settings → Identity",
|
||||||
|
"add": "Add a widget",
|
||||||
|
"forward": "Bring forward (drawn over the one above it in this list)",
|
||||||
|
"backward": "Send backward (drawn under the one below it in this list)",
|
||||||
|
"reviews": {
|
||||||
|
"min": "Only reviews with",
|
||||||
|
"seconds": "Each review for",
|
||||||
|
"stars": "The stars",
|
||||||
|
"name": "Who wrote it",
|
||||||
|
"missing": "No reviews yet: the widget stays hidden.",
|
||||||
|
"hint": "The reviews you typed in, one at a time.",
|
||||||
|
"where": "Add them under Signage → Message & settings"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"playlists": "Playlists",
|
"playlists": "Playlists",
|
||||||
@@ -1922,6 +1935,17 @@
|
|||||||
"outside": "Outside the picture the TV stays black.",
|
"outside": "Outside the picture the TV stays black.",
|
||||||
"reset": "Whole screen again",
|
"reset": "Whole screen again",
|
||||||
"done": "Done"
|
"done": "Done"
|
||||||
|
},
|
||||||
|
"reviews": {
|
||||||
|
"title": "Reviews",
|
||||||
|
"hint": "Reviews your guests left (on Google, Tripadvisor…), typed in here. The reviews widget shows them one at a time, the best ones if you choose.",
|
||||||
|
"none": "No reviews yet.",
|
||||||
|
"add": "Add a review",
|
||||||
|
"stars": "Stars",
|
||||||
|
"text": "What they wrote",
|
||||||
|
"name": "Name",
|
||||||
|
"source": "Where",
|
||||||
|
"date": "Date"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overview": {
|
"overview": {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ const plate = (w, pad) => ({
|
|||||||
...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}),
|
...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}),
|
||||||
})
|
})
|
||||||
// a menu, a stack, a shape or a scrolling text in a corner or a bar has no box of its own: it gets one of this size (cqmin)
|
// a menu, a stack, a shape or a scrolling text in a corner or a bar has no box of its own: it gets one of this size (cqmin)
|
||||||
const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7] }
|
const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7], reviews: [56, 24] }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The widgets of a slide: in their corners and bars, or (moved and sized by hand: position
|
* The widgets of a slide: in their corners and bars, or (moved and sized by hand: position
|
||||||
@@ -336,9 +336,52 @@ function widgetBody(w, ctx, fit, path) {
|
|||||||
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text)
|
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text)
|
||||||
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text)
|
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text)
|
||||||
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text)
|
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text)
|
||||||
|
if (w.kind === 'reviews') {
|
||||||
|
const list = (venue?.reviews || []).filter(r => r.stars >= (w.reviews_min || 4))
|
||||||
|
if (!list.length) return null
|
||||||
|
const r = list[pageAt(list.length, w.reviews_seconds || 8, now.getTime())]
|
||||||
|
return boxed(<ReviewBody w={w} r={r} fmt={fmt} n={list.length} />, 'reviews')
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STAR = '#fbbf24'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One of the venue's reviews (6R.19), the next one every few seconds: its stars, what they wrote,
|
||||||
|
* who and where. It fills its place: the text is sized from the place's size and the review's length.
|
||||||
|
*/
|
||||||
|
function ReviewBody({ w, r, fmt, n }) {
|
||||||
|
const box = useRef(null)
|
||||||
|
const [size, setSize] = useState(null)
|
||||||
|
useEffect(() => {
|
||||||
|
const el = box.current
|
||||||
|
if (!el || typeof ResizeObserver === 'undefined') return undefined
|
||||||
|
const ro = new ResizeObserver(() => setSize(s => (s && s.w === el.clientWidth && s.h === el.clientHeight ? s : { w: el.clientWidth, h: el.clientHeight })))
|
||||||
|
ro.observe(el)
|
||||||
|
return () => ro.disconnect()
|
||||||
|
}, [])
|
||||||
|
const ts = (w.text_size || 100) / 100
|
||||||
|
const chars = r.text.length + 30
|
||||||
|
const f = size ? Math.max(6, Math.min(size.h / 4.2, Math.sqrt((0.55 * size.w * size.h) / (chars * 0.55 * 1.45))) * Math.min(1, ts)) : 0
|
||||||
|
const who = [w.reviews_name !== false && r.name, r.source, r.date && fmt.formatDate(`${r.date}T12:00:00Z`, 'date')].filter(Boolean).join(' · ')
|
||||||
|
const font = { ...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}) }
|
||||||
|
return (
|
||||||
|
<div ref={box} style={{ width: '100%', height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: f * 0.35, ...font }}
|
||||||
|
data-testid="signage-w-reviews" data-count={n} data-name={r.name}>
|
||||||
|
{size && <>
|
||||||
|
{w.reviews_stars !== false && (
|
||||||
|
<div style={{ display: 'flex', gap: f * 0.15, justifyContent: 'inherit' }} aria-label={`${r.stars}/5`}>
|
||||||
|
{[1, 2, 3, 4, 5].map(i => <Star key={i} style={{ width: f * 1.1, height: f * 1.1, color: STAR, fill: i <= r.stars ? STAR : 'none', opacity: i <= r.stars ? 1 : 0.4 }} aria-hidden="true" />)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div style={{ fontSize: f, lineHeight: 1.35, fontWeight: w.bold ? 700 : 500, ...(w.underline ? { textDecoration: 'underline' } : {}) }}>“{r.text}”</div>
|
||||||
|
{who && <div style={{ fontSize: f * 0.72, fontWeight: 700, opacity: 0.85 }}>— {who}</div>}
|
||||||
|
</>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** A shape (6R.15) filling its box: a rectangle (rounded corners) or circle as a box, the others as SVG corners; a fill or a gradient, a border. */
|
/** A shape (6R.15) filling its box: a rectangle (rounded corners) or circle as a box, the others as SVG corners; a fill or a gradient, a border. */
|
||||||
function ShapeBody({ w, id }) {
|
function ShapeBody({ w, id }) {
|
||||||
const fill = w.fill || '#f59e0b'
|
const fill = w.fill || '#f59e0b'
|
||||||
|
|||||||
+17
-7
@@ -43,6 +43,9 @@ async function upload(token, bytes, name, type) {
|
|||||||
const res = await fetch(`${backend.url}/api/media`, { method: 'POST', headers: { authorization: `Bearer ${token}` }, body: form })
|
const res = await fetch(`${backend.url}/api/media`, { method: 'POST', headers: { authorization: `Bearer ${token}` }, body: form })
|
||||||
return res.json()
|
return res.json()
|
||||||
}
|
}
|
||||||
|
/** "Add a widget" at the top of the widgets section (owner 2026-11-22), then the kind. */
|
||||||
|
const addWidget = async kind => { await mgrPage.getByTestId('signage-widget-add').click(); await mgrPage.getByTestId(`signage-widget-add-${kind}`).click() }
|
||||||
|
let mgrPage = null
|
||||||
const shown = (page, testId, timeout = 10_000) => page.getByTestId(testId).first().waitFor({ timeout }).then(() => true).catch(() => false)
|
const shown = (page, testId, timeout = 10_000) => page.getByTestId(testId).first().waitFor({ timeout }).then(() => true).catch(() => false)
|
||||||
const kindNow = page => page.getByTestId('signage-slide').getAttribute('data-kind', { timeout: 2000 }).catch(() => null)
|
const kindNow = page => page.getByTestId('signage-slide').getAttribute('data-kind', { timeout: 2000 }).catch(() => null)
|
||||||
|
|
||||||
@@ -205,6 +208,7 @@ try {
|
|||||||
const tallJpg = execFileSync(PYTHON, ['-c', "import io,sys;from PIL import Image;b=io.BytesIO();Image.new('RGB',(1080,1920),(30,140,90)).save(b,'JPEG');sys.stdout.buffer.write(b.getvalue())"])
|
const tallJpg = execFileSync(PYTHON, ['-c', "import io,sys;from PIL import Image;b=io.BytesIO();Image.new('RGB',(1080,1920),(30,140,90)).save(b,'JPEG');sys.stdout.buffer.write(b.getvalue())"])
|
||||||
const tallPhoto = await upload(boss, tallJpg, 'tall poster.jpg', 'image/jpeg')
|
const tallPhoto = await upload(boss, tallJpg, 'tall poster.jpg', 'image/jpeg')
|
||||||
const mgr = await (await browser.newContext({ viewport: { width: 1440, height: 900 } })).newPage()
|
const mgr = await (await browser.newContext({ viewport: { width: 1440, height: 900 } })).newPage()
|
||||||
|
mgrPage = mgr
|
||||||
mgr.on('pageerror', e => errors.push(e.message))
|
mgr.on('pageerror', e => errors.push(e.message))
|
||||||
await mgr.goto(`${MANAGER}/login`)
|
await mgr.goto(`${MANAGER}/login`)
|
||||||
await mgr.getByTestId('login-form').waitFor({ timeout: 60_000 })
|
await mgr.getByTestId('login-form').waitFor({ timeout: 60_000 })
|
||||||
@@ -291,7 +295,7 @@ try {
|
|||||||
const hideRow = mgr.getByTestId('signage-menu-row').nth(1)
|
const hideRow = mgr.getByTestId('signage-menu-row').nth(1)
|
||||||
const hiddenId = Number(await hideRow.getAttribute('data-id'))
|
const hiddenId = Number(await hideRow.getAttribute('data-id'))
|
||||||
await hideRow.getByTestId('signage-item-hide').click()
|
await hideRow.getByTestId('signage-item-hide').click()
|
||||||
await mgr.getByTestId('signage-widget-add-clock').click()
|
await addWidget('clock')
|
||||||
await sleep(900)
|
await sleep(900)
|
||||||
r.check('5.6b: the preview shows the board with its badges (two, with their icons)',
|
r.check('5.6b: the preview shows the board with its badges (two, with their icons)',
|
||||||
await waitFor(async () => (await mgr.getByTestId('signage-preview').locator('[data-testid="signage-badge"] svg').count()) >= 2, 8000, 300) === true)
|
await waitFor(async () => (await mgr.getByTestId('signage-preview').locator('[data-testid="signage-badge"] svg').count()) >= 2, 8000, 300) === true)
|
||||||
@@ -310,18 +314,20 @@ try {
|
|||||||
// ── owner review 2 (2026-11-21): a hidden product stays in the list, greyed; widgets ordered, moved by the keys from their card; stacks ──
|
// ── owner review 2 (2026-11-21): a hidden product stays in the list, greyed; widgets ordered, moved by the keys from their card; stacks ──
|
||||||
r.check('2026-11-21 (2): a product hidden from the board stays in the list of the editor, marked hidden',
|
r.check('2026-11-21 (2): a product hidden from the board stays in the list of the editor, marked hidden',
|
||||||
await mgr.locator(`[data-testid="signage-menu-row"][data-id="${hiddenId}"]`).getAttribute('data-hidden') === 'true')
|
await mgr.locator(`[data-testid="signage-menu-row"][data-id="${hiddenId}"]`).getAttribute('data-hidden') === 'true')
|
||||||
await mgr.getByTestId('signage-widget-add-text').click()
|
await addWidget('text')
|
||||||
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-own-text').fill('Happy hour')
|
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-own-text').fill('Happy hour')
|
||||||
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-up').click()
|
const listed = await mgr.getByTestId('signage-widget').evaluateAll(els => els.map(e => e.dataset.kind))
|
||||||
|
r.check('owner 2026-11-22: "Add a widget" puts the new one at the top of the list (drawn over the others)', listed[0] === 'text', JSON.stringify(listed))
|
||||||
|
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-down').click()
|
||||||
const kinds = await mgr.getByTestId('signage-widget').evaluateAll(els => els.map(e => e.dataset.kind))
|
const kinds = await mgr.getByTestId('signage-widget').evaluateAll(els => els.map(e => e.dataset.kind))
|
||||||
r.check('2026-11-21 (2): a text widget, moved up the list with its arrow', kinds.indexOf('text') < kinds.lastIndexOf('clock'), JSON.stringify(kinds))
|
r.check('2026-11-21 (2): a text widget, sent backward with its arrow (under the clock)', kinds.indexOf('text') > kinds.indexOf('clock'), JSON.stringify(kinds))
|
||||||
r.check('2026-11-21 (2): …shown on the preview', await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-w-text').count()) > 0, 5000, 200) === true)
|
r.check('2026-11-21 (2): …shown on the preview', await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-w-text').count()) > 0, 5000, 200) === true)
|
||||||
const textCard = mgr.locator('[data-testid="signage-widget"][data-kind="text"]')
|
const textCard = mgr.locator('[data-testid="signage-widget"][data-kind="text"]')
|
||||||
await textCard.locator('span', { hasText: 'Text' }).first().click()
|
await textCard.locator('span', { hasText: 'Text' }).first().click()
|
||||||
await mgr.keyboard.press('ArrowRight')
|
await mgr.keyboard.press('ArrowRight')
|
||||||
r.check('2026-11-21 (2): picked on its card, the arrow keys move the widget (Custom)',
|
r.check('2026-11-21 (2): picked on its card, the arrow keys move the widget (Custom)',
|
||||||
await waitFor(async () => (await textCard.getByTestId('signage-widget-position').textContent()).includes('Custom'), 4000, 200) === true)
|
await waitFor(async () => (await textCard.getByTestId('signage-widget-position').textContent()).includes('Custom'), 4000, 200) === true)
|
||||||
await mgr.getByTestId('signage-widget-add-hstack').click()
|
await addWidget('hstack')
|
||||||
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
||||||
await stackCard.getByTestId('signage-stack-cell-editor').first().getByTestId('signage-stack-add').click()
|
await stackCard.getByTestId('signage-stack-cell-editor').first().getByTestId('signage-stack-add').click()
|
||||||
await mgr.getByTestId('signage-stack-add-clock').click()
|
await mgr.getByTestId('signage-stack-add-clock').click()
|
||||||
@@ -581,19 +587,23 @@ try {
|
|||||||
const ident = await api('GET', '/api/identity', { token: boss })
|
const ident = await api('GET', '/api/identity', { token: boss })
|
||||||
await api('PUT', '/api/identity', { token: boss, body: { name: ident.name || 'Taverna', wifi: { ssid: 'Xenia Guests', password: 'kalimera', security: 'WPA' },
|
await api('PUT', '/api/identity', { token: boss, body: { name: ident.name || 'Taverna', wifi: { ssid: 'Xenia Guests', password: 'kalimera', security: 'WPA' },
|
||||||
contact: { phone: '2310 123456', instagram: '@xenia' } } })
|
contact: { phone: '2310 123456', instagram: '@xenia' } } })
|
||||||
|
await api('PUT', '/api/signage/reviews', { token: boss, body: { reviews: [{ name: 'Maria', stars: 5, text: 'Best octopus on the island' }, { name: 'Bob', stars: 2, text: 'Meh' }] } })
|
||||||
await api('PUT', '/api/identity/hours', { token: boss, body: { days: [[{ from: '12:00', to: '23:00' }], [], [], [], [], [], []] } })
|
await api('PUT', '/api/identity/hours', { token: boss, body: { days: [[{ from: '12:00', to: '23:00' }], [], [], [], [], [], []] } })
|
||||||
const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } })
|
const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } })
|
||||||
await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [
|
await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [
|
||||||
{ kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' },
|
{ kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' },
|
||||||
{ kind: 'countdown', position: 'top-center', countdown_to: '2099-01-01T00:00', text: 'Opening in' },
|
{ kind: 'countdown', position: 'top-center', countdown_to: '2099-01-01T00:00', text: 'Opening in' },
|
||||||
{ kind: 'hours', position: 'top-left' }, { kind: 'wifi', position: 'bottom-right' }, { kind: 'contact', position: 'bottom-left' },
|
{ kind: 'hours', position: 'top-left' }, { kind: 'wifi', position: 'bottom-right' }, { kind: 'contact', position: 'bottom-left' },
|
||||||
{ kind: 'ticker', position: 'top-bar', text: 'Fresh fish today' }] } } })
|
{ kind: 'ticker', position: 'top-bar', text: 'Fresh fish today' },
|
||||||
|
{ kind: 'reviews', position: 'custom', box: { x: 30, y: 40, w: 40, h: 25 } }] } } })
|
||||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } })
|
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } })
|
||||||
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
|
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
|
||||||
r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV',
|
r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV',
|
||||||
await waitFor(async () => (await widgetsOn()) || null, 15_000, 300) === true)
|
await waitFor(async () => (await widgetsOn()) || null, 15_000, 300) === true)
|
||||||
r.check('6R.15: the Wi-Fi widget carries the code that joins the network', (await tv.getByTestId('signage-w-wifi').textContent()).includes('Xenia Guests')
|
r.check('6R.15: the Wi-Fi widget carries the code that joins the network', (await tv.getByTestId('signage-w-wifi').textContent()).includes('Xenia Guests')
|
||||||
&& await tv.getByTestId('signage-w-wifi').locator('svg').count() > 0)
|
&& await tv.getByTestId('signage-w-wifi').locator('svg').count() > 0)
|
||||||
|
r.check('6R.19: a review typed in by hand shows (the 2-star one is left out)', await tv.getByTestId('signage-w-reviews').getAttribute('data-count') === '1'
|
||||||
|
&& (await tv.getByTestId('signage-w-reviews').textContent()).includes('Best octopus'))
|
||||||
r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim()))
|
r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim()))
|
||||||
await tv.screenshot({ path: path.join(OUT, 'signage-new-widgets.png') })
|
await tv.screenshot({ path: path.join(OUT, 'signage-new-widgets.png') })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user