feat(webui): free-form draggable/resizable dashboard grid (phase 4)

The overview becomes a gridstack-backed free grid — drag, resize, and show/
hide 9 widgets (the 5 top stat tiles split out of the old single block, plus
connections/alerts/host/sessions), persisted to config/ui.json's
layout.overviewBlocks as {id,x,y,w,h,visible}.

- gridstack (zero-dep, vanilla; chosen over react-grid-layout whose
  react-draggable uses the React-19-removed findDOMNode). React renders each
  widget into a gridstack item via a portal (context flows through); gridstack
  owns layout/drag/resize. Per-widget minW/minH prevent content collapse.
- Desktop = editable in place; narrow screens = auto single-column, read-only.
  Fixed cellHeight => no ResizeObserver => the narrow column-clamp never
  persists over the desktop coords.
- Edit mode shows a panel: widget show/hide + nav reorder (the phase-3 motion
  list); the grid below is live-editable. Reset + empty-state preserved.
- Server UiLayoutItem gains optional x/y/w/h (clamped); the stats->5-tiles
  migration + default placement live client-side (lib/dashboard-layout.ts).

Verified across 2 adversarial review rounds (gridstack+React lifecycle traced
against the library source: StrictMode-safe, no mount-persist loop, no
re-init on coord change, no narrow-visit data loss).
This commit is contained in:
DrSmoothl committed 2026-06-13 21:17:23 +08:00
1 parent a5335687ec
commit f07f309c51
10 files changed
+532 -226

No files matched your search

+47 -2
View File
@@ -381,6 +381,9 @@ importers:
clsx:
specifier: ^2.1.1
version: 2.1.1
gridstack:
specifier: ^12.6.0
version: 12.6.0
lucide-react:
specifier: ^0.469.0
version: 0.469.0([email protected])
@@ -2315,6 +2318,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
[email protected]:
resolution: {integrity: sha512-dUrqsormSybFn/2P4Dz8AgprftKD5e/IiV7UmC0XLQU+G+/WtkAeFiCSNLoAGhPDXoJ/O61Xtj3gljY/Ds83yQ==}
[email protected]:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
@@ -4431,7 +4437,7 @@ snapshots:
magicast: 0.5.3
obug: 2.1.1
tinyrainbow: 3.1.0
vitest: 4.1.4(@types/node@24.12.2)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@24.12.2)([email protected])([email protected])([email protected])([email protected]))
vitest: 4.1.4(@types/node@25.6.0)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@25.6.0)([email protected])([email protected])([email protected])([email protected]))
transitivePeerDependencies:
- supports-color
@@ -4447,7 +4453,7 @@ snapshots:
obug: 2.1.1
std-env: 4.1.0
tinyrainbow: 3.1.0
vitest: 4.1.4(@types/node@24.12.2)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@24.12.2)([email protected])([email protected])([email protected])([email protected]))
vitest: 4.1.4(@types/node@25.6.0)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@25.6.0)([email protected])([email protected])([email protected])([email protected]))
'@vitest/[email protected]':
dependencies:
@@ -4466,6 +4472,14 @@ snapshots:
optionalDependencies:
vite: 8.0.8(@types/[email protected])([email protected])([email protected])([email protected])([email protected])
'@vitest/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))':
dependencies:
'@vitest/spy': 4.1.4
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
vite: 8.0.8(@types/[email protected])([email protected])([email protected])([email protected])([email protected])
'@vitest/[email protected]':
dependencies:
tinyrainbow: 3.1.0
@@ -4978,6 +4992,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -5761,6 +5777,35 @@ snapshots:
transitivePeerDependencies:
- msw
[email protected](@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])):
dependencies:
'@vitest/expect': 4.1.4
'@vitest/mocker': 4.1.4([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))
'@vitest/pretty-format': 4.1.4
'@vitest/runner': 4.1.4
'@vitest/snapshot': 4.1.4
'@vitest/spy': 4.1.4
'@vitest/utils': 4.1.4
es-module-lexer: 2.0.0
expect-type: 1.3.0
magic-string: 0.30.21
obug: 2.1.1
pathe: 2.0.3
picomatch: 4.0.4
std-env: 4.1.0
tinybench: 2.9.0
tinyexec: 1.1.1
tinyglobby: 0.2.16
tinyrainbow: 3.1.0
vite: 8.0.8(@types/[email protected])([email protected])([email protected])([email protected])([email protected])
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 25.6.0
'@vitest/coverage-istanbul': 4.1.4([email protected])
'@vitest/coverage-v8': 4.1.4([email protected])
transitivePeerDependencies:
- msw
[email protected]:
dependencies:
'@types/fs-extra': 11.0.4