Add child interfaces table to interface view

This commit is contained in:
jeremystretch 2021-04-02 17:33:34 -04:00
parent f28edd0864
commit 72a115b434
2 changed files with 25 additions and 0 deletions

View File

@ -1847,6 +1847,14 @@ class InterfaceView(generic.ObjectView):
orderable=False
)
# Get child interfaces
child_interfaces = Interface.objects.restrict(request.user, 'view').filter(parent=instance)
child_interfaces_tables = tables.InterfaceTable(
child_interfaces,
orderable=False
)
child_interfaces_tables.columns.hide('device')
# Get assigned VLANs and annotate whether each is tagged or untagged
vlans = []
if instance.untagged_vlan is not None:
@ -1863,6 +1871,7 @@ class InterfaceView(generic.ObjectView):
return {
'ipaddress_table': ipaddress_table,
'child_interfaces_table': child_interfaces_tables,
'vlan_table': vlan_table,
'breadcrumb_url': 'dcim:device_interfaces'
}

View File

@ -3,6 +3,15 @@
{% load plugins %}
{% load render_table from django_tables2 %}
{% block buttons %}
{% if perms.dcim.add_interface and not object.is_virtual %}
<a href="{% url 'dcim:interface_add' %}?device={{ object.device.pk }}&parent={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-success">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Child Interface
</a>
{% endif %}
{{ block.super }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-6">
@ -266,6 +275,13 @@
{% include 'panel_table.html' with table=vlan_table heading="VLANs" %}
</div>
</div>
{% if not object.is_virtual %}
<div class="row">
<div class="col-md-12">
{% include 'panel_table.html' with table=child_interfaces_table heading="Child Interfaces" %}
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-12">
{% plugin_full_width_page object %}