Closes #8163: Add bridge members panel to interface view

This commit is contained in:
Stephan Blanke 2022-03-28 20:37:00 +02:00
parent 894665b067
commit b7e2ea1ca5
3 changed files with 20 additions and 0 deletions

View File

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

View File

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

View File

@ -467,6 +467,13 @@
{% include 'inc/panel_table.html' with table=vlan_table heading="VLANs" %} {% include 'inc/panel_table.html' with table=vlan_table heading="VLANs" %}
</div> </div>
</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="row mb-3">
<div class="col col-md-12"> <div class="col col-md-12">
{% include 'inc/panel_table.html' with table=child_interfaces_table heading="Child Interfaces" %} {% include 'inc/panel_table.html' with table=child_interfaces_table heading="Child Interfaces" %}