From b01d96b5b3fe86e70321caf9bd21e11ec5195e44 Mon Sep 17 00:00:00 2001 From: gorban Date: Tue, 11 Feb 2020 12:50:41 +0300 Subject: [PATCH] CHanged VLAN table in device panel --- netbox/project-static/js/interface_toggles.js | 18 +- netbox/templates/dcim/device.html | 9 +- netbox/templates/dcim/inc/interface.html | 160 +++++++++++++++--- 3 files changed, 159 insertions(+), 28 deletions(-) diff --git a/netbox/project-static/js/interface_toggles.js b/netbox/project-static/js/interface_toggles.js index df8ac064b..147373335 100644 --- a/netbox/project-static/js/interface_toggles.js +++ b/netbox/project-static/js/interface_toggles.js @@ -2,9 +2,23 @@ $('button.toggle-ips').click(function() { var selected = $(this).attr('selected'); if (selected) { - $('#interfaces_table tr.interface:visible + tr.ipaddresses').hide(); + $('.ipaddresses').hide(); } else { - $('#interfaces_table tr.interface:visible + tr.ipaddresses').show(); + $('.ipaddresses').show(); + } + $(this).attr('selected', !selected); + $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked'); + return false; +}); + + +//Toggle the display of VLANs +$('button.toggle-vlans').click(function(){ + var selected = $(this).attr('selected'); + if (selected) { + $('.vlans').hide(); + } else { + $('.vlans').show(); } $(this).attr('selected', !selected); $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked'); diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index fdb5aec08..e15a0710e 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -571,6 +571,11 @@ +{# #} +{#
#} +
@@ -585,8 +590,8 @@ Name LAG Description - Tagged vlans - Untagged vlan +{# Tagged VLANs#} +{# Untagged VLAN#} MTU Mode Cable diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index e5bbe6d06..d19c6e392 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -39,21 +39,21 @@ {#Tagged ports#} - - {% if iface.tagged_vlans.all %} - {% for tag in iface.tagged_vlans.all %} - {{ tag }} -
- {% endfor %} - {% endif %} - - +{# #} +{# {% if iface.tagged_vlans.all %}#} +{# {% for tag in iface.tagged_vlans.all %}#} +{# {{ tag }}#} +{#
#} +{# {% endfor %}#} +{# {% endif %}#} +{# #} +{##} {#Untagged ports#} - - {% if iface.untagged_vlan %} - {{ iface.untagged_vlan }} - {% endif %} - +{# #} +{# {% if iface.untagged_vlan %}#} +{# {{ iface.untagged_vlan }}#} +{# {% endif %}#} +{# #} {# MTU #} {{ iface.mtu|default:"—" }} @@ -201,16 +201,17 @@ + {% with ipaddresses=iface.ip_addresses.all %} {% if ipaddresses %} - - {# Placeholder #} + +{# Placeholder#} {% if perms.dcim.change_interface or perms.dcim.delete_interface %} - + {% endif %} - {# IP addresses table #} - +{# IP addresses table#} + @@ -224,12 +225,12 @@ {% for ip in iface.ip_addresses.all %} - {# IP address #} +{# IP address#} - {# Primary/status/role #} +{# Primary/status/role#} - {# VRF #} +{# VRF#} - {# Description #} +{# Description#} - {# Buttons #} +{# Buttons#} {% endif %} {% endwith %} + +{% if iface.untagged_vlan or iface.tagged_vlans.all %} + + {# Placeholder#} + {% if perms.dcim.change_interface or perms.dcim.delete_interface %} + + {% endif %} + + {# VLAN table #} + + +{% endif %} +
{{ ip }} {% if device.primary_ip4 == ip or device.primary_ip6 == ip %} Primary @@ -240,7 +241,7 @@ {% endif %} {% if ip.vrf %} {{ ip.vrf.name }} @@ -249,7 +250,7 @@ {% endif %} {% if ip.description %} {{ ip.description }} @@ -258,7 +259,7 @@ {% endif %} {% if perms.ipam.change_ipaddress %} @@ -279,3 +280,114 @@
+ + + + + + + + + + + + + {# Untagged VLAN #} + {% if iface.untagged_vlan %} + + {# VLAN ID #} + + {# VLAN tag status #} + + {# VLAN name #} + + {# VLAN status #} + + {# VLAN description #} + + {# VLAN buttons #} + + {% endif %} + + + {# Tagged VLANs #} + + {% if iface.tagged_vlans.all %} + {% for tag in iface.tagged_vlans.all %} + + {# VLAN ID #} + + {# VLAN tag #} + + {# VLAN name #} + + {# VLAN status #} + + {# VLAN description #} + + {# VLAN buttons #} + + + {% endfor %} + {% endif %} +
IDTaggedNameStatusDescription
+ {{ iface.untagged_vlan.id }} + + +
  • +
    +
    {{ iface.untagged_vlan.name }} + {{ iface.untagged_vlan.status }} + {{ iface.untagged_vlan.description }} + {% if perms.ipam.change_vlan %} + + + + {% endif %} + {% if perms.ipam.delete_ipaddress %} + + + + {% endif %} +
    + {{ tag.id }} + + +
  • +
    +
    {{ tag.name }} + {{ tag.status }} + {{ tag.description }} + {% if perms.ipam.change_vlan %} + + + + {% endif %} + {% if perms.ipam.delete_ipaddress %} + + + + {% endif %} +
    +