Add a real VLAN legend, matching the reference diagram's style

Previously the only VLAN visual was a small 14px swatch inside the detail
table -- easy to miss, not what the user meant by 'legend'. Added a
dedicated colored block per VLAN (VLAN <id> on a color fill, name in a
matching-outline box next to it), stacked left of the existing detail
table, same layout idea as the reference diagram this was modeled on.

Also fixed a real bug this surfaced: vlan_color() picked a palette color
by hash(vid), which let two different VLANs collide on the same color
(209 and 217 both landed on green). Colors are now assigned by position
among the VLANs actually present, which can't collide as long as there
are <= 8 of them (the palette size) -- true here with room to grow.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NM3nivbufxEWiKKmatEtEe
This commit is contained in:
dcstephenson
2026-09-15 14:02:00 -05:00
parent c9dad944e9
commit 2a7528f8d8
4 changed files with 62 additions and 16 deletions
+10 -7
View File
@@ -29,13 +29,16 @@ switches/patch panels look the part: switches get draw.io's built-in network
switch icon, patch panels get a small rack-unit look (header strip + port
ticks) rather than a plain box.
A **VLAN table** sits at the top of the diagram (VLAN / Name / Description /
Subnet / Site). As of this writing NetBox has no VLANs defined here, so it
renders as an explicit "not configured yet" placeholder rather than being
silently omitted or -- worse -- filled in with invented VLAN numbers. Add
VLANs and interface tagged/untagged assignments in NetBox and regenerate
(no code changes needed): the table populates for real, and every connector
whose port has VLAN config picks up a short suffix like `9·V10 ↔ 1·V10`.
A **VLAN legend + table** sits at the top of the diagram: a colored
"VLAN &lt;id&gt; / name" block per VLAN on the left (each color also used for
that VLAN's connector tags and table swatch), and the detail table
(VLAN / Name / Description / Subnet / Site) next to it. If NetBox has no
VLANs defined, both render as an explicit "not configured yet" placeholder
rather than being silently omitted or -- worse -- filled in with invented
VLAN numbers. Add VLANs and interface tagged/untagged assignments in
NetBox and regenerate (no code changes needed): both populate for real,
and every connector whose port has VLAN config picks up a short suffix
like `9·V214+215T ↔ 1`.
Deliberately left out: literal switch CLI config dumps -- those belong in
the switches' NetBox config-context/notes, not pasted into a topology
diagram where they'd immediately go stale.