Ver Fonte

Add child interfaces table to interface view

jeremystretch há 4 anos atrás
pai
commit
72a115b434
2 ficheiros alterados com 25 adições e 0 exclusões
  1. 9 0
      netbox/dcim/views.py
  2. 16 0
      netbox/templates/dcim/interface.html

+ 9 - 0
netbox/dcim/views.py

@@ -1847,6 +1847,14 @@ class InterfaceView(generic.ObjectView):
             orderable=False
             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
         # Get assigned VLANs and annotate whether each is tagged or untagged
         vlans = []
         vlans = []
         if instance.untagged_vlan is not None:
         if instance.untagged_vlan is not None:
@@ -1863,6 +1871,7 @@ class InterfaceView(generic.ObjectView):
 
 
         return {
         return {
             'ipaddress_table': ipaddress_table,
             'ipaddress_table': ipaddress_table,
+            'child_interfaces_table': child_interfaces_tables,
             'vlan_table': vlan_table,
             'vlan_table': vlan_table,
             'breadcrumb_url': 'dcim:device_interfaces'
             'breadcrumb_url': 'dcim:device_interfaces'
         }
         }

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

@@ -3,6 +3,15 @@
 {% load plugins %}
 {% load plugins %}
 {% load render_table from django_tables2 %}
 {% 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 %}
 {% block content %}
     <div class="row">
     <div class="row">
         <div class="col-md-6">
         <div class="col-md-6">
@@ -266,6 +275,13 @@
             {% include 'panel_table.html' with table=vlan_table heading="VLANs" %}
             {% include 'panel_table.html' with table=vlan_table heading="VLANs" %}
         </div>
         </div>
     </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="row">
         <div class="col-md-12">
         <div class="col-md-12">
             {% plugin_full_width_page object %}
             {% plugin_full_width_page object %}