From 502b66367c176db17e92694eed6e3c2453a1a73a Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 16 Oct 2020 17:01:55 -0400 Subject: [PATCH] Convert VM interfaces list to table --- .../virtualization/inc/vminterface.html | 136 ------------------ .../virtualization/virtualmachine.html | 25 +--- netbox/virtualization/tables.py | 34 +++++ netbox/virtualization/views.py | 8 +- 4 files changed, 41 insertions(+), 162 deletions(-) delete mode 100644 netbox/templates/virtualization/inc/vminterface.html diff --git a/netbox/templates/virtualization/inc/vminterface.html b/netbox/templates/virtualization/inc/vminterface.html deleted file mode 100644 index 93efafb5a..000000000 --- a/netbox/templates/virtualization/inc/vminterface.html +++ /dev/null @@ -1,136 +0,0 @@ -{% load helpers %} - - - {# Checkbox #} - {% if perms.virtualization.change_vminterface or perms.virtualization.delete_vminterface %} - - - - {% endif %} - - {# Name #} - - {{ iface }} - - - {# MAC address #} - - {{ iface.mac_address|default:"—" }} - - - {# MTU #} - {{ iface.mtu|default:"—" }} - - {# 802.1Q mode #} - {{ iface.get_mode_display|default:"—" }} - - {# Description/tags #} - - {% if iface.description %} - {{ iface.description }}
- {% endif %} - {% for tag in iface.tags.all %} - {% tag tag %} - {% empty %} - {% if not iface.description %}—{% endif %} - {% endfor %} - - - {# Buttons #} - - {% if perms.ipam.add_ipaddress %} - - - - {% endif %} - {% if perms.virtualization.change_vminterface %} - - - - {% endif %} - {% if perms.virtualization.delete_vminterface %} - - - - {% endif %} - - - -{% with ipaddresses=iface.ip_addresses.all %} - {% if ipaddresses %} - - {# Placeholder #} - {% if perms.virtualization.change_vminterface or perms.virtualization.delete_vminterface %} - - {% endif %} - - {# IP addresses table #} - - - - - - - - - - - - {% for ip in iface.ip_addresses.all %} - - - {# IP address #} - - - {# Primary/status/role #} - - - {# VRF #} - - - {# Description #} - - - {# Buttons #} - - - - {% endfor %} -
IP AddressStatus/RoleVRFDescription
- {{ ip }} - - {% if virtualmachine.primary_ip4 == ip or virtualmachine.primary_ip6 == ip %} - Primary - {% endif %} - {{ ip.get_status_display }} - {% if ip.role %} - {{ ip.get_role_display }} - {% endif %} - - {% if ip.vrf %} - {{ ip.vrf.name }} - {% else %} - Global - {% endif %} - - {% if ip.description %} - {{ ip.description }} - {% else %} - - {% endif %} - - {% if perms.ipam.change_ipaddress %} - - - - {% endif %} - {% if perms.ipam.delete_ipaddress %} - - - - {% endif %} -
- - - {% endif %} -{% endwith %} diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html index b72eec571..a2213aee1 100644 --- a/netbox/templates/virtualization/virtualmachine.html +++ b/netbox/templates/virtualization/virtualmachine.html @@ -280,30 +280,7 @@ - - - - {% if perms.virtualization.change_vminterface or perms.virtualization.delete_vminterface %} - - {% endif %} - - - - - - - - - - {% for iface in interfaces %} - {% include 'virtualization/inc/vminterface.html' %} - {% empty %} - - - - {% endfor %} - -
NameMAC AddressMTUModeDescription
— No interfaces defined —
+ {% include 'responsive_table.html' with table=vminterface_table %} {% if perms.virtualization.add_vminterface or perms.virtualization.delete_vminterface %}