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
docs: set up MkDocs Material site with port status SVG example
- Add mkdocs.yml with Material theme, dark/light toggle, navigation tabs,
and GitHub Pages site_url
- Reorganise docs/ into 9 focused pages: index, installation, configuration,
how-it-works, layout-yaml, layout-css, svg-renderer, virtual-chassis,
troubleshooting
- Move content from the 226-line README into dedicated pages; README is
now a short install guide with a link to the full docs site
- Add docs/assets/port-status-example.svg — annotated SVG illustrating all
four port status states (full, partial, unconnected, disabled) including
the new partial-connection dot overlay from feature/partial-connection-indicator
- Replace docs/yaml-layout-schema.md with a redirect stub (content moved to
layout-yaml.md)
- Add .github/workflows/docs.yml — deploys to GitHub Pages on push to main
- Add docs optional-dependency group and Documentation URL to pyproject.toml
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.
8
+
Renders a visual front/rear panel of a device's physical ports and interfaces directly on the NetBox device detail page. Supports both a CSS Grid renderer and a scalable SVG renderer driven by a YAML layout.
Enable the plugin in your NetBox `configuration.py`:
36
+
Enable in `configuration.py`:
43
37
44
38
```python
45
39
PLUGINS= ["netbox_device_view"]
46
-
47
-
PLUGINS_CONFIG= {
48
-
"netbox_device_view": {
49
-
# Show the port grid inline on the main device tab (default: False)
50
-
# When False, the grid is only shown on a dedicated "Device View" tab
51
-
"show_on_device_tab": False,
52
-
# Where to render the grid when show_on_device_tab is True (default: "bottom")
53
-
# "bottom" — below main device content (full_width_page)
54
-
# "top" — above main device content (alerts area)
55
-
"device_tab_position": "bottom",
56
-
},
57
-
}
58
-
```
59
-
60
-
## How It Works
61
-
62
-
For each **Device Type** you create a **DeviceView** object (at *Plugins → Device Views → Add*) with either a **YAML layout** or a raw **CSS layout**. When you visit a device of that type, the plugin renders every interface and port as a clickable cell in the grid.
63
-
64
-
### Port/Interface name → CSS grid-area name
65
-
66
-
The plugin derives a `stylename` for each interface and port:
- For the 3-part Cisco format `Type{dev}/{module}/{port}`, stylename is `type{module}-{port}`
80
-
- For the 2-part format `Type{dev}/{port}`, stylename is `type-{port}`
81
-
- All other names: non-alphanumeric/dot characters are replaced with `-`
82
-
- Purely numeric stylenames are prefixed with `p`
83
-
- Virtual and LAG interfaces are skipped
84
-
85
-
---
86
-
87
-
## Layout formats
88
-
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
-
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
-
102
-
### YAML layout (recommended)
103
-
104
-
Fill the **YAML Layout** field with a YAML document describing the device layout. The plugin compiles it to CSS at render time.
105
-
106
-
Example for a Cisco C9300-24T with an optional 8x 10G expansion module:
107
-
108
-
```yaml
109
-
version: 1
110
-
111
-
meta:
112
-
description: "Cisco Catalyst 9300-24T"
113
-
114
-
canvas:
115
-
columns: 32
116
-
rows: 2
117
-
118
-
views:
119
-
front:
120
-
rows:
121
-
- blank: 14
122
-
- group:
123
-
spacer: 1
124
-
sections:
125
-
- sequence:
126
-
kind: interface
127
-
prefix: "gigabitethernet1-"
128
-
start: 1
129
-
count: 12
130
-
pattern: top-odd
131
-
- sequence:
132
-
kind: interface
133
-
prefix: "gigabitethernet1-"
134
-
start: 13
135
-
count: 12
136
-
pattern: top-odd
137
-
- spacer: 4
138
-
139
-
variants:
140
-
C9300-NM-8X:
141
-
match: module
142
-
rows:
143
-
- blank: 14
144
-
- group:
145
-
spacer: 1
146
-
sections:
147
-
- sequence:
148
-
kind: interface
149
-
prefix: "gigabitethernet1-"
150
-
start: 1
151
-
count: 12
152
-
pattern: top-odd
153
-
- sequence:
154
-
kind: interface
155
-
prefix: "gigabitethernet1-"
156
-
start: 13
157
-
count: 12
158
-
pattern: top-odd
159
-
- sequence:
160
-
kind: interface
161
-
prefix: "tengigabitethernet1-"
162
-
start: 1
163
-
count: 8
164
-
pattern: top-odd
165
40
```
166
41
167
-
See [`docs/yaml-layout-schema.md`](docs/yaml-layout-schema.md)
42
+
Run migrations and collect static files:
168
43
169
-
### CSS layout (legacy)
170
-
171
-
Fill the **Grid Template Area** field with raw CSS. The grid has **32 columns** and uses **20 px cells**.
"x x x x x x x x x x x x x x gigabitethernet0-1 gigabitethernet0-3 ... z z z z z"
180
-
"x x x x x x x x x x x x x x gigabitethernet0-2 gigabitethernet0-4 ... z z z z z";
181
-
}
44
+
```bash
45
+
cd /opt/netbox/netbox
46
+
python manage.py migrate netbox_device_view
47
+
python manage.py collectstatic --no-input
182
48
```
183
49
184
-
See [`examples/`](examples/) for ready-made CSS files.
185
-
186
-
> **Precedence:** if a DeviceView has a YAML layout, it is used and the CSS field is ignored.
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
-
200
-
### Module variants
201
-
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.
203
-
204
-
### Virtual Chassis
205
-
206
-
For virtual chassis devices, each member's CSS areas are scoped with a `.d{vc_position}` suffix automatically. YAML-rendered CSS is scoped the same way.
207
-
208
-
## Troubleshooting
209
-
210
-
**Tab not showing / badge count is zero**
211
-
No DeviceView exists for this device's type. Go to *Plugins → Device Views → Add* and create one.
212
-
213
-
**A port is not appearing in the grid**
214
-
The port's stylename is not referenced in the CSS. Check what stylename the plugin derives: it follows the rules in the table above. Add a corresponding area name to your `grid-template-areas`.
215
-
216
-
**Layout looks wrong after adding a module**
217
-
Add a `.deviceview.module{ModelName}.area` rule to your CSS that includes the new module ports.
218
-
219
-
**Virtual chassis ports missing**
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`).
50
+
For configuration options, layout formats, the SVG renderer, and troubleshooting see the **[full documentation](https://peterbaumert.github.io/netbox-device-view/)**.
0 commit comments