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:
bobbanandClaude Sonnet 5.5 committed 2026-11-12 23:04:22 +01:00
1 parent 639408c0d0
commit 333146e8e3
24 files changed
+10411 -22

No files matched your search

+1
View File
@@ -166,6 +166,7 @@ export default function App() {
<Fragment key={lang}>
<Routes>
<Route path="/wall" element={<Wall />} />
<Route path="/wall/:slug" element={<Wall />} />
<Route path="*" element={<Shelled user={user} />} />
</Routes>
</Fragment>
+29 -1
View File
@@ -53,11 +53,31 @@ export interface PublicStatus {
}
/** A link that opens the wall display, or a status page, without signing in, as the settings list shows it (never the secret). */
/** A named wall display: which pages the board rotates through (in order; none is every page) and how fast. */
export interface WallDisplay {
id: number;
name: string;
/** The address: /wall/<slug>. */
slug: string;
pages: string[];
rotateSeconds: number | null;
createdBy: string | null;
createdAt: string;
}
export interface WallDisplayInput {
name: string;
slug?: string;
pages: string[];
rotateSeconds: number | null;
}
export interface ShareLink {
id: number;
label: string;
tokenPrefix: string;
kind: ShareLinkKind;
/** For a wall: the named display it opens; null is the whole board. */
displayId: number | null;
/** A status page's own heading and message. */
title: string | null;
message: string | null;
@@ -90,6 +110,8 @@ export interface WallGroup {
}
export interface PublicWall {
/** The named display this link opens, if any. */
displayConfig?: { name: string; pages: string[]; rotateSeconds: number | null } | null;
detail: ShareLinkDetail;
level: "ok" | "warning" | "critical" | "unsure";
environment: string | null;
@@ -4059,10 +4081,16 @@ export const api = {
},
shareLinks: {
list: () => request<{ links: ShareLink[] }>("/api/share-links"),
create: (data: { label: string; detail?: ShareLinkDetail; kind?: ShareLinkKind; title?: string; message?: string; expiresInDays: number | null }) =>
create: (data: { label: string; detail?: ShareLinkDetail; kind?: ShareLinkKind; displayId?: number | null; title?: string; message?: string; expiresInDays: number | null }) =>
request<{ link: ShareLink; token: string; path: string }>("/api/share-links", { method: "POST", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/share-links/${id}`, { method: "DELETE" }),
},
wallDisplays: {
list: () => request<{ displays: WallDisplay[] }>("/api/wall-displays"),
create: (data: WallDisplayInput) => request<{ display: WallDisplay }>("/api/wall-displays", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: WallDisplayInput) => request<{ display: WallDisplay }>(`/api/wall-displays/${id}`, { method: "PUT", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/wall-displays/${id}`, { method: "DELETE" }),
},
statusPages: {
get: (linkId: number) => request<{ title: string; message: string; items: StatusPageItem[]; maxItems: number }>("/api/share-links/" + linkId + "/status"),
choices: () => request<{ servers: { id: number; name: string }[]; integrations: { id: number; name: string; type: string }[] }>("/api/share-links/status-choices"),
+196
View File
@@ -0,0 +1,196 @@
import { useState } from "react";
import { api, type WallDisplay } from "../api/client";
import { t } from "../i18n";
import { confirmDialog } from "../utils/dialogs";
import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
import { displayPageChoices, ROTATE_CHOICES } from "../utils/wallPages";
import CopyButton from "./CopyButton";
import { ErrorNotice } from "./Notice";
interface Draft {
id: number | null;
name: string;
slug: string;
pages: string[];
rotateSeconds: number | null;
}
const EMPTY: Draft = { id: null, name: "", slug: "", pages: [], rotateSeconds: null };
/** What a display shows, in words: "every page", or the pages it lists. */
function pagesWords(pages: string[]): string {
if (pages.length === 0) return t("Every page the board has");
const label = new Map(displayPageChoices().map((c) => [c.id, c.label]));
return pages.map((p) => t(label.get(p) ?? p)).join(" → ");
}
/**
* Named wall displays: "Hall TV", "Office monitor". Each is a choice of which pages the board rotates through and how fast, with an address of its own (/wall/hall-tv) to bookmark on that screen — and a
* share link can open one too. Administrators make and change them; they only choose among the pages the board has, they do not change what it shows.
*/
export default function WallDisplays({ displays, onChanged }: { displays: WallDisplay[] | null; onChanged: () => void }) {
const [draft, setDraft] = useState<Draft | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const choices = displayPageChoices();
function edit(d: WallDisplay) {
setDraft({ id: d.id, name: d.name, slug: d.slug, pages: d.pages, rotateSeconds: d.rotateSeconds });
setError(null);
}
/** The pages in the order of the board, whichever order they were ticked in. */
function toggle(id: string) {
if (!draft) return;
const on = draft.pages.includes(id);
const next = on ? draft.pages.filter((p) => p !== id) : [...draft.pages, id];
setDraft({ ...draft, pages: choices.map((c) => c.id).filter((c) => next.includes(c)) });
}
async function save(e: React.FormEvent) {
e.preventDefault();
if (!draft) return;
setBusy(true);
setError(null);
try {
const input = { name: draft.name.trim(), slug: draft.slug.trim() || undefined, pages: draft.pages, rotateSeconds: draft.rotateSeconds };
if (draft.id === null) await api.wallDisplays.create(input);
else await api.wallDisplays.update(draft.id, input);
toast.success(draft.id === null ? t("Added {name}.", { name: draft.name.trim() }) : t("Saved."));
setDraft(null);
onChanged();
} catch (err) {
setError(readableError(err));
} finally {
setBusy(false);
}
}
async function remove(d: WallDisplay) {
if (!(await confirmDialog({ title: t("Remove a wall display"), message: t("Remove \"{name}\"? A screen using its address shows the whole board instead, and a share link that opened it opens the whole board.", { name: d.name }), confirmLabel: t("Remove"), danger: true }))) return;
try {
await api.wallDisplays.remove(d.id);
toast.success(t("Removed {name}.", { name: d.name }));
onChanged();
} catch (err) {
setError(readableError(err));
}
}
return (
<div className="card mb-4">
<div className="card-header">
<h3 className="card-title">{t("Wall displays")}</h3>
{!draft && (
<div className="card-actions">
<button type="button" className="btn btn-primary btn-sm" onClick={() => setDraft({ ...EMPTY })}>
{t("Add a display")}
</button>
</div>
)}
</div>
<div className="card-body">
<p className="text-secondary">
{t("A display is a screen with its own address — the hall TV, the office monitor — that shows the pages you choose, in your order, at the speed you choose. Open it from the user menu's Wall display, or bookmark its address on the screen it is for. It chooses among the pages the board has; what the board shows does not change.")}
</p>
<ErrorNotice error={error} />
{draft && (
<form onSubmit={save} className="row g-3 mb-3">
<div className="col-md-5">
<label className="form-label" htmlFor="wd-name">
{t("Name")}
</label>
<input id="wd-name" className="form-control" required maxLength={60} placeholder={t("e.g. Hall TV")} value={draft.name} onChange={(e) => setDraft({ ...draft, name: e.target.value })} />
</div>
<div className="col-md-4">
<label className="form-label" htmlFor="wd-slug">
{t("Address")} <span className="text-secondary">{t("(optional)")}</span>
</label>
<div className="input-group">
<span className="input-group-text">/wall/</span>
<input id="wd-slug" className="form-control" maxLength={40} placeholder={t("made from the name")} pattern="[a-z0-9]+(-[a-z0-9]+)*" title={t("Lower case letters, digits and single hyphens")} value={draft.slug} onChange={(e) => setDraft({ ...draft, slug: e.target.value })} />
</div>
</div>
<div className="col-md-3">
<label className="form-label" htmlFor="wd-rotate">
{t("Rotate every")}
</label>
<select id="wd-rotate" className="form-select" value={draft.rotateSeconds ?? ""} onChange={(e) => setDraft({ ...draft, rotateSeconds: e.target.value === "" ? null : Number(e.target.value) })}>
<option value="">{t("Not set (the address or this screen decides)")}</option>
{ROTATE_CHOICES.map((s) => (
<option key={s} value={s}>
{t("{n} seconds", { n: s })}
</option>
))}
</select>
</div>
<div className="col-12">
<div className="form-label">{t("Pages it shows, in the order of the board")}</div>
<div className="d-flex flex-wrap gap-3">
{choices.map((c) => (
<label key={c.id} className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={draft.pages.includes(c.id)} onChange={() => toggle(c.id)} />
<span className="form-check-label">{t(c.label)}</span>
</label>
))}
</div>
<div className="form-hint text-secondary small mt-1">
{t("Tick none for every page the board has. A page only appears while it has something to show: “Needs attention” only while something does, a group only if you have an integration in it.")}
</div>
</div>
<div className="col-12 d-flex gap-2">
<button type="submit" className="btn btn-primary" disabled={busy || draft.name.trim() === ""}>
{busy ? t("Saving…") : t("Save")}
</button>
<button type="button" className="btn" onClick={() => setDraft(null)}>
{t("Cancel")}
</button>
</div>
</form>
)}
{displays?.length === 0 && !draft && <div className="text-secondary">{t("No displays yet. Without one, the wall shows every page.")}</div>}
{displays && displays.length > 0 && (
<div className="table-responsive">
<table className="table table-vcenter mb-0">
<thead>
<tr>
<th>{t("Name")}</th>
<th>{t("Address")}</th>
<th>{t("Pages")}</th>
<th>{t("Rotates")}</th>
<th className="w-1">{t("Actions")}</th>
</tr>
</thead>
<tbody>
{displays.map((d) => (
<tr key={d.id}>
<td className="fw-bold">{d.name}</td>
<td>
<a href={`/wall/${d.slug}`} target="_blank" rel="noreferrer">
/wall/{d.slug}
</a>{" "}
<CopyButton text={`${window.location.origin}/wall/${d.slug}`} />
</td>
<td className="text-secondary">{pagesWords(d.pages)}</td>
<td className="text-secondary">{d.rotateSeconds === null ? t("not set") : t("every {n} s", { n: d.rotateSeconds })}</td>
<td>
<div className="btn-list flex-nowrap">
<button type="button" className="btn btn-sm" onClick={() => edit(d)}>
{t("Edit")}
</button>
<button type="button" className="btn btn-sm btn-outline-danger" onClick={() => void remove(d)}>
{t("Remove")}
</button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
</div>
);
}
+7 -3
View File
@@ -2,7 +2,7 @@ import { useEffect, useState, type ReactNode } from "react";
import type { WallGroup, WallTile } from "../api/client";
import { formatDate, formatTime } from "../utils/date";
import { formatRemaining } from "../utils/duration";
import { groupMembers, pageOrOverview, ROTATE_CHOICES, stepPage, wallPages } from "../utils/wallPages";
import { applyDisplay, groupMembers, pageOrOverview, ROTATE_CHOICES, stepPage, wallPages } from "../utils/wallPages";
import { t } from "../i18n";
export const REFRESH_MS = 30_000;
@@ -115,10 +115,13 @@ export default function WallView({
idle,
footerActions,
rotation,
display,
}: {
data: WallData;
idle: boolean;
footerActions: ReactNode;
/** A named display: its name (shown in the footer) and which pages it rotates through, in order; none listed is every page. */
display?: { name: string; pages: string[] } | null;
/** How the pages rotate (seconds each, null for the overview alone) and how to change it; absent on a board that does not rotate. */
rotation?: { seconds: number | null; onChange: (seconds: number | null) => void };
}) {
@@ -127,7 +130,7 @@ export default function WallView({
// The pages: the overview, what needs attention (while something does), and one for each group of integrations.
const rotating = !!rotation && rotation.seconds !== null;
const pages = wallPages(data);
const pages = applyDisplay(wallPages(data), display?.pages ?? []);
const pagesKey = pages.map((p) => p.id).join(",");
const [pageId, setPageId] = useState("overview");
const [paused, setPaused] = useState(false);
@@ -287,6 +290,7 @@ export default function WallView({
<footer className="wall-footer">
<span>
{display?.name && <strong>{display.name} · </strong>}
{data.updatedAt ? `Updated ${formatTime(data.updatedAt)}` : "Loading…"} · refreshes every {REFRESH_MS / 1000} s
{rotating && pages.length > 1 && (
<span className="wall-pager" aria-label={`Page ${pages.findIndex((p) => p.id === page.id) + 1} of ${pages.length}: ${page.label}`}>
@@ -310,7 +314,7 @@ export default function WallView({
value={rotation.seconds === null ? "off" : String(rotation.seconds)}
onChange={(e) => {
setPaused(false);
setPageId("overview");
setPageId(pages[0].id);
rotation.onChange(e.target.value === "off" ? null : Number(e.target.value));
}}
>
+3 -3
View File
@@ -14,11 +14,11 @@ function stored(): string | null {
/**
* How the wall display rotates: how many seconds each page stays, or null for the overview alone. It lives in the address (`?rotate=30`),
* so a TV's bookmark carries it, and this browser remembers the last choice made on the board itself.
* so a TV's bookmark carries it, and this browser remembers the last choice made on the board itself. A named display may say how fast too (`configured`); the address still wins over it.
*/
export function useWallRotation() {
export function useWallRotation(configured: number | null = null) {
const [params, setParams] = useSearchParams();
const seconds = rotateSeconds(params.get("rotate"), stored());
const seconds = rotateSeconds(params.get("rotate"), stored(), configured);
const setSeconds = useCallback(
(next: number | null) => {
try {
+31
View File
@@ -24,6 +24,7 @@ export const sv: Record<string, string> = {
"{n} mo ago": "för {n} mån sedan",
"{n} more acknowledged": "{n} till kvitterade",
"{n} more explained by something that is down": "{n} till förklaras av något som ligger nere",
"{n} seconds": "{n} sekunder",
"{n} silenced by maintenance": "{n} tystade av underhåll",
"{n} so far": "{n} hittills",
"{n} stretch with a failure": "{n} period med ett fel",
@@ -53,6 +54,7 @@ export const sv: Record<string, string> = {
"7 days": "7 dagar",
"8 hours": "8 timmar",
"90 days": "90 dagar",
"A display is a screen with its own address — the hall TV, the office monitor — that shows the pages you choose, in your order, at the speed you choose. Open it from the user menu's Wall display, or bookmark its address on the screen it is for. It chooses among the pages the board has; what the board shows does not change.": "En display är en skärm med en egen adress — hallens TV, kontorets skärm — som visar de sidor du väljer, i den ordning du väljer, i den takt du väljer. Öppna den från Väggskärm i användarmenyn, eller bokmärk dess adress på skärmen den är till för. Den väljer bland de sidor tavlan har; vad tavlan visar ändras inte.",
"A full-screen status board for a spare monitor or tablet": "En helskärmsöversikt för en ledig skärm eller surfplatta",
"A job about this": "Ett jobb om det här",
"A job to add": "Ett jobb att lägga till",
@@ -70,6 +72,7 @@ export const sv: Record<string, string> = {
"Actions": "Åtgärder",
"Active": "Aktiv",
"Add {name} to favourites": "Lägg till {name} i favoriter",
"Add a display": "Lägg till en display",
"Add a job": "Lägg till ett jobb",
"Add a job about this…": "Lägg till ett jobb om det här…",
"Add a job above, and give it a day if it has one.": "Lägg till ett jobb ovan och ge det en dag om det har en.",
@@ -89,8 +92,10 @@ export const sv: Record<string, string> = {
"Add server": "Lägg till server",
"Add task": "Lägg till uppgift",
"Add:": "Lägg till:",
"Added {name}.": "{name} är tillagd.",
"Added.": "Tillagd.",
"Adding…": "Lägger till…",
"Address": "Adress",
"Address aliases": "Adressalias",
"Address in Uptime Kuma": "Adress i Uptime Kuma",
"Address to scan": "Adress att skanna",
@@ -210,6 +215,7 @@ export const sv: Record<string, string> = {
"Disabled": "Avstängd",
"Disk (allocated)": "Disk (tilldelad)",
"Dismiss": "Avfärda",
"Display": "Display",
"DNS answers": "DNS-svar",
"DNS providers": "DNS-leverantörer",
"DNS record change notifications.": "Notiser om ändrade DNS-poster.",
@@ -219,6 +225,7 @@ export const sv: Record<string, string> = {
"Done": "Klar",
"Download clients": "Nedladdningsklienter",
"Due day (optional)": "Förfallodag (valfritt)",
"e.g. Hall TV": "t.ex. Hallens TV",
"Each connected system gets its own page — open it from here or from the sidebar, in the group shown. Add and manage credentials here.": "Varje anslutet system får en egen sida — öppna den härifrån eller från sidomenyn, i gruppen som visas. Lägg till och hantera inloggningsuppgifter här.",
"Each server may be under maintenance for": "Varje server får vara under underhåll i högst",
"Edit": "Redigera",
@@ -232,14 +239,19 @@ export const sv: Record<string, string> = {
"Ends": "Slutar",
"Ends in": "Slutar om",
"Enter a value": "Ange ett värde",
"every {n} s": "var {n} s",
"Every alert is live. Start a window above before you work on something, so it doesn't raise alarms while you do.": "Alla larm är aktiva. Starta ett fönster ovan innan du jobbar med något, så att det inte larmar medan du gör det.",
"Every container is on its latest image, as far as the last check could tell.": "Alla containrar kör sin senaste avbild, så vitt den senaste kontrollen kunde se.",
"Every page the board has": "Alla sidor tavlan har",
"Every server": "Alla servrar",
"Every time a recurring maintenance happens": "Varje gång ett återkommande underhåll sker",
"Every Uptime Kuma integration is disabled — enable one under Integrations.": "Alla Uptime Kuma-integrationer är avstängda — slå på en under Integrationer.",
"Everything": "Allt",
"Everything — every page": "Allt — alla sidor",
"Everything — every server, integration, network device and DNS provider": "Allt — alla servrar, integrationer, nätverksenheter och DNS-leverantörer",
"Everything about this server in the change log": "Allt om den här servern i ändringsloggen",
"Everything coming up": "Allt som är på gång",
"Exit (Esc)": "Avsluta (Esc)",
"Expired:": "Utgånget:",
"Expiring:": "Löper ut:",
"Export CSV": "Exportera CSV",
@@ -255,6 +267,7 @@ export const sv: Record<string, string> = {
"Fold the cards you do not need and put the others in the order you like — for every server": "Fäll ihop korten du inte behöver och lägg de andra i den ordning du vill — för alla servrar",
"Follow Settings again": "Följ Inställningar igen",
"From now": "Från nu",
"Full screen": "Helskärm",
"Further ahead": "Längre fram",
"Game servers": "Spelservrar",
"Generator": "Generator",
@@ -330,7 +343,9 @@ export const sv: Record<string, string> = {
"Load:": "Belastning:",
"Loading…": "Läser in…",
"Longest wait": "Längsta väntan",
"Lower case letters, digits and single hyphens": "Små bokstäver, siffror och enstaka bindestreck",
"Lowercase letters, numbers and - _ . : / — up to 12 tags per server.": "Små bokstäver, siffror och - _ . : / — upp till 12 taggar per server.",
"made from the name": "görs av namnet",
"Main menu": "Huvudmeny",
"Maintenance": "Underhåll",
"Maintenance — alerts silenced for": "Underhåll — larm tystade för",
@@ -377,6 +392,8 @@ export const sv: Record<string, string> = {
"No admin links added yet — e.g. Dockge, Webmin, or Cockpit for this server.": "Inga adminlänkar tillagda än — till exempel Dockge, Webmin eller Cockpit för den här servern.",
"No agent data": "Inga agentdata",
"No data": "Inga data",
"No display called “{slug}” — showing everything": "Ingen display heter ”{slug}” — visar allt",
"No displays yet. Without one, the wall shows every page.": "Inga displayer än. Utan någon visar väggskärmen alla sidor.",
"No enabled Proxmox integrations configured yet.": "Inga påslagna Proxmox-integrationer har konfigurerats än.",
"No expiry dates": "Inga utgångsdatum",
"No hardware data yet. Install the agent on this server, or link it to a Proxmox VM/LXC (under Settings).": "Inga hårdvarudata än. Installera agenten på servern, eller koppla den till en Proxmox-VM/LXC (under Inställningar).",
@@ -410,6 +427,8 @@ export const sv: Record<string, string> = {
"not reported": "ej rapporterat",
"Not reporting": "Rapporterar inte",
"Not scanned yet.": "Inte skannad än.",
"not set": "inte satt",
"Not set (the address or this screen decides)": "Inte satt (adressen eller skärmen bestämmer)",
"Not set up yet": "Inte uppsatt än",
"Not silenced": "Inte tystad",
"Notes": "Anteckningar",
@@ -458,9 +477,12 @@ export const sv: Record<string, string> = {
"Operating system": "Operativsystem",
"Operations": "Drift",
"OS type": "OS-typ",
"Other": "Övrigt",
"Others sign in with Authentik and appear under Users; you decide their role.": "Andra loggar in med Authentik och dyker upp under Användare; du bestämmer deras roll.",
"Overview": "Översikt",
"Page {page} of {pages} ({total} total)": "Sida {page} av {pages} ({total} totalt)",
"Pages": "Sidor",
"Pages it shows, in the order of the board": "Sidor den visar, i tavlans ordning",
"Patch plans": "Patchplaner",
"Pick all {n} shown": "Markera alla {n} som visas",
"Pick the servers to change together, then choose what to do from the bar at the foot of the page.": "Markera de servrar som ska ändras tillsammans och välj sedan vad som ska göras i fältet längst ned på sidan.",
@@ -489,11 +511,14 @@ export const sv: Record<string, string> = {
"Refresh": "Uppdatera",
"Refreshing…": "Uppdaterar…",
"Remove": "Ta bort",
"Remove \"{name}\"? A screen using its address shows the whole board instead, and a share link that opened it opens the whole board.": "Ta bort ”{name}”? En skärm som använder dess adress visar hela tavlan i stället, och en delningslänk som öppnade den öppnar hela tavlan.",
"Remove {name} from favourites": "Ta bort {name} från favoriter",
"Remove a wall display": "Ta bort en väggdisplay",
"Remove acknowledgement": "Ta bort kvittering",
"Remove it": "Ta bort den",
"Remove recurring maintenance": "Ta bort återkommande underhåll",
"Remove server": "Ta bort server",
"Removed {name}.": "{name} är borttagen.",
"Reported": "Rapporterad",
"Reported by the agent as of": "Rapporterat av agenten per",
"Reporting": "Rapporterar",
@@ -510,7 +535,9 @@ export const sv: Record<string, string> = {
"Restart…": "Starta om…",
"restarted": "omstartad",
"Roomy": "Luftig",
"Rotate every": "Rotera var",
"Rotate token": "Byt nyckel",
"Rotates": "Roterar",
"Rows per page": "Rader per sida",
"Run #{id} in Semaphore — the playbook's output is there.": "Körning #{id} i Semaphore — playbookens utdata finns där.",
"Run a playbook": "Kör en playbook",
@@ -623,6 +650,7 @@ export const sv: Record<string, string> = {
"This server's agent hasn't reported updates — it may be an older agent, or its package manager isn't one it can ask.": "Serverns agent har inte rapporterat uppdateringar — det kan vara en äldre agent, eller så är dess pakethanterare ingen den kan fråga.",
"This token is only shown once — copy it now.": "Nyckeln visas bara en gång — kopiera den nu.",
"This week": "Den här veckan",
"Tick none for every page the board has. A page only appears while it has something to show: “Needs attention” only while something does, a group only if you have an integration in it.": "Kryssa inget för alla sidor tavlan har. En sida visas bara när den har något att visa: ”Behöver uppmärksamhet” bara när något gör det, en grupp bara om du har en integration i den.",
"Time in total": "Tid totalt",
"Time range": "Tidsperiod",
"Title": "Titel",
@@ -663,6 +691,7 @@ export const sv: Record<string, string> = {
"Wake": "Väck",
"Wake now": "Väck nu",
"Wall display": "Väggskärm",
"Wall displays": "Väggdisplayer",
"Warning": "Varning",
"Welcome back,": "Välkommen tillbaka,",
"What are you working on?": "Vad jobbar du med?",
@@ -678,7 +707,9 @@ export const sv: Record<string, string> = {
"When you acknowledge an alert, are handed one, put something under maintenance or start an update run, it is listed here until it is done.": "När du kvitterar ett larm, får ett tilldelat, sätter något under underhåll eller startar en uppdateringskörning listas det här tills det är klart.",
"Where": "Var",
"Whether somebody is on it": "Om någon jobbar med det",
"Which display": "Vilken display",
"Which servers": "Vilka servrar",
"Which wall display": "Vilken väggdisplay",
"Whose jobs": "Vems jobb",
"Widen the sidebar": "Bredda sidomenyn",
"Widen the sidebar ([)": "Bredda sidomenyn ([)",
+6 -1
View File
@@ -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
View File
@@ -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>
</>
}
+37 -3
View File
@@ -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>
+18 -2
View File
@@ -40,6 +40,21 @@ export function wallPages(d: WallPagesInput): WallPage[] {
return pages;
}
/**
* Pure: the pages a named display rotates through — those it lists, in the order it lists them, that the board has just now (an "alerts" page only exists while something needs attention). A display that
* lists none shows every page the board has, and one whose pages are all gone from the board shows the overview rather than nothing.
*/
export function applyDisplay(pages: WallPage[], wanted: string[]): WallPage[] {
if (wanted.length === 0) return pages;
const chosen = [...new Set(wanted)].map((id) => pages.find((p) => p.id === id)).filter((p): p is WallPage => !!p);
return chosen.length > 0 ? chosen : pages.slice(0, 1);
}
/** The page ids a display may be given, in the order of the board, and what each is called: the overview, what needs attention, and a group of integrations each. */
export function displayPageChoices(): { id: string; label: string }[] {
return [{ id: "overview", label: "Overview" }, { id: "alerts", label: "Needs attention" }, ...[...TYPE_GROUPS.map((g) => ({ id: `group:${g.id}`, label: g.label })), { id: "group:other", label: "Other" }]];
}
/** Pure: the page `step` places on from the current one (wrapping round); a page that is gone (its alerts cleared) sends it to the overview. */
export function stepPage(pages: WallPage[], currentId: string, step: number): WallPage {
const at = pages.findIndex((p) => p.id === currentId);
@@ -54,9 +69,9 @@ export function pageOrOverview(pages: WallPage[], currentId: string): WallPage {
/**
* Pure: how long each page stays, in seconds, or null for no rotation. The address wins (`?rotate=45`; `?rotate=on` for the default; `?rotate=off`),
* then what this browser last chose, else no rotation. A number out of range is brought into it; anything else means off.
* then what the named display says (when it says), then what this browser last chose, else no rotation. A number out of range is brought into it; anything else means off.
*/
export function rotateSeconds(param: string | null, stored: string | null): number | null {
export function rotateSeconds(param: string | null, stored: string | null, configured: number | null = null): number | null {
const read = (v: string | null): number | null | undefined => {
if (v === null || v === "") return undefined;
const t = v.trim().toLowerCase();
@@ -67,6 +82,7 @@ export function rotateSeconds(param: string | null, stored: string | null): numb
};
const fromAddress = read(param);
if (fromAddress !== undefined) return fromAddress;
if (configured !== null) return Math.min(ROTATE_MAX, Math.max(ROTATE_MIN, configured));
return read(stored) ?? null;
}