feat(webui): customizable dashboard + nav layout (phase 3)
The "C" half — reorder + show/hide the overview cards and the sidebar nav,
persisted to config/ui.json's layout section.
- LayoutContext loads the layout (authed GET /api/ui) and persists edits via
the section-merge POST /api/ui {layout} (debounced). reconcileLayoutItems
keeps stored order/visibility, appends new catalogue entries (forward-compat),
and forces pinned items visible.
- Overview is refactored into a block registry (stats/connections/alerts/host/
sessions). A 「编辑布局」 mode (motion Reorder — zero new deps) edits both the
cards and the nav in place, with per-item show/hide and a reset; an all-hidden
dashboard shows an empty state with 恢复默认.
- Anti-self-lock: PINNED_NAV = ['/', '/settings'] can be reordered but never
hidden — the overview hosts the layout editor and settings hosts
account/appearance, so the user can never strand themselves.
- api.ui.save now takes Partial<UiConfig> (the section-merge contract).
A late initial GET can't clobber an in-flight edit (dirtyRef); a pending edit
flushes on unmount. Verified across 2 adversarial review rounds.
This commit is contained in:
6 files changed
+613
-225
No files matched your search
@@ -82,8 +82,9 @@ export interface ApiClient {
|
||||
ui: {
|
||||
/** Full config (appearance + layout). Bearer-gated. */
|
||||
get(): Promise<UiConfig>;
|
||||
/** Persist the full config; returns the normalized server view. */
|
||||
save(config: UiConfig): Promise<UiConfig>;
|
||||
/** Persist config. Section-level merge: a payload with only `appearance`
|
||||
* or only `layout` keeps the other section. Returns the normalized view. */
|
||||
save(config: Partial<UiConfig>): Promise<UiConfig>;
|
||||
/** Cosmetic appearance subset, usable pre-auth (login page theming). */
|
||||
getPublic(): Promise<UiAppearance>;
|
||||
/** Upload a background image (PNG/JPEG/WebP, ≤5MB). Returns updated config. */
|
||||
|
||||
Reference in new issue
Block a user