Răsfoiți Sursa

Closes #4290: Include device name in tooltip on rack elevations

Jeremy Stretch 6 ani în urmă
părinte
comite
1e4dd102bd
2 a modificat fișierele cu 13 adăugiri și 8 ștergeri
  1. 1 0
      docs/release-notes/version-2.7.md
  2. 12 8
      netbox/dcim/elevations.py

+ 1 - 0
docs/release-notes/version-2.7.md

@@ -7,6 +7,7 @@
 * [#3949](https://github.com/netbox-community/netbox/issues/3949) - Revised the installation docs and upgrade script to employ a Python virtual environment
 * [#3949](https://github.com/netbox-community/netbox/issues/3949) - Revised the installation docs and upgrade script to employ a Python virtual environment
 * [#4281](https://github.com/netbox-community/netbox/issues/4281) - Allow filtering device component list views by type
 * [#4281](https://github.com/netbox-community/netbox/issues/4281) - Allow filtering device component list views by type
 * [#4284](https://github.com/netbox-community/netbox/issues/4284) - Add MRJ21 port and cable types
 * [#4284](https://github.com/netbox-community/netbox/issues/4284) - Add MRJ21 port and cable types
+* [#4290](https://github.com/netbox-community/netbox/issues/4290) - Include device name in tooltip on rack elevations
 * [#4305](https://github.com/netbox-community/netbox/issues/4305) - Add 10-inch option for rack width
 * [#4305](https://github.com/netbox-community/netbox/issues/4305) - Add 10-inch option for rack width
 
 
 ## Bug Fixes
 ## Bug Fixes

+ 12 - 8
netbox/dcim/elevations.py

@@ -20,6 +20,16 @@ class RackElevationSVG:
         self.rack = rack
         self.rack = rack
         self.include_images = include_images
         self.include_images = include_images
 
 
+    def _get_device_description(self, device):
+        return '{} ({}) — {} ({}U) {} {}'.format(
+            device.name,
+            device.device_role,
+            device.device_type.display_name,
+            device.device_type.u_height,
+            device.asset_tag or '',
+            device.serial or ''
+        )
+
     @staticmethod
     @staticmethod
     def _add_gradient(drawing, id_, color):
     def _add_gradient(drawing, id_, color):
         gradient = drawing.linearGradient(
         gradient = drawing.linearGradient(
@@ -64,10 +74,7 @@ class RackElevationSVG:
                 fill='black'
                 fill='black'
             )
             )
         )
         )
-        link.set_desc('{} — {} ({}U) {} {}'.format(
-            device.device_role, device.device_type.display_name,
-            device.device_type.u_height, device.asset_tag or '', device.serial or ''
-        ))
+        link.set_desc(self._get_device_description(device))
         link.add(drawing.rect(start, end, style='fill: #{}'.format(color), class_='slot'))
         link.add(drawing.rect(start, end, style='fill: #{}'.format(color), class_='slot'))
         hex_color = '#{}'.format(foreground_color(color))
         hex_color = '#{}'.format(foreground_color(color))
         link.add(drawing.text(str(name), insert=text, fill=hex_color))
         link.add(drawing.text(str(name), insert=text, fill=hex_color))
@@ -81,10 +88,7 @@ class RackElevationSVG:
 
 
     def _draw_device_rear(self, drawing, device, start, end, text):
     def _draw_device_rear(self, drawing, device, start, end, text):
         rect = drawing.rect(start, end, class_="slot blocked")
         rect = drawing.rect(start, end, class_="slot blocked")
-        rect.set_desc('{} — {} ({}U) {} {}'.format(
-            device.device_role, device.device_type.display_name,
-            device.device_type.u_height, device.asset_tag or '', device.serial or ''
-        ))
+        rect.set_desc(self._get_device_description(device))
         drawing.add(rect)
         drawing.add(rect)
         drawing.add(drawing.text(str(device), insert=text))
         drawing.add(drawing.text(str(device), insert=text))