From 9eb9715e05d550d4f0d3d43f6349198d55852e49 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 3 Jul 2018 17:05:04 -0400 Subject: [PATCH] Cleaned up IP addresses list under device/VM interfaces --- netbox/project-static/css/base.css | 4 + netbox/templates/dcim/device.html | 4 +- netbox/templates/dcim/inc/interface.html | 122 ++++++++++++++--------- 3 files changed, 80 insertions(+), 50 deletions(-) diff --git a/netbox/project-static/css/base.css b/netbox/project-static/css/base.css index bd1570827..52656a505 100644 --- a/netbox/project-static/css/base.css +++ b/netbox/project-static/css/base.css @@ -366,6 +366,10 @@ table.component-list td.subtable td { padding-bottom: 6px; padding-top: 6px; } +table.interface-ips th { + font-size: 80%; + font-weight: normal; +} /* Reports */ table.reports td.method { diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 4984dad95..8a8bf5086 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -762,9 +762,9 @@ $(".interface-toggle").click(function() { $('button.toggle-ips').click(function() { var selected = $(this).attr('selected'); if (selected) { - $('#interfaces_table tr.ipaddress').hide(); + $('#interfaces_table tr.ipaddresses').hide(); } else { - $('#interfaces_table tr.ipaddress').show(); + $('#interfaces_table tr.ipaddresses').show(); } $(this).attr('selected', !selected); $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked'); diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index 33e30b126..b254794df 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -131,56 +131,82 @@ {% endif %} -{% for ip in iface.ip_addresses.all %} - - {# Placeholder #} - {% if perms.dcim.change_interface or perms.dcim.delete_interface %} - - {% endif %} - - {# IP address #} - - {{ ip }} - - - {# Primary, status, role #} - - {% if device.primary_ip4 == ip or device.primary_ip6 == ip %} - Primary +{% with ipaddresses=iface.ip_addresses.all %} + {% if ipaddresses %} + + {# Placeholder #} + {% if perms.dcim.change_interface or perms.dcim.delete_interface %} + {% endif %} - {{ ip.get_status_display }} - {% if ip.role %} - {{ ip.get_role_display }} - {% endif %} - - {# VRF #} - - {% if ip.vrf %} - {{ ip.vrf.name }} - {% else %} - Global - {% endif %} - + {# IP addresses table #} + + + + + + + + + + + + {% for ip in iface.ip_addresses.all %} + - {# Description #} - + {# IP address #} + - {# Buttons #} - - -{% endfor %} + {# Primary/status/role #} + + + {# VRF #} + + + {# Description #} + + + {# Buttons #} + + + + {% endfor %} +
IP AddressStatus/RoleVRFDescription
- {{ ip.description }} - + {{ ip }} + - {% if perms.ipam.change_ipaddress %} - - - - {% endif %} - {% if perms.ipam.delete_ipaddress %} - - - - {% endif %} -
+ {% if device.primary_ip4 == ip or device.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 %}