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

Merge pull request #8983 from stephanblanke/8163-bridge-members-panel-in-interface-view

Closes #8163: Add bridge members panel to interface view
Jeremy Stretch 3 лет назад
Родитель
Сommit
9fca9ca7ec

+ 4 - 0
netbox/dcim/models/device_components.py

@@ -762,6 +762,10 @@ class Interface(ComponentModel, BaseInterface, LinkTermination, PathEndpoint):
     def is_lag(self):
         return self.type == InterfaceTypeChoices.TYPE_LAG
 
+    @property
+    def is_bridge(self):
+        return self.type == InterfaceTypeChoices.TYPE_BRIDGE
+
     @property
     def link(self):
         return self.cable or self.wireless_link

+ 9 - 0
netbox/dcim/views.py

@@ -1776,6 +1776,14 @@ class InterfaceView(generic.ObjectView):
             orderable=False
         )
 
+        # Get bridge interfaces
+        bridge_interfaces = Interface.objects.restrict(request.user, 'view').filter(bridge=instance)
+        bridge_interfaces_tables = tables.InterfaceTable(
+            bridge_interfaces,
+            exclude=('device', 'parent'),
+            orderable=False
+        )
+
         # Get child interfaces
         child_interfaces = Interface.objects.restrict(request.user, 'view').filter(parent=instance)
         child_interfaces_tables = tables.InterfaceTable(
@@ -1800,6 +1808,7 @@ class InterfaceView(generic.ObjectView):
 
         return {
             'ipaddress_table': ipaddress_table,
+            'bridge_interfaces_table': bridge_interfaces_tables,
             'child_interfaces_table': child_interfaces_tables,
             'vlan_table': vlan_table,
         }

+ 7 - 0
netbox/templates/dcim/interface.html

@@ -467,6 +467,13 @@
             {% include 'inc/panel_table.html' with table=vlan_table heading="VLANs" %}
         </div>
     </div>
+    {% if object.is_bridge %}
+    <div class="row mb-3">
+        <div class="col col-md-12">
+            {% include 'inc/panel_table.html' with table=bridge_interfaces_table heading="Bridge Interfaces" %}
+        </div>
+    </div>
+    {% endif %}
     <div class="row mb-3">
         <div class="col col-md-12">
             {% include 'inc/panel_table.html' with table=child_interfaces_table heading="Child Interfaces" %}