netbox-render 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netbox-render
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: NetBox plugin for subdivided device bay rack elevation rendering
5
5
  Author-email: Parag Mehta <pmehta@pmehta.com>
6
6
  License-Expression: Apache-2.0
@@ -44,9 +44,11 @@ Out of the box, NetBox shows a device-bay device as one rectangle with an occupa
44
44
  I patched `RackElevationSVG._draw_device` so each bay gets its own section showing:
45
45
 
46
46
  - Bay index (1, 2, 3, ...) sorted by bay name
47
- - Child device name, or "(empty)"
47
+ - Child device name with text wrapping for long names, or "(empty)"
48
48
  - Role color on the front face (rear renders grey, matching stock behavior)
49
49
  - Clickable link to the child device page
50
+ - Optional device type images with label overlay (`enable_images`)
51
+ - Auto grid layout for dense shelves (multiple bays arranged in columns)
50
52
 
51
53
  Devices without bays are untouched.
52
54
 
@@ -110,7 +112,7 @@ PLUGINS_CONFIG = {
110
112
 
111
113
  ### Grid layout
112
114
 
113
- Dense shelves (many bays in few rack units) automatically switch to a grid layout when vertical stacking would make bays too short. The column count is auto-calculated to produce the most square cells.
115
+ The plugin auto-calculates the optimal column count by minimizing cell aspect ratio. When layouts tie (e.g. 2×2 vs 4×1), it prefers fewer empty cells and more columns — so typical shelves auto-detect a horizontal row while tall chassis devices stack vertically.
114
116
 
115
117
  Override with `layouts` using the device type slug as the key and `{'columns': N}` as the value. Invalid values (zero, non-integer, exceeding bay count) fall back to auto-calculation with a logged warning.
116
118
 
@@ -13,9 +13,11 @@ Out of the box, NetBox shows a device-bay device as one rectangle with an occupa
13
13
  I patched `RackElevationSVG._draw_device` so each bay gets its own section showing:
14
14
 
15
15
  - Bay index (1, 2, 3, ...) sorted by bay name
16
- - Child device name, or "(empty)"
16
+ - Child device name with text wrapping for long names, or "(empty)"
17
17
  - Role color on the front face (rear renders grey, matching stock behavior)
18
18
  - Clickable link to the child device page
19
+ - Optional device type images with label overlay (`enable_images`)
20
+ - Auto grid layout for dense shelves (multiple bays arranged in columns)
19
21
 
20
22
  Devices without bays are untouched.
21
23
 
@@ -79,7 +81,7 @@ PLUGINS_CONFIG = {
79
81
 
80
82
  ### Grid layout
81
83
 
82
- Dense shelves (many bays in few rack units) automatically switch to a grid layout when vertical stacking would make bays too short. The column count is auto-calculated to produce the most square cells.
84
+ The plugin auto-calculates the optimal column count by minimizing cell aspect ratio. When layouts tie (e.g. 2×2 vs 4×1), it prefers fewer empty cells and more columns — so typical shelves auto-detect a horizontal row while tall chassis devices stack vertically.
83
85
 
84
86
  Override with `layouts` using the device type slug as the key and `{'columns': N}` as the value. Invalid values (zero, non-integer, exceeding bay count) fall back to auto-calculation with a logged warning.
85
87
 
@@ -108,11 +108,13 @@ def _render_wrapped_text(container, lines, text_x, bay_y, cell_height,
108
108
  if stroke_outline:
109
109
  container.add(Text(
110
110
  line_text, stroke='black', stroke_width='0.3em',
111
- stroke_linejoin='round', class_=f'device-image-label{css_extra}',
111
+ stroke_linejoin='round', clip_path=f"url(#{clip_id})",
112
+ class_=f'device-image-label{css_extra}',
112
113
  **base_kwargs,
113
114
  ))
114
115
  container.add(Text(
115
116
  line_text, fill='white',
117
+ clip_path=f"url(#{clip_id})",
116
118
  class_=f'device-image-label{css_extra}',
117
119
  **base_kwargs,
118
120
  ))
@@ -190,6 +192,8 @@ def _patched_draw_device(self, device, coords, size, color=None, image=None):
190
192
  label_lines = [str(index)]
191
193
  else:
192
194
  label_lines = _wrap_label(label, cell_width, font_size)
195
+ max_lines = max(1, int(cell_height / (font_size * 1.3)))
196
+ label_lines = label_lines[:max_lines]
193
197
 
194
198
  clip_id = f"clip-bay-{device.pk}-{i}"
195
199
  clip_path = ClipPath(id=clip_id)
@@ -263,13 +267,14 @@ def _patched_draw_device(self, device, coords, size, color=None, image=None):
263
267
  if device_url:
264
268
  self.drawing.add(link)
265
269
 
270
+ padding_extra = ' shaded' if self.highlight_devices else ''
266
271
  total_cells = columns * rows
267
272
  for i in range(n_bays, total_cells):
268
273
  col = i % columns
269
274
  row = i // columns
270
275
  bay_x = x + col * cell_width
271
276
  bay_y = y + row * cell_height
272
- self.drawing.add(Rect((bay_x, bay_y), (cell_width, cell_height), class_='slot blocked'))
277
+ self.drawing.add(Rect((bay_x, bay_y), (cell_width, cell_height), class_=f'slot blocked{padding_extra}'))
273
278
  if row > 0:
274
279
  self.drawing.add(Line(
275
280
  start=(bay_x, bay_y),
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netbox-render
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: NetBox plugin for subdivided device bay rack elevation rendering
5
5
  Author-email: Parag Mehta <pmehta@pmehta.com>
6
6
  License-Expression: Apache-2.0
@@ -44,9 +44,11 @@ Out of the box, NetBox shows a device-bay device as one rectangle with an occupa
44
44
  I patched `RackElevationSVG._draw_device` so each bay gets its own section showing:
45
45
 
46
46
  - Bay index (1, 2, 3, ...) sorted by bay name
47
- - Child device name, or "(empty)"
47
+ - Child device name with text wrapping for long names, or "(empty)"
48
48
  - Role color on the front face (rear renders grey, matching stock behavior)
49
49
  - Clickable link to the child device page
50
+ - Optional device type images with label overlay (`enable_images`)
51
+ - Auto grid layout for dense shelves (multiple bays arranged in columns)
50
52
 
51
53
  Devices without bays are untouched.
52
54
 
@@ -110,7 +112,7 @@ PLUGINS_CONFIG = {
110
112
 
111
113
  ### Grid layout
112
114
 
113
- Dense shelves (many bays in few rack units) automatically switch to a grid layout when vertical stacking would make bays too short. The column count is auto-calculated to produce the most square cells.
115
+ The plugin auto-calculates the optimal column count by minimizing cell aspect ratio. When layouts tie (e.g. 2×2 vs 4×1), it prefers fewer empty cells and more columns — so typical shelves auto-detect a horizontal row while tall chassis devices stack vertically.
114
116
 
115
117
  Override with `layouts` using the device type slug as the key and `{'columns': N}` as the value. Invalid values (zero, non-integer, exceeding bay count) fall back to auto-calculation with a logged warning.
116
118
 
@@ -1 +0,0 @@
1
- __version__ = "0.2.0"
File without changes
File without changes