You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Renders a visual CSS grid representation of a device's physical ports and interfaces directly on the NetBox device detail page.
8
+
Renders a visual CSS grid representation of a device's physical ports and interfaces directly on the NetBox device detail page. An SVG renderer is also available for YAML-based layouts.
@@ -88,6 +88,17 @@ The plugin derives a `stylename` for each interface and port:
88
88
89
89
A DeviceView supports two layout formats. **YAML is preferred** — it is easier to write, validate, and maintain. Legacy CSS is still fully supported for backward compatibility.
90
90
91
+
### Render modes
92
+
93
+
A DeviceView also has a **Render Mode** field:
94
+
95
+
| Mode | Description |
96
+
|------|-------------|
97
+
|`css` (default) | CSS Grid renderer — works with both YAML and legacy CSS layouts |
98
+
|`svg`| SVG renderer — requires a YAML layout; produces a scalable `<svg>` element |
99
+
100
+
SVG mode produces the same port positions as CSS mode (using `canvas.cell_size` for coordinates) and supports front/rear faces, module variants, hover tooltips, and click targets. Virtual Chassis devices always fall back to CSS mode.
101
+
91
102
### YAML layout (recommended)
92
103
93
104
Fill the **YAML Layout** field with a YAML document describing the device layout. The plugin compiles it to CSS at render time.
@@ -113,13 +124,13 @@ views:
113
124
sections:
114
125
- sequence:
115
126
kind: interface
116
-
prefix: "gigabitethernet0-"
127
+
prefix: "gigabitethernet1-"
117
128
start: 1
118
129
count: 12
119
130
pattern: top-odd
120
131
- sequence:
121
132
kind: interface
122
-
prefix: "gigabitethernet0-"
133
+
prefix: "gigabitethernet1-"
123
134
start: 13
124
135
count: 12
125
136
pattern: top-odd
@@ -135,13 +146,13 @@ variants:
135
146
sections:
136
147
- sequence:
137
148
kind: interface
138
-
prefix: "gigabitethernet0-"
149
+
prefix: "gigabitethernet1-"
139
150
start: 1
140
151
count: 12
141
152
pattern: top-odd
142
153
- sequence:
143
154
kind: interface
144
-
prefix: "gigabitethernet0-"
155
+
prefix: "gigabitethernet1-"
145
156
start: 13
146
157
count: 12
147
158
pattern: top-odd
@@ -153,7 +164,7 @@ variants:
153
164
pattern: top-odd
154
165
```
155
166
156
-
See [`docs/yaml-layout-schema.md`](docs/yaml-layout-schema.md) for the full schema reference and [`examples/yaml/`](examples/yaml/) for ready-made YAML files.
167
+
See [`docs/yaml-layout-schema.md`](docs/yaml-layout-schema.md)
157
168
158
169
### CSS layout (legacy)
159
170
@@ -174,6 +185,18 @@ See [`examples/`](examples/) for ready-made CSS files.
174
185
175
186
> **Precedence:** if a DeviceView has a YAML layout, it is used and the CSS field is ignored.
176
187
188
+
### Migrating from CSS to YAML
189
+
190
+
> [!IMPORTANT]
191
+
> If you have existing DeviceViews with CSS `grid_template_area` layouts and want to switch to the SVG renderer, run the bundled management command to convert them automatically:
192
+
>
193
+
> ```bash
194
+
> cd /opt/netbox/netbox
195
+
> python manage.py css_to_yaml
196
+
> ```
197
+
>
198
+
> This converts every DeviceView that has a CSS layout but no YAML layout, writes the result into the **YAML Layout** field, and leaves the original CSS untouched (so you can roll back by clearing the YAML field). After running it, set **Render Mode → SVG** on the DeviceViews you want to upgrade.
199
+
177
200
### Module variants
178
201
179
202
When a device has an installed module, an extra CSS class matching the module model is added to the device div. In YAML, declare a `variants:` block. In CSS, add a `.deviceview.module{ModelName}.area` rule.
@@ -195,3 +218,9 @@ Add a `.deviceview.module{ModelName}.area` rule to your CSS that includes the ne
195
218
196
219
**Virtual chassis ports missing**
197
220
Ensure your CSS uses `.area.d{vc_position}` scoped selectors. Each VC member needs its own rule.
221
+
222
+
**SVG mode shows nothing / falls back to CSS**
223
+
SVG mode requires a YAML layout. If the DeviceView has no YAML layout, or the device is part of a Virtual Chassis, it silently falls back to CSS rendering.
224
+
225
+
**Port status colours not showing in SVG mode**
226
+
Status classes (`bg-success`, `bg-secondary`, `bg-danger`) are applied by JavaScript using the `data-stylename` attribute. Ensure the static file `netbox_device_view/css/device_view_svg.css` is collected (`python manage.py collectstatic`).
Copy file name to clipboardExpand all lines: docs/yaml-layout-schema.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -239,6 +239,74 @@ The YAML renderer produces CSS equivalent to the legacy hand-written format:
239
239
240
240
---
241
241
242
+
## SVG renderer
243
+
244
+
When a DeviceView has `render_mode` set to `svg`, the plugin uses the same `NormalizedLayout` model to emit an `<svg>` element instead of CSS. The `cell_size` canvas field controls the pixel size of each port cell (default: 20 px if set to 0).
Patch panels with separate front and rear views produce **two `<svg>` elements**, each with a `data-face` attribute and a `dv-face-front` / `dv-face-rear` class. The JS in the template shows/hides them based on the active tab.
282
+
283
+
### CSS classes on port groups
284
+
285
+
| Class | Meaning |
286
+
|-------|---------|
287
+
|`dv-port`| Any clickable port element |
288
+
|`dv-kind-{kind}`| Element kind (`interface`, `port`, `console-port`, etc.) |
289
+
|`{stylename}`| Derived CSS name — same as grid-area name in CSS mode |
290
+
|`dv-spacer`| Spacer element |
291
+
|`dv-blank`| Blank decorative element |
292
+
|`dv-label`| Text label element |
293
+
|`dv-base`| Wrapper `<g>` for base elements when variants are present |
294
+
|`dv-variant`| Wrapper `<g>` for a module variant layer |
295
+
|`dv-variant-{ModelName}`| Identifies which variant this layer belongs to |
296
+
|`dv-face-front` / `dv-face-rear`| Applied to the top-level `<svg>` for patch panels |
297
+
298
+
### Interactivity
299
+
300
+
Status coloring, hover tooltips (Bootstrap), and variant switching are handled by JavaScript injected in the template — the SVG renderer itself emits only structural markup. The `data-stylename` attribute on port `<g>` elements is the hook used by JS to apply status classes (e.g. `bg-success`, `bg-secondary`, `bg-danger`).
301
+
302
+
### Limitations
303
+
304
+
-**Virtual Chassis** devices fall back to CSS rendering automatically — SVG mode for VC is not yet supported.
305
+
- SVG mode requires a YAML layout; if no YAML is present the DeviceView silently falls back to CSS.
306
+
-`cell_size: 0` (patch-panel auto-sizing) uses `DEFAULT_CELL = 20 px` in SVG mode since CSS `auto` sizing has no SVG equivalent.
307
+
308
+
---
309
+
242
310
## Examples
243
311
244
312
Ready-made YAML layouts are in [`examples/yaml/`](../examples/yaml/):
0 commit comments