Skip to content

Commit

Permalink
Adds stroke to the reservation (#12506)
Browse files Browse the repository at this point in the history
* adds stroke to the reservation #11900

* fixed right side border

* Tweak reserved stroke style & add constants for colors

---------

Co-authored-by: jeremystretch <[email protected]>
  • Loading branch information
abhi1693 and jeremystretch authored May 9, 2023
1 parent 4e49f4a commit 57156f0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions netbox/dcim/svg/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
'RackElevationSVG',
)

GRADIENT_RESERVED = '#b0b0ff'
GRADIENT_OCCUPIED = '#d7d7d7'
GRADIENT_BLOCKED = '#ffc0c0'
STROKE_RESERVED = '#4d4dff'


def get_device_name(device):
if device.virtual_chassis:
Expand Down Expand Up @@ -132,9 +137,9 @@ def _setup_drawing(self):
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

Expand Down Expand Up @@ -246,13 +251,13 @@ def draw_margin(self):
coords = self._get_device_coords(segment[0], u_height)
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')
Rect(coords, size, class_='reservation', stroke=STROKE_RESERVED, stroke_width=2)
)
self.drawing.add(link)

Expand Down

0 comments on commit 57156f0

Please sign in to comment.