Wall displays: a night schedule that dims or blanks the board

A named display can dim the board or blank it (so a tablet or computer may
sleep) between two times on the screen's own clock. A critical alert brings the
board back unless told not to, and a touch or key press brings it back for two
minutes. A share link that opens the display follows the same schedule.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-13 18:47:53 +01:00
1 parent 168d01dc7b
commit a69d0a611d
17 files changed
+9948 -22

No files matched your search

+4 -1
View File
@@ -61,6 +61,8 @@ export interface WallDisplay {
slug: string;
pages: string[];
rotateSeconds: number | null;
/** A night schedule on the screen's own clock; null = none. */
night: { from: string; to: string; mode: "dim" | "off"; wakeOnCritical: boolean } | null;
createdBy: string | null;
createdAt: string;
}
@@ -69,6 +71,7 @@ export interface WallDisplayInput {
slug?: string;
pages: string[];
rotateSeconds: number | null;
night: { from: string; to: string; mode: "dim" | "off"; wakeOnCritical: boolean } | null;
}
export interface ShareLink {
@@ -111,7 +114,7 @@ export interface WallGroup {
export interface PublicWall {
/** The named display this link opens, if any. */
displayConfig?: { name: string; pages: string[]; rotateSeconds: number | null } | null;
displayConfig?: { name: string; pages: string[]; rotateSeconds: number | null; night: { from: string; to: string; mode: "dim" | "off"; wakeOnCritical: boolean } | null } | null;
detail: ShareLinkDetail;
level: "ok" | "warning" | "critical" | "unsure";
environment: string | null;
+58 -4
View File
@@ -14,9 +14,21 @@ interface Draft {
slug: string;
pages: string[];
rotateSeconds: number | null;
/** A night schedule: switched on, from, to (screen's own clock), how, and whether a critical alert brings the board back. */
night: boolean;
nightFrom: string;
nightTo: string;
nightMode: "dim" | "off";
nightWake: boolean;
}
const EMPTY: Draft = { id: null, name: "", slug: "", pages: [], rotateSeconds: null };
const EMPTY: Draft = { id: null, name: "", slug: "", pages: [], rotateSeconds: null, night: false, nightFrom: "22:00", nightTo: "07:00", nightMode: "dim", nightWake: true };
/** The night in words: "22:00–07:00, dimmed". */
function nightWords(n: WallDisplay["night"]): string {
if (!n) return t("none");
return `${n.from}–${n.to}, ${n.mode === "dim" ? t("dimmed") : t("blank")}${n.wakeOnCritical ? "" : ` · ${t("even if something is critical")}`}`;
}
/** What a display shows, in words: "every page", or the pages it lists. */
function pagesWords(pages: string[]): string {
@@ -36,7 +48,7 @@ export default function WallDisplays({ displays, onChanged }: { displays: WallDi
const choices = displayPageChoices();
function edit(d: WallDisplay) {
setDraft({ id: d.id, name: d.name, slug: d.slug, pages: d.pages, rotateSeconds: d.rotateSeconds });
setDraft({ id: d.id, name: d.name, slug: d.slug, pages: d.pages, rotateSeconds: d.rotateSeconds, night: d.night !== null, nightFrom: d.night?.from ?? "22:00", nightTo: d.night?.to ?? "07:00", nightMode: d.night?.mode ?? "dim", nightWake: d.night?.wakeOnCritical ?? true });
setError(null);
}
@@ -54,7 +66,7 @@ export default function WallDisplays({ displays, onChanged }: { displays: WallDi
setBusy(true);
setError(null);
try {
const input = { name: draft.name.trim(), slug: draft.slug.trim() || undefined, pages: draft.pages, rotateSeconds: draft.rotateSeconds };
const input = { name: draft.name.trim(), slug: draft.slug.trim() || undefined, pages: draft.pages, rotateSeconds: draft.rotateSeconds, night: draft.night ? { from: draft.nightFrom, to: draft.nightTo, mode: draft.nightMode, wakeOnCritical: draft.nightWake } : null };
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."));
@@ -139,8 +151,48 @@ export default function WallDisplays({ displays, onChanged }: { displays: WallDi
{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">
<label className="form-check mb-2">
<input type="checkbox" className="form-check-input" checked={draft.night} onChange={(e) => setDraft({ ...draft, night: e.target.checked })} />
<span className="form-check-label">{t("Dim or blank it at night")}</span>
</label>
{draft.night && (
<div className="row g-3 ms-1">
<div className="col-sm-3 col-md-2">
<label className="form-label" htmlFor="wd-from">
{t("From")}
</label>
<input id="wd-from" type="time" className="form-control" required value={draft.nightFrom} onChange={(e) => setDraft({ ...draft, nightFrom: e.target.value })} />
</div>
<div className="col-sm-3 col-md-2">
<label className="form-label" htmlFor="wd-to">
{t("To")}
</label>
<input id="wd-to" type="time" className="form-control" required value={draft.nightTo} onChange={(e) => setDraft({ ...draft, nightTo: e.target.value })} />
</div>
<div className="col-sm-6 col-md-4">
<label className="form-label" htmlFor="wd-nightmode">
{t("At night")}
</label>
<select id="wd-nightmode" className="form-select" value={draft.nightMode} onChange={(e) => setDraft({ ...draft, nightMode: e.target.value as "dim" | "off" })}>
<option value="dim">{t("Dim the board")}</option>
<option value="off">{t("Blank the screen (the device may sleep)")}</option>
</select>
</div>
<div className="col-12">
<label className="form-check mb-1">
<input type="checkbox" className="form-check-input" checked={draft.nightWake} onChange={(e) => setDraft({ ...draft, nightWake: e.target.checked })} />
<span className="form-check-label">{t("Show the board again while something is critical")}</span>
</label>
<div className="form-hint text-secondary small">
{t("By the clock of the screen itself, every day; an end earlier than the start runs past midnight. A page that cannot switch a TV off can only dim the picture or show black — a blank screen lets a tablet or a computer go to sleep, and a touch or a key brings the board back for two minutes.")}
</div>
</div>
</div>
)}
</div>
<div className="col-12 d-flex gap-2">
<button type="submit" className="btn btn-primary" disabled={busy || draft.name.trim() === ""}>
<button type="submit" className="btn btn-primary" disabled={busy || draft.name.trim() === "" || (draft.night && draft.nightFrom === draft.nightTo)}>
{busy ? t("Saving…") : t("Save")}
</button>
<button type="button" className="btn" onClick={() => setDraft(null)}>
@@ -159,6 +211,7 @@ export default function WallDisplays({ displays, onChanged }: { displays: WallDi
<th>{t("Address")}</th>
<th>{t("Pages")}</th>
<th>{t("Rotates")}</th>
<th>{t("Night")}</th>
<th className="w-1">{t("Actions")}</th>
</tr>
</thead>
@@ -174,6 +227,7 @@ export default function WallDisplays({ displays, onChanged }: { displays: WallDi
</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 className="text-secondary">{nightWords(d.night)}</td>
<td>
<div className="btn-list flex-nowrap">
<button type="button" className="btn btn-sm" onClick={() => edit(d)}>
+23 -7
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 { applyDisplay, groupMembers, pageOrOverview, ROTATE_CHOICES, stepPage, wallPages } from "../utils/wallPages";
import { applyDisplay, groupMembers, nightState, pageOrOverview, ROTATE_CHOICES, stepPage, WAKE_FOR_MS, wallPages, type WallNight } from "../utils/wallPages";
import { t } from "../i18n";
export const REFRESH_MS = 30_000;
@@ -82,9 +82,10 @@ function useClock(): Date {
return now;
}
/** Keeps the screen awake while the page is open, where the browser allows it. */
function useWakeLock() {
/** Keeps the screen awake while the page is open, where the browser allows it — and lets go while `enabled` is false (a blank night screen, so the device may sleep). */
function useWakeLock(enabled = true) {
useEffect(() => {
if (!enabled) return;
let lock: { release: () => Promise<void> } | null = null;
let gone = false;
const request = async () => {
@@ -103,7 +104,7 @@ function useWakeLock() {
document.removeEventListener("visibilitychange", onVisible);
void lock?.release().catch(() => {});
};
}, []);
}, [enabled]);
}
/**
@@ -121,12 +122,26 @@ export default function WallView({
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;
display?: { name: string; pages: string[]; night?: WallNight | null } | 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 };
}) {
const now = useClock();
useWakeLock();
// The night: dimmed or blank by the screen's own clock, unless something is critical (and the schedule says to show it) or somebody has just touched the screen.
const [wokenUntil, setWokenUntil] = useState<number | null>(null);
const night = nightState(now, display?.night, { critical: data.level === "critical", wokenUntil });
useWakeLock(night !== "off");
useEffect(() => {
if (!display?.night) return;
const wake = () => setWokenUntil(Date.now() + WAKE_FOR_MS);
window.addEventListener("pointerdown", wake);
window.addEventListener("keydown", wake);
return () => {
window.removeEventListener("pointerdown", wake);
window.removeEventListener("keydown", wake);
};
}, [display?.night]);
// The pages: the overview, what needs attention (while something does), and one for each group of integrations.
const rotating = !!rotation && rotation.seconds !== null;
@@ -162,7 +177,8 @@ export default function WallView({
const showsDetail = data.problems !== null || data.windows !== null || data.integrations !== null;
return (
<div className={`wall ${idle ? "wall-idle" : ""}`} data-bs-theme="dark">
<div className={`wall ${idle ? "wall-idle" : ""} ${night !== "day" ? `wall-night-${night}` : ""}`} data-bs-theme="dark" aria-hidden={night === "off" ? true : undefined}>
{night === "off" && <div className="wall-night-note">{t("Night — touch the screen to wake it")}</div>}
<header className="wall-header">
<img src="/logo.webp" alt="Homelab Manager" width={901} height={460} className="wall-logo" />
{data.environmentName && <span className="badge env-badge">{data.environmentName}</span>}
+14
View File
@@ -140,6 +140,7 @@ export const sv: Record<string, string> = {
"Apply this server's updates through a Semaphore playbook": "Installera serverns uppdateringar via en Semaphore-playbook",
"approved in Semaphore": "godkänd i Semaphore",
"Apps": "Appar",
"At night": "På natten",
"Automation": "Automation",
"Awaiting reply": "Väntar på svar",
"Awake again.": "Vaken igen.",
@@ -153,10 +154,13 @@ export const sv: Record<string, string> = {
"Belongs to": "Tillhör",
"between {low} and {high}": "mellan {low} och {high}",
"Between 5 and 500.": "Mellan 5 och 500.",
"blank": "svart",
"Blank the screen (the device may sleep)": "Släck skärmen (enheten får sova)",
"Blocking is switched off.": "Blockering är avstängd.",
"Bound to localhost only — other machines can't connect, but the port is still taken": "Bunden bara till localhost — andra maskiner kan inte ansluta, men porten är ändå upptagen",
"breadcrumb": "sökväg",
"by {name}": "av {name}",
"By the clock of the screen itself, every day; an end earlier than the start runs past midnight. A page that cannot switch a TV off can only dim the picture or show black — a blank screen lets a tablet or a computer go to sleep, and a touch or a key brings the board back for two minutes.": "Efter skärmens egen klocka, varje dag; ett slut som är tidigare än starten går förbi midnatt. En sida kan inte stänga av en TV, bara dämpa bilden eller visa svart — en svart skärm låter en surfplatta eller dator gå i vila, och en tryckning eller tangent tar tillbaka tavlan i två minuter.",
"Can’t be read": "Kan inte läsas",
"Cancel": "Avbryt",
"Cards": "Kort",
@@ -216,6 +220,9 @@ export const sv: Record<string, string> = {
"Description": "Beskrivning",
"Details": "Detaljer",
"didn't finish": "blev inte klar",
"Dim or blank it at night": "Dämpa eller släck den på natten",
"Dim the board": "Dämpa tavlan",
"dimmed": "dämpad",
"Disable": "Stäng av",
"Disabled": "Avstängd",
"Disk": "Disk",
@@ -246,6 +253,7 @@ export const sv: Record<string, string> = {
"Ends": "Slutar",
"Ends in": "Slutar om",
"Enter a value": "Ange ett värde",
"even if something is critical": "även om något är kritiskt",
"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.",
@@ -273,6 +281,7 @@ export const sv: Record<string, string> = {
"First port": "Första port",
"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": "Från",
"From now": "Från nu",
"full in about {n} days": "full om cirka {n} dagar",
"Full screen": "Helskärm",
@@ -399,6 +408,8 @@ export const sv: Record<string, string> = {
"Next →": "Nästa →",
"Next run": "Nästa körning",
"Next to expire:": "Nästa som löper ut:",
"Night": "Natt",
"Night — touch the screen to wake it": "Natt — rör vid skärmen för att väcka den",
"No active alerts, but some checks couldn't run": "Inga aktiva larm, men vissa kontroller kunde inte köras",
"No active alerts.": "Inga aktiva larm.",
"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.",
@@ -428,6 +439,7 @@ export const sv: Record<string, string> = {
"No templates found in Semaphore.": "Inga mallar hittades i Semaphore.",
"Nobody in particular": "Ingen särskild",
"Nobody is on it": "Ingen jobbar med det",
"none": "ingen",
"Normal": "Normal",
"Not a VM? Hide this": "Ingen VM? Dölj det här",
"Not checked yet": "Inte kontrollerad än",
@@ -602,6 +614,7 @@ export const sv: Record<string, string> = {
"Show servers that are": "Visa servrar som är",
"Show silenced": "Visa tystade",
"Show silenced and grouped": "Visa tystade och grupperade",
"Show the board again while something is critical": "Visa tavlan igen medan något är kritiskt",
"Show the history": "Visa historiken",
"Shutdown": "Stäng av",
"Sign in with Authentik": "Logga in med Authentik",
@@ -671,6 +684,7 @@ export const sv: Record<string, string> = {
"Time in total": "Tid totalt",
"Time range": "Tidsperiod",
"Title": "Titel",
"To": "Till",
"To do": "Att göra",
"Today": "Idag",
"Toggle navigation": "Visa eller dölj menyn",
+1 -1
View File
@@ -107,7 +107,7 @@ export default function SharedWall() {
<WallView
data={data}
idle={idle}
display={displayConfig ? { name: displayConfig.name, pages: displayConfig.pages } : null}
display={displayConfig ? { name: displayConfig.name, pages: displayConfig.pages, night: displayConfig.night } : null}
rotation={{ seconds: rotation.seconds, onChange: rotation.setSeconds }}
footerActions={
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
+1 -1
View File
@@ -104,7 +104,7 @@ 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}
display={display ? { name: display.name, pages: display.pages, night: display.night } : slug && displays !== null ? { name: t("No display called “{slug}” — showing everything", { slug }), pages: [] } : null}
rotation={{ seconds: rotation.seconds, onChange: rotation.setSeconds }}
footerActions={
<>
+23
View File
@@ -2354,3 +2354,26 @@ select,
.sparkline-orange { --sparkline-color: var(--tblr-orange); }
.sparkline-red { --sparkline-color: var(--tblr-red); }
.sparkline-secondary { --sparkline-color: var(--tblr-secondary); }
/* ── A wall display at night (named displays, night schedule): dimmed, or blank so the screen can sleep ── */
.wall-night-dim {
filter: brightness(0.28) saturate(0.7);
}
.wall-night-off {
background: #000;
cursor: none;
}
.wall-night-off > :not(.wall-night-note) {
visibility: hidden;
}
.wall-night-note {
position: fixed;
inset: auto 0 1.5rem 0;
text-align: center;
font-size: 0.9rem;
color: #e6edf7;
opacity: 0.18;
}
+39
View File
@@ -1,5 +1,6 @@
import type { IntegrationType } from "../api/client";
import { groupOfType, TYPE_GROUPS } from "./integrationTypes";
import { } from "../i18n";
/** One screen of the rotating wall display: the overview, the list of what needs attention, or one group of integrations. */
export interface WallPage {
@@ -16,6 +17,44 @@ export interface WallPagesInput {
integrations: { type: string }[] | null;
}
/** A night schedule: from this time to that on the screen's own clock (past midnight when `to` is earlier), the board is dimmed, or blanked so the screen can sleep. */
export interface WallNight {
from: string;
to: string;
mode: "dim" | "off";
/** Show the board again, whatever the hour, while something is critical. */
wakeOnCritical: boolean;
}
export type NightState = "day" | "dim" | "off";
/** How long a touch or a key press brings the board back at night. */
export const WAKE_FOR_MS = 2 * 60_000;
const minutesOf = (hhmm: string): number => {
const [h, m] = hhmm.split(":").map(Number);
return h * 60 + m;
};
/** Pure: whether a moment (by the clock of the Date it is given, which is the screen's) falls in the night: from the start up to, not including, the end — and across midnight when the end is earlier. */
export function inNight(now: Date, night: Pick<WallNight, "from" | "to">): boolean {
const t = now.getHours() * 60 + now.getMinutes();
const from = minutesOf(night.from);
const to = minutesOf(night.to);
if (from === to) return false;
return from < to ? t >= from && t < to : t >= from || t < to;
}
/**
* Pure: what the board should look like now. The day, unless it is night; and at night, unless something is critical and the schedule says to show the board then, or somebody touched the
* screen a little while ago (`wokenUntil`, epoch ms). Otherwise the night's way: dimmed, or blank.
*/
export function nightState(now: Date, night: WallNight | null | undefined, opts: { critical: boolean; wokenUntil: number | null }): NightState {
if (!night || !inNight(now, night)) return "day";
if (night.wakeOnCritical && opts.critical) return "day";
if (opts.wokenUntil !== null && opts.wokenUntil > now.getTime()) return "day";
return night.mode;
}
/** The longest and shortest a page may stay, in seconds. */
export const ROTATE_MIN = 10;
export const ROTATE_MAX = 600;