feat: network diagrams — draw.io-style editor #139

Merged
chihlasm merged 31 commits from feat/network-diagrams into main 2026-04-14 05:44:27 +00:00
3 changed files with 12 additions and 0 deletions
Showing only changes of commit 4a12c9b37d - Show all commits

View File

@@ -22,12 +22,20 @@ class DeviceProperties(BaseModel):
status: str = Field(default="unknown", pattern=r"^(unknown|online|offline|degraded)$")
class NodeStyle(BaseModel):
width: float | None = None
height: float | None = None
class DiagramNode(BaseModel):
id: str
type: str
label: str
position: Position
properties: DeviceProperties = Field(default_factory=DeviceProperties)
nodeType: str | None = None
style: NodeStyle | None = None
parentId: str | None = None
class DiagramEdge(BaseModel):

View File

@@ -207,6 +207,7 @@ function DiagramEditorInner() {
type: 'device',
position: n.position,
style: n.style || { width: 120, height: 120 },
...(n.parentId ? { parentId: n.parentId, extent: 'parent' as const } : {}),
data: {
label: n.label,
deviceType: n.type,
@@ -247,6 +248,7 @@ function DiagramEditorInner() {
type: 'device' as const,
position: n.position,
style: n.style || { width: 120, height: 120 },
...(n.parentId ? { parentId: n.parentId, extent: 'parent' as const } : {}),
data: { label: n.label, deviceType: n.type, properties: n.properties } satisfies DeviceNodeData,
}
})
@@ -297,6 +299,7 @@ function DiagramEditorInner() {
position: n.position,
properties: data.properties,
style: { width: dw, height: dh },
...(n.parentId ? { parentId: n.parentId } : {}),
}
})
}, [getNodes])

View File

@@ -18,6 +18,7 @@ export interface DiagramNode {
properties: DeviceProperties
nodeType?: string
style?: { width?: number; height?: number } | null
parentId?: string | null
}
export interface DiagramEdge {