diff --git a/README.md b/README.md index 54209b7..001f8fd 100644 --- a/README.md +++ b/README.md @@ -950,6 +950,8 @@ switched by `?view=`, so a section can be linked to: an alert about a failing se **The status strip.** Under a server's name, on every section of its page, a row of figures says how it is at a glance: **Status** (online, with when it last reported — or *offline*, with when it did, and a note when Proxmox says the guest is still running, so a stopped agent is not read as a dead machine; for a server with no agent report, what Proxmox says, or that nothing has reported), **Maintenance** (only while a window on this server is on, with when it ends and why), **Alerts** (how many are open about this server and how bad — what a maintenance window, a snooze or a closing has put aside is not counted, but said — and a link to the Alerts page), **Updates** (what is waiting, how many of them security fixes, whether a reboot is needed), **Disk** (the fullest, against its own limit: green, yellow within ten points of it, red at it; a mount with its own limit is judged by that, and an ignored mount is left out), **CPU · memory** and **how long it has run** (for a guest Proxmox reads, or from an agent of version 8 on Linux, 7 on Windows, which say it in every report; left out while the server is offline, since it is then no longer how long it has been up). A figure nothing is known for is left out or says so — it is never filled in. It uses what the page already has plus the alerts and the maintenance windows, read again whenever the page is (the *Refresh* button). Everyone signed in sees it. +**Brand colours and logos.** Every kind of integration and DNS provider has its brand's colour and, where the open icon set [Simple Icons](https://simpleicons.org) (CC0) has one, its logo — Proxmox, Synology, Tailscale, Gitea, Jellyfin, Immich, Nextcloud, Grafana, Prometheus, Home Assistant, Sonarr, Radarr, qBittorrent, Hetzner, Cloudflare, Pi-hole and more. The kind **tags** on the Integrations page (cards and table), the Servers page and the DNS page are in that colour with the logo, made readable on the light and the dark theme alike (the lightness is held where the text reads, the hue kept; every tag is at least 4.9:1 on dark and 5.2:1 on light); the dashboard's integration cards have the logo beside their title; the kind picker has it on each choice; and **the menu** has a small icon before each page in its groups — the logo for an integration's page, the page's own icon for the rest — which **Settings → Display → Menu → Show an icon before each page** switches off for this browser. A few kinds have no open logo (NetBox, Prowlarr, Lidarr, Readarr, SABnzbd, Technitium, osTicket, phpIPAM, Fragnet, Dockhand, Semaphore, UPS): they keep their generic icon and an approximate colour. **Settings → Display → Badge colours** shows each tag as it looks now, lets you choose another colour for any of them, and **Use the brand's** goes back. Logos and names belong to their owners and are used only to tell the systems apart. + **Shorter page introductions.** The few lines under a page’s title that say what the page is are folded to two lines when they are longer than that, with **Show more** under them, so the page’s own content starts higher up. What you choose is remembered for that page in this browser; a short one is shown as it is, a link inside the folded part opens it when you tab to it, and a printout shows all of it. **Notification history.** Records → Notifications lists every notification that was sent, with how it went through each channel (or why it was not sent: held for quiet hours, a routing rule said nobody, no channel switched on), the error a channel gave when it refused, a filter and a search, and **Send again**. Kept 30 days. See NOTIFICATIONS.md. diff --git a/package-lock.json b/package-lock.json index d0ee055..58e267c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4206,6 +4206,25 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "license": "ISC" }, + "node_modules/simple-icons": { + "version": "16.37.0", + "resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-16.37.0.tgz", + "integrity": "sha512-8mCJIhpMYOL9g13GW59EiL3sVXJnTEKGCTZFaekl9UQ3Qo0SwVjnLaJ82QiaH8BKBdouEDzrHMXIWh8cBIy48A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/simple-icons" + }, + { + "type": "github", + "url": "https://github.com/sponsors/simple-icons" + } + ], + "license": "CC0-1.0", + "engines": { + "node": ">=0.12.18" + } + }, "node_modules/socket.io": { "version": "4.8.4", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.4.tgz", @@ -5183,7 +5202,8 @@ "qrcode-generator": "^2.0.4", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-router-dom": "^7.1.1" + "react-router-dom": "^7.1.1", + "simple-icons": "^16.37.0" }, "devDependencies": { "@types/react": "^18.3.18", diff --git a/server/test/brands.test.ts b/server/test/brands.test.ts new file mode 100644 index 0000000..b444f43 --- /dev/null +++ b/server/test/brands.test.ts @@ -0,0 +1,157 @@ +/** + * Brand colours and logos for the kinds of integration and DNS providers: every kind has a colour that is a real colour, the logos that exist are paths that can be drawn, a card's label says which kind + * it is about, going back to a brand's colour is saved in a way the settings can keep, and the menu and the tags use them. + * + * Run with: npm test --workspace server + */ +import { test, describe, before, after } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { AddressInfo } from "node:net"; +import type { Server } from "node:http"; + +const dir = mkdtempSync(join(tmpdir(), "hm-brands-")); +process.env.DATABASE_PATH = join(dir, "test.sqlite"); +process.env.SESSION_DIR = join(dir, "sessions"); +process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32); + +const express = (await import("express")).default; +const { db } = await import("../src/db/client.js"); +const { users } = await import("../src/db/schema.js"); +const { runMigrations } = await import("../src/db/migrate.js"); +const { settingsRouter } = await import("../src/routes/settings.js"); +const b = await import("../../web/src/utils/brands.js"); +const { TYPE_LABELS, TYPE_PAGES } = await import("../../web/src/utils/integrationTypes.js"); + +await runMigrations(); + +const web = (...parts: string[]) => readFileSync(join(import.meta.dirname, "..", "..", "web", "src", ...parts), "utf8"); +const PROVIDERS = ["cloudflare", "loopia", "pihole", "azure", "cpanel", "technitium"]; + +describe("the table", () => { + test("every kind of integration has a colour, and a logo is a path that can be drawn", () => { + for (const kind of Object.keys(TYPE_LABELS)) { + const brand = (b.KIND_BRANDS as Record)[kind]; + assert.ok(brand, `${kind} has no brand`); + assert.match(brand.color, /^#[0-9a-f]{6}$/, kind); + if (brand.path !== null) assert.match(brand.path, /^M[\d.\- ,a-zA-Z]+$/, `${kind}'s logo is not a path`); + } + assert.equal(Object.keys(b.KIND_BRANDS).length, Object.keys(TYPE_LABELS).length, "no brand for a kind that does not exist"); + }); + + test("every DNS provider has one too", () => { + for (const p of PROVIDERS) assert.match((b.PROVIDER_BRANDS as Record)[p].color, /^#[0-9a-f]{6}$/, p); + assert.equal(Object.keys(b.PROVIDER_BRANDS).length, PROVIDERS.length); + }); + + test("the well-known ones have their logo, and the few the open set lacks keep their generic icon", () => { + for (const k of ["proxmox", "synology", "tailscale", "gitea", "jellyfin", "immich", "nextcloud", "grafana", "prometheus", "homeassistant", "sonarr", "radarr", "qbittorrent", "hetzner", "cloudflare", "pihole"]) assert.ok(b.brandOf(k)?.path, `${k} has a logo`); + for (const k of ["netbox", "prowlarr", "lidarr", "readarr", "sabnzbd", "technitium", "osticket", "phpipam", "fragnet", "dockhand", "semaphore", "ups", "azure", "loopia"]) assert.equal(b.brandOf(k)?.path, null, `${k} has none`); + }); + + test("a kind that shares a brand shares its colour (Hetzner Cloud and Robot, Proxmox and its Backup Server)", () => { + assert.equal(b.brandOf("hetzner")?.color, b.brandOf("hetznerrobot")?.color); + assert.equal(b.brandOf("proxmox")?.color, b.brandOf("pbs")?.color); + assert.equal(b.PROVIDER_BRANDS.technitium.color, b.KIND_BRANDS.technitium.color); + }); + + test("something that is no kind has no brand", () => { + assert.equal(b.brandOf("martian"), null); + assert.equal(b.brandOf(""), null); + }); +}); + +describe("what the page's helpers say", () => { + test("a card's label says which kind it is about, with or without the name of the one integration", () => { + assert.equal(b.kindOfLabel("Jellyfin"), "jellyfin"); + assert.equal(b.kindOfLabel("Jellyfin: Media"), "jellyfin"); + assert.equal(b.kindOfLabel("Hetzner Cloud: Projekt 1"), "hetzner"); + assert.equal(b.kindOfLabel("Technitium DNS"), "technitium"); + assert.equal(b.kindOfLabel("Servers down"), null); + assert.equal(b.kindOfLabel(""), null); + }); + + test("a colour is #rrggbb and nothing else — an empty one is 'none chosen'", () => { + for (const ok of ["#00a4dc", "#FFFFFF"]) assert.equal(b.isHexColor(ok), true, ok); + for (const bad of ["", "00a4dc", "#abc", "#12345g", "red", null, undefined, 5]) assert.equal(b.isHexColor(bad), false, String(bad)); + }); +}); + +describe("going back to a brand's colour is kept", () => { + let app: Server; + let base = ""; + before(async () => { + await db.insert(users).values({ oidcSub: "admin", name: "Ada", role: "admin" }); + const a = express(); + a.use(express.json()); + a.use((req, _res, next) => { + (req as unknown as { session: unknown }).session = { user: { sub: "admin" } }; + next(); + }); + a.use("/api/settings", settingsRouter); + app = await new Promise((resolve) => { + const s = a.listen(0, "127.0.0.1", () => resolve(s)); + }); + base = `http://127.0.0.1:${(app.address() as AddressInfo).port}/api/settings`; + }); + after(() => { + app.close(); + try { + rmSync(dir, { recursive: true, force: true }); + } catch { + // Windows keeps the database file locked until the process exits. + } + }); + const put = (body: unknown) => fetch(base, { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }); + const colors = async () => ((await (await fetch(`${base}/integration-colors`)).json()) as { integrationColors: Record }).integrationColors; + + test("a colour is chosen, and given up by saving an empty one (the settings merge key by key, so a key cannot be taken away)", async () => { + assert.equal((await put({ integrationColors: { proxmox: "#112233", jellyfin: "#445566" } })).status, 200); + assert.deepEqual(await colors(), { proxmox: "#112233", jellyfin: "#445566" }); + assert.equal((await put({ integrationColors: { proxmox: "" } })).status, 200); + const now = await colors(); + assert.equal(b.isHexColor(now.proxmox), false, "an empty one is none chosen, so the brand's is used"); + assert.equal(now.jellyfin, "#445566", "the others are as they were"); + }); +}); + +describe("where they are used", () => { + test("the Integrations page, the Servers page and the DNS page draw their tags with the brand tag, and no page is left with the old plain style", () => { + for (const f of ["Integrations.tsx", "Servers.tsx", "Dns.tsx"]) { + const s = web("pages", f); + assert.match(s, / { + const nav = web("layout", "nav.tsx"); + assert.match(nav, /export const NAV: NavEntry\[\] = withLogos\(PLAIN_NAV\)/); + assert.match(nav, /kinds\?\.length === 1 && hasLogo\(kinds\[0\]\)/); + // a page of several kinds (Media managers, Download clients) stays generic + assert.ok((nav.match(/PAGE_KINDS\[/g) ?? []).length >= 1); + assert.equal((TYPE_PAGES as Record).sonarr, (TYPE_PAGES as Record).radarr, "they share a page, so it has no single logo"); + }); + + test("the menu's groups show an icon before each page, switched off per browser by an attribute on the page, and the dashboard cards and kind picker carry the logos", () => { + assert.match(web("layout", "SidebarNav.tsx"), /className="menu-item-icon"[\s\S]*?\{leaf\.icon\}/); + const css = web("styles.css"); + assert.match(css, /html\[data-menu-icons="off"\] \.dropdown-item \.menu-item-icon\s*\{\s*display:\s*none/); + assert.match(web("main.tsx"), /applyStoredMenuIcons\(\)/); + assert.match(web("utils", "menuIcons.ts"), /data-menu-icons/); + assert.match(web("pages", "Dashboard.tsx"), /kindOfLabel\(label\)/); + assert.match(web("components", "IntegrationTypePicker.tsx"), / { + const css = web("styles.css"); + assert.match(css, /\.badge\.brand-tag\s*\{[\s\S]*?color-mix\(in srgb, var\(--b\) \d+%, black\)/); + assert.match(css, /\[data-bs-theme="dark"\] \.badge\.brand-tag\s*\{[\s\S]*?color-mix\(in srgb, var\(--b\) \d+%, white\)/); + assert.match(css, /\.brand-fg\s*\{[\s\S]*?black\)/); + // and where the browser can hold the lightness, it does: no darker than 0.48 on the light theme, no lighter than 0.76 on the dark one + assert.match(css, /@supports \(color: oklch\(from red l c h\)\)[\s\S]*?min\(l, 0\.48\)[\s\S]*?max\(l, 0\.76\)/); + }); +}); diff --git a/web/package.json b/web/package.json index f49dec1..2a8942a 100644 --- a/web/package.json +++ b/web/package.json @@ -16,7 +16,8 @@ "qrcode-generator": "^2.0.4", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-router-dom": "^7.1.1" + "react-router-dom": "^7.1.1", + "simple-icons": "^16.37.0" }, "devDependencies": { "@types/react": "^18.3.18", diff --git a/web/src/components/BrandIcon.tsx b/web/src/components/BrandIcon.tsx new file mode 100644 index 0000000..18c377f --- /dev/null +++ b/web/src/components/BrandIcon.tsx @@ -0,0 +1,90 @@ +import type { CSSProperties, ReactNode } from "react"; +import { + IconBatteryCharging, + IconBinaryTree, + IconBrandDocker, + IconCloud, + IconCloudDownload, + IconDeviceGamepad2, + IconDeviceTv, + IconNetwork, + IconPlayerPlay, + IconPlugConnected, + IconTicket, + IconWorld, + IconWorldWww, +} from "@tabler/icons-react"; +import { brandOf, isHexColor } from "../utils/brands"; +import { TYPE_LABELS } from "../utils/integrationTypes"; + +/** For a brand the icon set does not have: the generic icon the menu already used for it. */ +const FALLBACK: Record = { + semaphore: IconPlayerPlay, + dockhand: IconBrandDocker, + phpipam: IconNetwork, + osticket: IconTicket, + ups: IconBatteryCharging, + netbox: IconBinaryTree, + fragnet: IconDeviceGamepad2, + prowlarr: IconDeviceTv, + lidarr: IconDeviceTv, + readarr: IconDeviceTv, + technitium: IconWorldWww, + sabnzbd: IconCloudDownload, + azure: IconCloud, + loopia: IconWorld, +}; + +/** Whether there is a real logo for it (as against the generic icon). */ +export const hasLogo = (kind: string): boolean => !!brandOf(kind)?.path; + +/** + * The logo of a kind of integration or DNS provider, or its generic icon when there is no logo. In the brand's colour — made readable on the light or the dark theme by the style sheet (.brand-fg) — + * unless `mono`, where it takes the colour of the text around it (the menu), or `color` says one (a colour somebody chose). + */ +export default function BrandIcon({ kind, size = 16, mono = false, color, title }: { kind: string; size?: number; mono?: boolean; color?: string | null; title?: string }) { + const brand = brandOf(kind); + const chosen = isHexColor(color) ? color : null; + const tint: { className?: string; style?: CSSProperties } = mono ? {} : chosen ? { style: { color: chosen } } : brand ? { className: "brand-fg", style: { "--b": brand.color } as CSSProperties } : {}; + if (brand?.path) { + return ( + + + + ); + } + const Generic = FALLBACK[kind] ?? IconPlugConnected; + return ( + + + + ); +} + +/** + * A tag for a kind of integration or provider: its logo and its name, in its brand colour — or in the colour somebody chose in Settings → Display → Badges, which is used as it is. A kind with no + * brand at all is a plain grey tag. + */ +export function BrandTag({ kind, label, custom, className = "", children }: { kind: string; label?: string; custom?: string | null; className?: string; children?: ReactNode }) { + const text = label ?? (TYPE_LABELS as Record)[kind] ?? kind; + const brand = brandOf(kind); + const chosen = isHexColor(custom) ? custom : null; + if (chosen) { + return ( + + + {text} + {children} + + ); + } + if (!brand) return {text}{children}; + return ( + + + {text} + {children} + + ); +} + diff --git a/web/src/components/IntegrationTypePicker.tsx b/web/src/components/IntegrationTypePicker.tsx index 2f90628..b00b6ef 100644 --- a/web/src/components/IntegrationTypePicker.tsx +++ b/web/src/components/IntegrationTypePicker.tsx @@ -1,6 +1,7 @@ import { useState } from "react"; import type { IntegrationType } from "../api/client"; import { groupTypes, TYPE_LABELS } from "../utils/integrationTypes"; +import BrandIcon from "./BrandIcon"; /** * Chooses a kind of integration: the kinds in groups, as the sidebar groups their pages, with a box that narrows them by name or group ("net" finds NetBox and the Network group's). @@ -36,7 +37,8 @@ export default function IntegrationTypePicker({ available, value, onChange }: {
{g.label}
{g.types.map((t) => ( - ))} diff --git a/web/src/layout/SidebarNav.tsx b/web/src/layout/SidebarNav.tsx index 2f6369a..0651615 100644 --- a/web/src/layout/SidebarNav.tsx +++ b/web/src/layout/SidebarNav.tsx @@ -133,6 +133,9 @@ export default function SidebarNav({ const subRow = (leaf: NavLeaf) => (
`dropdown-item d-flex align-items-center ${isActive ? "active" : ""}`} onClick={onNavigate}> + {leaf.label} {badgeOf(leaf.to)} diff --git a/web/src/layout/nav.tsx b/web/src/layout/nav.tsx index f0ac78c..f4c7ed0 100644 --- a/web/src/layout/nav.tsx +++ b/web/src/layout/nav.tsx @@ -65,7 +65,8 @@ import { IconReportAnalytics, } from "@tabler/icons-react"; import type { CurrentUser } from "../api/client"; -import { isPageHidden } from "../utils/navVisibility"; +import { isPageHidden, PAGE_KINDS, pagePath } from "../utils/navVisibility"; +import BrandIcon, { hasLogo } from "../components/BrandIcon"; // The menu: what pages there are, how they are grouped, and which role is needed to see each. Used by the sidebar, the command // palette, the keyboard shortcuts and the breadcrumbs, so they always agree. @@ -91,7 +92,7 @@ export type NavEntry = NavLeaf | NavGroup; export const isGroup = (entry: NavEntry): entry is NavGroup => "items" in entry; -export const NAV: NavEntry[] = [ +const PLAIN_NAV: NavEntry[] = [ { to: "/", label: "Dashboard", icon: }, { to: "/alerts", label: "Alerts", icon: }, { to: "/my-work", label: "My work", icon: , minRole: "operator" }, @@ -223,6 +224,20 @@ export const NAV: NavEntry[] = [ }, ]; +/** + * The menu, with the logo of an integration where a page is about one kind of integration and the icon set has its logo (Proxmox, Jellyfin, Grafana …) in place of the generic icon. The logo takes + * the colour of the menu's text, like every other icon in it, so it does not turn the menu into a row of colours; the brand colours are in the tags on the Integrations page. + */ +function withLogos(entries: NavEntry[]): NavEntry[] { + const logo = (leaf: NavLeaf): NavLeaf => { + const kinds = PAGE_KINDS[pagePath(leaf.to)]; + return kinds?.length === 1 && hasLogo(kinds[0]) ? { ...leaf, icon: } : leaf; + }; + return entries.map((e) => (isGroup(e) ? { ...e, items: e.items.map(logo) } : logo(e))); +} + +export const NAV: NavEntry[] = withLogos(PLAIN_NAV); + const roleRank: Record = { viewer: 0, operator: 1, admin: 2 }; /** What this role can see: pages it isn't allowed are dropped, so are pages of integrations nobody has added when the Display setting says to leave those out, an emptied group disappears, and a group down to one page becomes that page's own link. */ diff --git a/web/src/main.tsx b/web/src/main.tsx index 8f0c155..e1bde98 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -6,10 +6,12 @@ import "@tabler/core/dist/css/tabler.min.css"; import "./styles.css"; import { loadEnvironment } from "./utils/environment"; import { applyStoredDensity } from "./utils/density"; +import { applyStoredMenuIcons } from "./utils/menuIcons"; // Dev and production can be told apart (ENVIRONMENT_NAME / ENVIRONMENT_COLOR on the server); do it before anything is drawn. void loadEnvironment(); applyStoredDensity(); +applyStoredMenuIcons(); // Production only — in dev the worker would just add another layer between Vite and the browser. if ("serviceWorker" in navigator && import.meta.env.PROD) { diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index 76d331a..e5a9dc0 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -29,6 +29,8 @@ import { ErrorNotice } from "../components/Notice"; import { WidgetSkeleton } from "../components/Skeleton"; import { TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes"; import type { Agenda, Heartbeat } from "../api/client"; +import BrandIcon from "../components/BrandIcon"; +import { kindOfLabel } from "../utils/brands"; const DNS_TYPE_COLORS: Record = { A: "#60a5fa", @@ -211,6 +213,7 @@ function WidgetCard({ label, badge, hide, children }: { label: string; badge?: R // rest follow the order they chose — a card nobody has placed goes last, in the order it was drawn. const hidden = layout.hidden.includes(label); const problem = problemOf(badge); + const kind = kindOfLabel(label); if (hidden && !editing) return null; return (
@@ -232,7 +235,10 @@ function WidgetCard({ label, badge, hide, children }: { label: string; badge?: R )}
-
{label}
+
+ {kind && } + {label} +
{badge &&
{badge}
}
{children} diff --git a/web/src/pages/Dns.tsx b/web/src/pages/Dns.tsx index bfa7b3e..6951d60 100644 --- a/web/src/pages/Dns.tsx +++ b/web/src/pages/Dns.tsx @@ -26,6 +26,7 @@ import { ErrorNotice } from "../components/Notice"; import { toast } from "../utils/toast"; import { readableError } from "../utils/errors"; import { EmptyRow, LoadingRow } from "../components/EmptyState"; +import { BrandTag } from "../components/BrandIcon"; const PROVIDER_LABELS: Record = { cloudflare: "Cloudflare", @@ -38,12 +39,6 @@ const PROVIDER_LABELS: Record = { const emptyRecordForm: DnsRecordInput = { type: "A", name: "", content: "", ttl: 3600, priority: undefined, proxied: undefined }; -function providerBadgeStyle(colors: Record, providerType: DnsProviderType): CSSProperties { - const color = colors[providerType]; - if (!color) return {}; - return { backgroundColor: `${color}22`, color, border: `1px solid ${color}55` }; -} - const dnsTabs = (view: "records" | "domains") => ( {p.name} - - {PROVIDER_LABELS[p.providerType]} - +
- - {TYPE_LABELS[i.type]} - +
diff --git a/web/src/pages/Servers.tsx b/web/src/pages/Servers.tsx index 77536e3..e37a2c9 100644 --- a/web/src/pages/Servers.tsx +++ b/web/src/pages/Servers.tsx @@ -26,12 +26,7 @@ import EmptyState, { EmptyRow, LoadingRow } from "../components/EmptyState"; import BulkBar from "../components/BulkBar"; import { RunsOnBulkDrawer, SilenceBulkDrawer, TagBulkDrawer } from "../components/BulkDrawers"; import { doBulk, plural } from "../utils/bulk"; - -function typeBadgeStyle(colors: Record, type: string): CSSProperties { - const color = colors[type]; - if (!color) return {}; - return { backgroundColor: `${color}22`, color, border: `1px solid ${color}55` }; -} +import { BrandTag } from "../components/BrandIcon"; export default function Servers({ user }: { user: CurrentUser }) { @@ -235,9 +230,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
{s.hostname ?? "no hostname reported"}
{s.proxmoxIntegrationId ? ( - - Proxmox - + ) : s.lastSeenAt ? ( agentState(s, agentLatest) === "behind" ? ( diff --git a/web/src/pages/settings/BadgeSettings.tsx b/web/src/pages/settings/BadgeSettings.tsx index 0559a8b..5664aa3 100644 --- a/web/src/pages/settings/BadgeSettings.tsx +++ b/web/src/pages/settings/BadgeSettings.tsx @@ -3,6 +3,8 @@ import { TYPE_LABELS } from "../../utils/integrationTypes"; import { api } from "../../api/client"; import { ErrorNotice } from "../../components/Notice"; import { PageSkeleton } from "../../components/Skeleton"; +import { BrandTag } from "../../components/BrandIcon"; +import { brandOf, isHexColor } from "../../utils/brands"; const PROVIDER_NAMES: Record = { cloudflare: "Cloudflare", @@ -13,31 +15,38 @@ const PROVIDER_NAMES: Record = { technitium: "Technitium", }; +/** + * One row for each kind: its tag as it looks now (its brand colour and logo, or the colour chosen here), a colour to choose instead, and — once one is chosen — a way back to the brand's. + * "Back to the brand's" is saved as an empty colour: the settings are merged key by key, so a key cannot be taken away, only given nothing. + */ function ColorList({ names, colors, onChange, + onReset, }: { names: Record; colors: Record; onChange: (id: string, color: string) => void; + onReset: (id: string) => void; }) { return (
{Object.entries(names).map(([id, name]) => { - const color = colors[id] ?? "#6366f1"; + const custom = isHexColor(colors[id]) ? colors[id] : null; + const color = custom ?? brandOf(id)?.color ?? "#6366f1"; return ( -
- - {name} +
+ + - onChange(id, e.target.value)} - /> - {color} + onChange(id, e.target.value)} /> + {custom ? color : brandOf(id) ? `${color} — the brand's` : color} + {custom && brandOf(id) && ( + + )}
); })} @@ -105,11 +114,12 @@ export default function BadgeSettings() {

DNS provider badge colors

-

Customize the color of each DNS provider's badge throughout the app.

+

Each provider's badge is in its brand's colour, with its logo where there is one. Choose another colour for any of them to use that throughout the app instead.

setProviderColors((c) => ({ ...c, [id]: color }))} + onReset={(id) => setProviderColors((c) => ({ ...c, [id]: "" }))} />
@@ -121,11 +131,12 @@ export default function BadgeSettings() {

Integration badge colors

-

Customize the color of each integration type's badge throughout the app.

+

Each kind's badge is in its brand's colour, with its logo where there is one (a few have an approximate colour: the brand has no open logo). Choose another colour for any of them to use that throughout the app instead.

setIntegrationColors((c) => ({ ...c, [id]: color }))} + onReset={(id) => setIntegrationColors((c) => ({ ...c, [id]: "" }))} />
diff --git a/web/src/pages/settings/DisplaySettings.tsx b/web/src/pages/settings/DisplaySettings.tsx index e2742bd..8efd4ed 100644 --- a/web/src/pages/settings/DisplaySettings.tsx +++ b/web/src/pages/settings/DisplaySettings.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; import { api, type AppSettings, type DateFormat, type TimeFormat } from "../../api/client"; import { setDateTimeSettings } from "../../utils/date"; import { setPageSize } from "../../utils/pageSize"; +import { getMenuIcons, setMenuIcons } from "../../utils/menuIcons"; import { MENU_CHANGED } from "../../hooks/useMenuHiding"; import { PAGE_KINDS, unusedPages } from "../../utils/navVisibility"; import { NAV, isGroup } from "../../layout/nav"; @@ -25,6 +26,8 @@ export default function DisplaySettings() { const [timeFormat, setTimeFormatState] = useState("24h"); const [pageSize, setPageSizeState] = useState(20); const [hideUnusedPages, setHideUnusedPages] = useState(false); + // Per browser, not saved with the other settings: it takes effect at once. + const [menuIcons, setMenuIconsState] = useState(getMenuIcons()); // The kinds of integration that have been added, to say which pages the setting would leave out. const [added, setAdded] = useState(null); const [saving, setSaving] = useState(false); @@ -159,6 +162,19 @@ export default function DisplaySettings() {

Menu

+