mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
Tweak reserved stroke style & add constants for colors
This commit is contained in:
parent
7d7af1298b
commit
120e44c71e
@ -22,6 +22,11 @@ __all__ = (
|
||||
'RackElevationSVG',
|
||||
)
|
||||
|
||||
GRADIENT_RESERVED = '#b0b0ff'
|
||||
GRADIENT_OCCUPIED = '#d7d7d7'
|
||||
GRADIENT_BLOCKED = '#ffc0c0'
|
||||
STROKE_RESERVED = '#4d4dff'
|
||||
|
||||
|
||||
def get_device_name(device):
|
||||
if device.virtual_chassis:
|
||||
@ -132,9 +137,9 @@ class RackElevationSVG:
|
||||
drawing.defs.add(drawing.style(css_file.read()))
|
||||
|
||||
# Add gradients
|
||||
RackElevationSVG._add_gradient(drawing, 'reserved', '#b0b0ff')
|
||||
RackElevationSVG._add_gradient(drawing, 'occupied', '#d7d7d7')
|
||||
RackElevationSVG._add_gradient(drawing, 'blocked', '#ffc0c0')
|
||||
RackElevationSVG._add_gradient(drawing, 'reserved', GRADIENT_RESERVED)
|
||||
RackElevationSVG._add_gradient(drawing, 'occupied', GRADIENT_OCCUPIED)
|
||||
RackElevationSVG._add_gradient(drawing, 'blocked', GRADIENT_BLOCKED)
|
||||
|
||||
return drawing
|
||||
|
||||
@ -244,15 +249,15 @@ class RackElevationSVG:
|
||||
for segment in array_to_ranges(reservation.units):
|
||||
u_height = 1 if len(segment) == 1 else segment[1] + 1 - segment[0]
|
||||
coords = self._get_device_coords(segment[0], u_height)
|
||||
coords = (coords[0] + self.unit_width + RACK_ELEVATION_BORDER_WIDTH - 0.1, coords[1])
|
||||
coords = (coords[0] + self.unit_width + RACK_ELEVATION_BORDER_WIDTH * 2, coords[1])
|
||||
size = (
|
||||
self.margin_width,
|
||||
self.margin_width - 3,
|
||||
u_height * self.unit_height
|
||||
)
|
||||
link = Hyperlink(href=f'{self.base_url}{reservation.get_absolute_url()}', target='_parent')
|
||||
link.set_desc(f'Reservation #{reservation.pk}: {reservation.description}')
|
||||
link.add(
|
||||
Rect(coords, size, class_='reservation', stroke='red', stroke_width=2)
|
||||
Rect(coords, size, class_='reservation', stroke=STROKE_RESERVED, stroke_width=2)
|
||||
)
|
||||
self.drawing.add(link)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user