Просмотр исходного кода

Move rack elevation CSS to project-static/rack_elevation.css

Jeremy Stretch 6 лет назад
Родитель
Сommit
aefe2b4196

+ 0 - 61
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

+ 2 - 1
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')

+ 58 - 0
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;
+}