Sfoglia il codice sorgente

Closes #21268: Add Device Type details panel to Device view (#21368)

Martin Hauser 3 giorni fa
parent
commit
02ffdd9d5d
2 ha cambiato i file con 11 aggiunte e 2 eliminazioni
  1. 10 2
      netbox/dcim/ui/panels.py
  2. 1 0
      netbox/dcim/views.py

+ 10 - 2
netbox/dcim/ui/panels.py

@@ -90,7 +90,6 @@ class DevicePanel(panels.ObjectAttributesPanel):
     parent_device = attrs.TemplatedAttr('parent_bay', template_name='dcim/device/attrs/parent_device.html')
     gps_coordinates = attrs.GPSCoordinatesAttr()
     tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group')
-    device_type = attrs.RelatedObjectAttr('device_type', linkify=True, grouped_by='manufacturer')
     description = attrs.TextAttr('description')
     airflow = attrs.ChoiceAttr('airflow')
     serial = attrs.TextAttr('serial', label=_('Serial number'), style='font-monospace', copy_button=True)
@@ -122,10 +121,19 @@ class DeviceManagementPanel(panels.ObjectAttributesPanel):
     cluster = attrs.RelatedObjectAttr('cluster', linkify=True)
 
 
+class DeviceDeviceTypePanel(panels.ObjectAttributesPanel):
+    title = _('Device Type')
+
+    manufacturer = attrs.RelatedObjectAttr('device_type.manufacturer', linkify=True)
+    model = attrs.RelatedObjectAttr('device_type', linkify=True)
+    height = attrs.TextAttr('device_type.u_height', format_string='{}U')
+    front_image = attrs.ImageAttr('device_type.front_image')
+    rear_image = attrs.ImageAttr('device_type.rear_image')
+
+
 class DeviceDimensionsPanel(panels.ObjectAttributesPanel):
     title = _('Dimensions')
 
-    height = attrs.TextAttr('device_type.u_height', format_string='{}U')
     total_weight = attrs.TemplatedAttr('total_weight', template_name='dcim/device/attrs/total_weight.html')
 
 

+ 1 - 0
netbox/dcim/views.py

@@ -2470,6 +2470,7 @@ class DeviceView(generic.ObjectView):
                 ],
             ),
             ImageAttachmentsPanel(),
+            panels.DeviceDeviceTypePanel(),
             panels.DeviceDimensionsPanel(),
             TemplatePanel('dcim/panels/device_rack_elevations.html'),
         ],