Alerts tab, Docker tab, nine new skins including HUD, a colour for every machine
Alerts: rules over sensors, watched fleet-wide from the hub; ntfy and webhook channels; firing count on the rail. Docker: containers by stack with live use, start/stop/restart, following logs, inspect, images/volumes/networks. Skins: HUD, Nord, Gruvbox, Catppuccin (+Latte), Dracula, Tokyo Night, Solarized (+Light). Accents: per-machine colour. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
63fcba6077
commit
cb1617c2b8
@@ -0,0 +1,25 @@
|
||||
// Each machine wears a colour — a stripe across the header, its name in the switcher — so
|
||||
// you always know which box you are typing into. A colour you pick wins; otherwise the
|
||||
// machine's name picks one, the same one on every device.
|
||||
import { api } from './api'
|
||||
import { currentThemeId } from './themes'
|
||||
import { getRefreshMs } from './prefs'
|
||||
|
||||
export const ACCENTS = ['#e3a33b', '#3fb950', '#58a6ff', '#f778ba', '#ff7b72', '#a371f7', '#39c5cf', '#d4d44a', '#ff9e64', '#9aa7b4']
|
||||
const KEY = 'hamlab.accents'
|
||||
|
||||
export function getAccents(): Record<string, string> { try { return JSON.parse(localStorage.getItem(KEY) ?? '{}') ?? {} } catch { return {} } }
|
||||
export function accentFor(name: string): string {
|
||||
const picked = getAccents()[name]
|
||||
if (picked && /^#[0-9a-f]{6}$/i.test(picked)) return picked
|
||||
let h = 0; for (const c of name) h = (h * 31 + c.charCodeAt(0)) >>> 0
|
||||
return ACCENTS[h % ACCENTS.length]
|
||||
}
|
||||
export function applyAccent(name: string) { document.documentElement.style.setProperty('--machine', accentFor(name)) }
|
||||
export function setAccents(all: Record<string, string>, save = true) {
|
||||
localStorage.setItem(KEY, JSON.stringify(all))
|
||||
window.dispatchEvent(new Event('hamlab:accents'))
|
||||
if (save) savePrefs()
|
||||
}
|
||||
// Everything the hub remembers about how the console looks, saved as one object.
|
||||
export function savePrefs() { return api.saveUIPrefs({ theme: currentThemeId(), refreshMs: getRefreshMs(), accents: getAccents() }).catch(() => { /* local still applied */ }) }
|
||||
Reference in New Issue
Block a user