From aefe2b419634e796c2d7464149f896f36b18949d Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 15 Jan 2020 14:05:44 -0500 Subject: [PATCH] Move rack elevation CSS to project-static/rack_elevation.css --- netbox/dcim/constants.py | 61 -------------------- netbox/dcim/models/__init__.py | 3 +- netbox/project-static/css/rack_elevation.css | 58 +++++++++++++++++++ 3 files changed, 60 insertions(+), 62 deletions(-) create mode 100644 netbox/project-static/css/rack_elevation.css diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py index 93576a390..62c95b246 100644 --- a/netbox/dcim/constants.py +++ b/netbox/dcim/constants.py @@ -60,67 +60,6 @@ COMPATIBLE_TERMINATION_TYPES = { } -RACK_ELEVATION_STYLE = """ -* { - font-family: sans-serif; - font-size: 13px; -} -rect { - box-sizing: border-box; -} -text { - text-anchor: middle; - dominant-baseline: middle; -} -.rack { - background-color: #f0f0f0; - fill: none; - stroke: black; - stroke-width: 3px; -} -.slot { - fill: #f7f7f7; - stroke: #a0a0a0; -} -.slot:hover { - fill: #fff; -} -.slot+.add-device { - fill: none; -} -.slot:hover+.add-device { - fill: blue; -} -.add-device:hover { - fill: blue; -} -.add-device:hover+.slot { - fill: #fff; -} -.reserved { - fill: url(#reserved); -} -.reserved:hover { - fill: url(#reserved); -} -.occupied { - fill: url(#occupied); -} -.occupied:hover { - fill: url(#occupied); -} -.blocked { - fill: url(#blocked); -} -.blocked:hover { - fill: url(#blocked); -} -.blocked:hover+.add-device { - fill: none; -} -""" - - # Rack Elevation SVG Size RACK_ELEVATION_UNIT_WIDTH_DEFAULT = 230 RACK_ELEVATION_UNIT_HEIGHT_DEFAULT = 20 diff --git a/netbox/dcim/models/__init__.py b/netbox/dcim/models/__init__.py index 737c5ab1f..8d066e921 100644 --- a/netbox/dcim/models/__init__.py +++ b/netbox/dcim/models/__init__.py @@ -375,7 +375,8 @@ class RackElevationHelperMixin: drawing = svgwrite.Drawing(size=(width, height)) # add the stylesheet - drawing.defs.add(drawing.style(RACK_ELEVATION_STYLE)) + with open('{}/css/rack_elevation.css'.format(settings.STATICFILES_DIRS[0])) as css_file: + drawing.defs.add(drawing.style(css_file.read())) # add gradients RackElevationHelperMixin._add_gradient(drawing, 'reserved', '#c7c7ff') diff --git a/netbox/project-static/css/rack_elevation.css b/netbox/project-static/css/rack_elevation.css new file mode 100644 index 000000000..06120c223 --- /dev/null +++ b/netbox/project-static/css/rack_elevation.css @@ -0,0 +1,58 @@ +/* Stylesheet for rendering SVG rack elevations */ +* { + font-family: sans-serif; + font-size: 13px; +} +rect { + box-sizing: border-box; +} +text { + text-anchor: middle; + dominant-baseline: middle; +} +.rack { + background-color: #f0f0f0; + fill: none; + stroke: black; + stroke-width: 3px; +} +.slot { + fill: #f7f7f7; + stroke: #a0a0a0; +} +.slot:hover { + fill: #fff; +} +.slot+.add-device { + fill: none; +} +.slot:hover+.add-device { + fill: blue; +} +.add-device:hover { + fill: blue; +} +.add-device:hover+.slot { + fill: #fff; +} +.reserved { + fill: url(#reserved); +} +.reserved:hover { + fill: url(#reserved); +} +.occupied { + fill: url(#occupied); +} +.occupied:hover { + fill: url(#occupied); +} +.blocked { + fill: url(#blocked); +} +.blocked:hover { + fill: url(#blocked); +} +.blocked:hover+.add-device { + fill: none; +}