feat(mazenet): persist canvas layout per topology to localStorage
Dragging a LAN or decky, or resizing a NetBox, updates React state but previously vanished on reload because the grid-layout adapter rewrote everything from the graph. Add a per-topology localStorage snapshot (key: mazenet.layout.<topologyId>) that captures net x/y/w/h and decky x/y; useLayoutPersistor writes it debounced, and getTopology merges it over adaptTopology's grid so entities without a stored entry still fall back to a clean auto-layout. Deleting a topology calls clearLayout to drop its snapshot.
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Network, Plus, Power, Trash2, UploadCloud, RefreshCw } from 'lucide-react';
|
||||
import api from '../../utils/api';
|
||||
import { clearLayout } from '../MazeNET/useMazeLayoutStore';
|
||||
import './TopologyList.css';
|
||||
|
||||
interface TopologySummary {
|
||||
@@ -90,6 +91,7 @@ const TopologyList: React.FC = () => {
|
||||
setBusy(id);
|
||||
try {
|
||||
await api.delete(`/topologies/${id}`);
|
||||
clearLayout(id);
|
||||
await fetchRows();
|
||||
} catch (e) {
|
||||
setErr((e as Error)?.message ?? 'delete failed');
|
||||
|
||||
Reference in New Issue
Block a user