Accessibility pass, command palette actions, row detail panel, server activity, map, wall display and setup guide
Accessibility: skip link, labelled landmarks, visible focus, page-change announcements, sortable headings as real buttons, every label tied to its field, named row checkboxes, and text contrast raised to 4.5:1 in both themes. Command palette: also runs actions (silence/end maintenance, theme, density, wall display, sign out) and is a proper dialog; g-then-letter shortcuts, "/" and "?". Row detail panel for six tables. Server Activity card, with the health check now recording offline/back-online and disk events in the audit log. Map page of hosts, servers, DNS names and monitors. Full-screen wall display. A getting-started checklist on the admin dashboard. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7f5e1cd41
commit
57fd4f8c52
36 files changed
+2790
-210
No files matched your search
+65
-151
@@ -1,42 +1,8 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { Link, NavLink, useLocation } from "react-router-dom";
|
||||
import {
|
||||
IconLayoutDashboard,
|
||||
IconServer2,
|
||||
IconWorld,
|
||||
IconNetwork,
|
||||
IconKey,
|
||||
IconPlugConnected,
|
||||
IconBrandDocker,
|
||||
IconAffiliate,
|
||||
IconPlayerPlay,
|
||||
IconBrandGit,
|
||||
IconServerCog,
|
||||
IconDatabase,
|
||||
IconUsers,
|
||||
IconDevices,
|
||||
IconHistory,
|
||||
IconStethoscope,
|
||||
IconSettings,
|
||||
IconMenu2,
|
||||
IconSun,
|
||||
IconMoon,
|
||||
IconWand,
|
||||
IconTool,
|
||||
IconWorldWww,
|
||||
IconListCheck,
|
||||
IconShieldLock,
|
||||
IconRefresh,
|
||||
IconActivityHeartbeat,
|
||||
IconShieldCheck,
|
||||
IconTicket,
|
||||
IconPlug,
|
||||
IconExternalLink,
|
||||
IconAlertTriangle,
|
||||
IconChevronUp,
|
||||
IconLogout,
|
||||
} from "@tabler/icons-react";
|
||||
import { IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop } from "@tabler/icons-react";
|
||||
import { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
|
||||
import { isCurrent, isGroup, visibleNav, type NavGroup } from "./nav";
|
||||
import { formatRemaining } from "../utils/duration";
|
||||
import { getTheme, setTheme, type Theme } from "../utils/theme";
|
||||
import { DENSITIES, getDensity, setDensity, type Density } from "../utils/density";
|
||||
@@ -44,6 +10,9 @@ import CommandPalette from "../components/CommandPalette";
|
||||
import { isLightColor, useEnvironment } from "../utils/environment";
|
||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||
import { useStackedTables } from "../hooks/useStackedTables";
|
||||
import { useShortcuts } from "../hooks/useShortcuts";
|
||||
import { useFormLabels } from "../hooks/useFormLabels";
|
||||
import ShortcutHelp from "../components/ShortcutHelp";
|
||||
import { useBreadcrumbTailValue } from "../utils/breadcrumb";
|
||||
|
||||
interface NavBadge {
|
||||
@@ -58,110 +27,6 @@ function initialsOf(name: string): string {
|
||||
return (words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? "?").slice(0, 2)).toUpperCase();
|
||||
}
|
||||
|
||||
type Role = "operator" | "admin";
|
||||
|
||||
interface NavLeaf {
|
||||
to: string;
|
||||
label: string;
|
||||
/** Shown for top-level links, and when a group is left with a single visible page and so is drawn as that page's own link. */
|
||||
icon: ReactNode;
|
||||
minRole?: Role;
|
||||
}
|
||||
|
||||
interface NavGroup {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: ReactNode;
|
||||
items: NavLeaf[];
|
||||
}
|
||||
|
||||
type NavEntry = NavLeaf | NavGroup;
|
||||
|
||||
const isGroup = (entry: NavEntry): entry is NavGroup => "items" in entry;
|
||||
|
||||
const NAV: NavEntry[] = [
|
||||
{ to: "/", label: "Dashboard", icon: <IconLayoutDashboard size={20} /> },
|
||||
{
|
||||
id: "infrastructure",
|
||||
label: "Infrastructure",
|
||||
icon: <IconServer2 size={20} />,
|
||||
items: [
|
||||
{ to: "/servers", label: "Servers", icon: <IconServer2 size={20} /> },
|
||||
{ to: "/proxmox", label: "Proxmox", icon: <IconServerCog size={20} /> },
|
||||
{ to: "/synology", label: "Synology", icon: <IconDatabase size={20} /> },
|
||||
{ to: "/pbs", label: "Proxmox Backup", icon: <IconShieldCheck size={20} /> },
|
||||
{ to: "/docker", label: "Docker", icon: <IconBrandDocker size={20} /> },
|
||||
{ to: "/tailscale", label: "Tailscale", icon: <IconAffiliate size={20} /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "network",
|
||||
label: "Network",
|
||||
icon: <IconWorld size={20} />,
|
||||
items: [
|
||||
{ to: "/dns", label: "DNS", icon: <IconWorld size={20} /> },
|
||||
{ to: "/domains", label: "Domains", icon: <IconWorldWww size={20} /> },
|
||||
{ to: "/ipam", label: "IP Addresses", icon: <IconNetwork size={20} /> },
|
||||
{ to: "/ports", label: "Ports", icon: <IconPlug size={20} /> },
|
||||
{ to: "/consistency", label: "Consistency", icon: <IconListCheck size={20} /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "automation",
|
||||
label: "Automation",
|
||||
icon: <IconRefresh size={20} />,
|
||||
items: [
|
||||
{ to: "/semaphore", label: "Semaphore", icon: <IconPlayerPlay size={20} /> },
|
||||
{ to: "/gitea", label: "Gitea", icon: <IconBrandGit size={20} /> },
|
||||
],
|
||||
},
|
||||
{ to: "/secrets", label: "Secrets", icon: <IconKey size={20} /> },
|
||||
{
|
||||
id: "operations",
|
||||
label: "Operations",
|
||||
icon: <IconTool size={20} />,
|
||||
items: [
|
||||
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
|
||||
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
|
||||
{ to: "/uptime-kuma", label: "Uptime Kuma", icon: <IconActivityHeartbeat size={20} /> },
|
||||
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
|
||||
{ to: "/admin-links", label: "Admin Links", icon: <IconExternalLink size={20} /> },
|
||||
{ to: "/generator", label: "Generator", icon: <IconWand size={20} /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "administration",
|
||||
label: "Administration",
|
||||
icon: <IconSettings size={20} />,
|
||||
items: [
|
||||
{ to: "/integrations", label: "Integrations", icon: <IconPlugConnected size={20} /> },
|
||||
{ to: "/users", label: "Users", icon: <IconUsers size={20} />, minRole: "admin" },
|
||||
{ to: "/sessions", label: "Sessions", icon: <IconDevices size={20} />, minRole: "admin" },
|
||||
{ to: "/audit-log", label: "Audit Log", icon: <IconHistory size={20} />, minRole: "operator" },
|
||||
{ to: "/diag-log", label: "Diagnostic Log", icon: <IconStethoscope size={20} />, minRole: "admin" },
|
||||
{ to: "/settings", label: "Settings", icon: <IconSettings size={20} />, minRole: "admin" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const roleRank: Record<CurrentUser["role"], number> = { viewer: 0, operator: 1, admin: 2 };
|
||||
|
||||
/** What this role can see: pages it isn't allowed are dropped, an emptied group disappears, and a group down to one page becomes that page's own link. */
|
||||
function visibleNav(role: CurrentUser["role"]): NavEntry[] {
|
||||
const allowed = (leaf: NavLeaf) => !leaf.minRole || roleRank[role] >= roleRank[leaf.minRole];
|
||||
const out: NavEntry[] = [];
|
||||
for (const entry of NAV) {
|
||||
if (!isGroup(entry)) {
|
||||
if (allowed(entry)) out.push(entry);
|
||||
continue;
|
||||
}
|
||||
const items = entry.items.filter(allowed);
|
||||
if (items.length === 1) out.push(items[0]);
|
||||
else if (items.length > 1) out.push({ ...entry, items });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const OPEN_GROUPS_KEY = "hlm-nav-open-groups";
|
||||
|
||||
function loadOpenGroups(): Set<string> {
|
||||
@@ -173,11 +38,6 @@ function loadOpenGroups(): Set<string> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Is this the current page (or a page beneath it, like /servers/3 under /servers)? */
|
||||
function isCurrent(pathname: string, to: string): boolean {
|
||||
return to === "/" ? pathname === "/" : pathname === to || pathname.startsWith(`${to}/`);
|
||||
}
|
||||
|
||||
export default function AppShell({ user, children }: { user: CurrentUser; children: ReactNode }) {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
const [theme, setThemeState] = useState<Theme>(() => getTheme());
|
||||
@@ -185,6 +45,11 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
|
||||
const environment = useEnvironment();
|
||||
useStackedTables();
|
||||
useShortcuts(user);
|
||||
useFormLabels();
|
||||
const mainRef = useRef<HTMLElement>(null);
|
||||
const [announcement, setAnnouncement] = useState("");
|
||||
const firstRoute = useRef(true);
|
||||
const breadcrumbTail = useBreadcrumbTailValue();
|
||||
const { report } = useAlertsReport();
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
@@ -228,6 +93,18 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
const nav = visibleNav(user.role);
|
||||
const { pathname } = useLocation();
|
||||
|
||||
// A page change in a single-page app is silent: tell screen readers where they are, and move the keyboard to the new page's start
|
||||
// (not on the first load, where the browser has already done its own thing).
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
const title = document.querySelector(".page-title")?.textContent?.trim() || document.title;
|
||||
setAnnouncement(title);
|
||||
if (!firstRoute.current) mainRef.current?.focus({ preventScroll: true });
|
||||
firstRoute.current = false;
|
||||
}, 200);
|
||||
return () => clearTimeout(timer);
|
||||
}, [pathname]);
|
||||
|
||||
// Where this page sits in the menu: "Infrastructure › Servers", and on a page about one thing, that thing's name as well.
|
||||
const crumbs: { label: string; to?: string }[] = [];
|
||||
for (const entry of nav) {
|
||||
@@ -285,7 +162,8 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
const b = badges[to];
|
||||
return b ? (
|
||||
<span className={`badge ms-auto ${b.className}`} title={b.title}>
|
||||
{b.text}
|
||||
<span aria-hidden="true">{b.text}</span>
|
||||
<span className="visually-hidden">{b.title}</span>
|
||||
</span>
|
||||
) : null;
|
||||
};
|
||||
@@ -298,7 +176,21 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<aside className="navbar navbar-vertical navbar-expand-lg" data-bs-theme={environment && isLightColor(environment.color) ? "light" : "dark"}>
|
||||
<a
|
||||
className="skip-link"
|
||||
href="#main"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
mainRef.current?.focus();
|
||||
}}
|
||||
>
|
||||
Skip to content
|
||||
</a>
|
||||
<div className="visually-hidden" role="status" aria-live="polite" aria-atomic="true">
|
||||
{announcement}
|
||||
</div>
|
||||
<ShortcutHelp />
|
||||
<aside aria-label="Homelab Manager" className="navbar navbar-vertical navbar-expand-lg" data-bs-theme={environment && isLightColor(environment.color) ? "light" : "dark"}>
|
||||
<div className="container-fluid">
|
||||
<button
|
||||
type="button"
|
||||
@@ -318,8 +210,16 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
</h1>
|
||||
<div className={`navbar-collapse collapse ${sidebarOpen ? "show" : ""}`}>
|
||||
<div className="px-3 pt-3 pt-lg-0">
|
||||
<CommandPalette />
|
||||
<CommandPalette
|
||||
user={user}
|
||||
onToggleTheme={toggleTheme}
|
||||
onSetDensity={(d) => {
|
||||
setDensity(d);
|
||||
setDensityState(d);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<nav aria-label="Main menu">
|
||||
<ul className="navbar-nav pt-lg-3">
|
||||
{nav.map((entry) => {
|
||||
if (!isGroup(entry)) {
|
||||
@@ -353,7 +253,8 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
const worst = inside.find((b) => b.className.includes("bg-red")) ?? inside.find((b) => b.className.includes("bg-yellow")) ?? inside[0];
|
||||
return (
|
||||
<span className={`badge ms-auto me-4 ${worst.className}`} title={inside.map((b) => b.title).join(", ")}>
|
||||
{inside.reduce((n, b) => n + Number(b.text), 0)}
|
||||
<span aria-hidden="true">{inside.reduce((n, b) => n + Number(b.text), 0)}</span>
|
||||
<span className="visually-hidden">{inside.map((b) => b.title).join(", ")}</span>
|
||||
</span>
|
||||
);
|
||||
})()}
|
||||
@@ -375,6 +276,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</nav>
|
||||
<div className="navbar-footer px-3 user-menu" ref={menuRef}>
|
||||
{menuOpen && (
|
||||
<div className="user-menu-list" role="menu">
|
||||
@@ -413,6 +315,18 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
<IconShieldLock size={16} />
|
||||
Privacy
|
||||
</NavLink>
|
||||
<NavLink
|
||||
to="/wall"
|
||||
className="user-menu-item"
|
||||
role="menuitem"
|
||||
onClick={() => {
|
||||
setMenuOpen(false);
|
||||
setSidebarOpen(false);
|
||||
}}
|
||||
>
|
||||
<IconDeviceDesktop size={16} />
|
||||
Wall display
|
||||
</NavLink>
|
||||
<a className="user-menu-item" role="menuitem" href="/auth/logout">
|
||||
<IconLogout size={16} />
|
||||
Sign out
|
||||
@@ -440,7 +354,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
</aside>
|
||||
|
||||
<div className="page-wrapper">
|
||||
<div className="page-body">
|
||||
<main className="page-body" id="main" tabIndex={-1} ref={mainRef}>
|
||||
<div className="container-xl">
|
||||
{maintenance.length > 0 && (
|
||||
<div className="alert alert-warning d-flex align-items-center gap-2">
|
||||
@@ -465,7 +379,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user