Add named wall displays: pages, order and speed per screen
An administrator can make named displays (Hall TV, Office monitor) under Settings -> Share links, each with an address of its own (/wall/hall-tv), the pages it rotates through in the board's order, and a rotation speed. The signed-in wall opens one from its address and can switch between them, and a wall share link can open one too. The address still wins over the display's speed, then the browser's choice. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
639408c0d0
commit
333146e8e3
24 files changed
+10411
-22
No files matched your search
@@ -4,6 +4,7 @@ import { api, type PublicWall } from "../api/client";
|
||||
import WallView, { REFRESH_MS, wallHeadline, type WallData } from "../components/WallView";
|
||||
import { setDateTimeSettings } from "../utils/date";
|
||||
import { useWallRotation } from "../hooks/useWallRotation";
|
||||
import { t } from "../i18n";
|
||||
|
||||
/**
|
||||
* The wall display behind a share link: the same board, read-only and without signing in. The address carries the secret, and the
|
||||
@@ -16,7 +17,9 @@ export default function SharedWall() {
|
||||
const [state, setState] = useState<"loading" | "ok" | "dead" | "unreachable">("loading");
|
||||
const [updatedAt, setUpdatedAt] = useState<Date | null>(null);
|
||||
const [idle, setIdle] = useState(false);
|
||||
const rotation = useWallRotation();
|
||||
// The named display this link opens, once the board has been read: its pages and its speed.
|
||||
const [displayConfig, setDisplayConfig] = useState<PublicWall["displayConfig"]>(null);
|
||||
const rotation = useWallRotation(displayConfig?.rotateSeconds ?? null);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
@@ -28,6 +31,7 @@ export default function SharedWall() {
|
||||
if (!alive) return;
|
||||
setDateTimeSettings({ dateFormat: w.display.dateFormat as "ymd" | "dmy" | "mdy", timeFormat: w.display.timeFormat as "24h" | "12h" });
|
||||
setWall(w);
|
||||
setDisplayConfig(w.displayConfig ?? null);
|
||||
setUpdatedAt(new Date());
|
||||
setState("ok");
|
||||
})
|
||||
@@ -103,6 +107,7 @@ export default function SharedWall() {
|
||||
<WallView
|
||||
data={data}
|
||||
idle={idle}
|
||||
display={displayConfig ? { name: displayConfig.name, pages: displayConfig.pages } : null}
|
||||
rotation={{ seconds: rotation.seconds, onChange: rotation.setSeconds }}
|
||||
footerActions={
|
||||
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
|
||||
|
||||
+34
-5
@@ -1,10 +1,11 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { api, type IntegrationSummary, type MaintenanceWindow, type ServerSummary, type WallGroup, type WallTile } from "../api/client";
|
||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||
import { api, type IntegrationSummary, type MaintenanceWindow, type ServerSummary, type WallDisplay, type WallGroup, type WallTile } from "../api/client";
|
||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||
import { useEnvironment } from "../utils/environment";
|
||||
import { useWallRotation } from "../hooks/useWallRotation";
|
||||
import WallView, { REFRESH_MS, wallHeadline, type WallData } from "../components/WallView";
|
||||
import { t } from "../i18n";
|
||||
|
||||
/**
|
||||
* A full-screen status board for a spare monitor or tablet: how things are, in type big enough to read across a room, refreshing
|
||||
@@ -20,7 +21,17 @@ export default function Wall() {
|
||||
const [extras, setExtras] = useState<{ tiles: WallTile[]; groups: WallGroup[] } | null>(null);
|
||||
const [updatedAt, setUpdatedAt] = useState<Date | null>(null);
|
||||
const [idle, setIdle] = useState(false);
|
||||
const rotation = useWallRotation();
|
||||
// A named display ("/wall/hall-tv"): which pages it rotates through and how fast. Without one (or while it is being read) the board is the whole board, as it always was.
|
||||
const { slug } = useParams();
|
||||
const [displays, setDisplays] = useState<WallDisplay[] | null>(null);
|
||||
const display = slug ? (displays ?? []).find((d) => d.slug === slug) ?? null : null;
|
||||
const rotation = useWallRotation(display?.rotateSeconds ?? null);
|
||||
useEffect(() => {
|
||||
api.wallDisplays
|
||||
.list()
|
||||
.then((res) => setDisplays(res.displays))
|
||||
.catch(() => setDisplays([]));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
@@ -93,14 +104,32 @@ export default function Wall() {
|
||||
<WallView
|
||||
data={data}
|
||||
idle={idle}
|
||||
display={display ? { name: display.name, pages: display.pages } : slug && displays !== null ? { name: t("No display called “{slug}” — showing everything", { slug }), pages: [] } : null}
|
||||
rotation={{ seconds: rotation.seconds, onChange: rotation.setSeconds }}
|
||||
footerActions={
|
||||
<>
|
||||
{displays && displays.length > 0 && (
|
||||
<label className="wall-rotate">
|
||||
{t("Display")}{" "}
|
||||
<select
|
||||
aria-label={t("Which wall display")}
|
||||
value={slug ?? ""}
|
||||
onChange={(e) => navigate(e.target.value ? `/wall/${e.target.value}${window.location.search}` : `/wall${window.location.search}`)}
|
||||
>
|
||||
<option value="">{t("Everything")}</option>
|
||||
{displays.map((d) => (
|
||||
<option key={d.id} value={d.slug}>
|
||||
{d.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
|
||||
Full screen
|
||||
{t("Full screen")}
|
||||
</button>
|
||||
<Link to="/" className="wall-link">
|
||||
Exit (Esc)
|
||||
{t("Exit (Esc)")}
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api, type ShareLink, type ShareLinkDetail, type ShareLinkKind } from "../../api/client";
|
||||
import { api, type ShareLink, type ShareLinkDetail, type ShareLinkKind, type WallDisplay } from "../../api/client";
|
||||
import WallDisplays from "../../components/WallDisplays";
|
||||
import StatusPageEditor from "../../components/StatusPageEditor";
|
||||
import CopyButton from "../../components/CopyButton";
|
||||
import TimeAgo from "../../components/TimeAgo";
|
||||
@@ -28,6 +29,9 @@ const DETAIL_WORDS: Record<ShareLinkDetail, string> = {
|
||||
|
||||
export default function ShareSettings() {
|
||||
const [links, setLinks] = useState<ShareLink[] | null>(null);
|
||||
const [displays, setDisplays] = useState<WallDisplay[] | null>(null);
|
||||
// For a wall link: the named display it opens ("" is the whole board).
|
||||
const [displayId, setDisplayId] = useState("");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [label, setLabel] = useState("");
|
||||
const [detail, setDetail] = useState<ShareLinkDetail>("summary");
|
||||
@@ -46,14 +50,21 @@ export default function ShareSettings() {
|
||||
.then((res) => setLinks(res.links))
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}
|
||||
function loadDisplays() {
|
||||
api.wallDisplays
|
||||
.list()
|
||||
.then((res) => setDisplays(res.displays))
|
||||
.catch(() => setDisplays([]));
|
||||
}
|
||||
useEffect(load, []);
|
||||
useEffect(loadDisplays, []);
|
||||
|
||||
async function create(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
setBusy(true);
|
||||
try {
|
||||
const res = await api.shareLinks.create(kind === "status" ? { label: label.trim(), kind, title: title.trim() || undefined, message: message.trim() || undefined, expiresInDays: days } : { label: label.trim(), kind, detail, expiresInDays: days });
|
||||
const res = await api.shareLinks.create(kind === "status" ? { label: label.trim(), kind, title: title.trim() || undefined, message: message.trim() || undefined, expiresInDays: days } : { label: label.trim(), kind, detail, ...(kind === "wall" && displayId ? { displayId: Number(displayId) } : {}), expiresInDays: days });
|
||||
setCreated({ label: res.link.label, url: window.location.origin + res.path });
|
||||
setLabel("");
|
||||
setTitle("");
|
||||
@@ -90,6 +101,14 @@ export default function ShareSettings() {
|
||||
</div>
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
<WallDisplays
|
||||
displays={displays}
|
||||
onChanged={() => {
|
||||
loadDisplays();
|
||||
load();
|
||||
}}
|
||||
/>
|
||||
|
||||
{created && (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
@@ -152,6 +171,21 @@ export default function ShareSettings() {
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
{kind === "wall" && displays && displays.length > 0 && (
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="share-display">
|
||||
{t("Which display")}
|
||||
</label>
|
||||
<select id="share-display" className="form-select" value={displayId} onChange={(e) => setDisplayId(e.target.value)}>
|
||||
<option value="">{t("Everything — every page")}</option>
|
||||
{displays.map((d) => (
|
||||
<option key={d.id} value={d.id}>
|
||||
{d.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
{kind === "status" && (
|
||||
<>
|
||||
<div className="col-md-6">
|
||||
@@ -221,7 +255,7 @@ export default function ShareSettings() {
|
||||
<td>
|
||||
{l.label} <span className="text-secondary small">{l.tokenPrefix}…</span>
|
||||
</td>
|
||||
<td>{l.kind === "status" ? "Status page · " + l.itemCount + (l.itemCount === 1 ? " thing" : " things") : l.kind === "calendar" ? "Calendar · " + (l.detail === "names" ? "with names" : "kinds only") : "Wall · " + DETAIL_WORDS[l.detail].toLowerCase()}</td>
|
||||
<td>{l.kind === "status" ? "Status page · " + l.itemCount + (l.itemCount === 1 ? " thing" : " things") : l.kind === "calendar" ? "Calendar · " + (l.detail === "names" ? "with names" : "kinds only") : "Wall · " + DETAIL_WORDS[l.detail].toLowerCase() + (l.displayId !== null ? " · " + (displays?.find((d) => d.id === l.displayId)?.name ?? "") : "")}</td>
|
||||
<td className="text-secondary">
|
||||
{l.createdBy ?? "—"}, <TimeAgo value={l.createdAt} fromDb />
|
||||
</td>
|
||||
|
||||
Reference in new issue
Block a user