IP Addresses not shown on filtered Interface list #3221

Closed
opened 2025-12-29 18:26:51 +01:00 by adam · 1 comment
Owner

Originally created by @Alestor on GitHub (Jan 25, 2020).

Originally assigned to: @hSaria on GitHub.

Environment

  • Python version: 3.5.3
  • NetBox version: 2.7.2

Steps to Reproduce

  1. Choose a Device
  2. Scroll down to Interfaces and set a filter
  3. Check 'Show IPs'

Expected Behavior

The IP Addresses for the filtered Interface will be displayed.

Observed Behavior

Only the Headers for the IP Information are displayed (IP Address | Status/Role | VRF | Description)

Originally created by @Alestor on GitHub (Jan 25, 2020). Originally assigned to: @hSaria on GitHub. <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.5.3 * NetBox version: 2.7.2 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Choose a Device 2. Scroll down to Interfaces and set a filter 3. Check 'Show IPs' <!-- What did you expect to happen? --> ### Expected Behavior The IP Addresses for the filtered Interface will be displayed. <!-- What happened instead? --> ### Observed Behavior Only the Headers for the IP Information are displayed (IP Address | Status/Role | VRF | Description)
adam added the type: bugstatus: accepted labels 2025-12-29 18:26:51 +01:00
adam closed this issue 2025-12-29 18:26:51 +01:00
Author
Owner

@hSaria commented on GitHub (Jan 25, 2020):

A few things going here:

  • The checkbox ignores whether an interface is visible or not (fixed by checking that the previous interface row is visible)
  • The IP addresses row is being hidden as it doesn't technically "match" (fixed by next on all visible interfaces at the end)
  • The selector is not very specific, causing it to hide the IP nested rows (fixed by changing the interfaces selector)

All fixed with

--- a/netbox/project-static/js/interface_toggles.js
+++ b/netbox/project-static/js/interface_toggles.js
@@ -2,9 +2,9 @@
 $('button.toggle-ips').click(function() {
     var selected = $(this).attr('selected');
     if (selected) {
-        $('#interfaces_table tr.ipaddresses').hide();
+        $('#interfaces_table tr.interface:visible + tr.ipaddresses').hide();
     } else {
-        $('#interfaces_table tr.ipaddresses').show();
+        $('#interfaces_table tr.interface:visible + tr.ipaddresses').show();
     }
     $(this).attr('selected', !selected);
     $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
@@ -15,7 +15,7 @@ $('button.toggle-ips').click(function() {
 $('input.interface-filter').on('input', function() {
     var filter = new RegExp(this.value);
 
-    for (interface of $(this).closest('div.panel').find('tbody > tr')) {
+    for (interface of $('#interfaces_table > tbody > tr')) {
         // Slice off 'interface_' at the start of the ID
         if (filter && filter.test(interface.id.slice(10))) {
             // Match the toggle in case the filter now matches the interface
@@ -27,4 +27,9 @@ $('input.interface-filter').on('input', function() {
             $(interface).hide();
         }
     }
+
+    // Show the ip addresses table row for the visible (matched) interfaces, if checked
+    if ($('button.toggle-ips').attr('selected')) {
+        $('#interfaces_table > tbody > tr:visible').next('tr.ipaddresses').show();
+    }
 });

Although now this brings up the idea of searching based on an IP address

@hSaria commented on GitHub (Jan 25, 2020): A few things going here: * The checkbox ignores whether an interface is visible or not (fixed by checking that the previous interface row is visible) * The IP addresses row is being hidden as it doesn't technically "match" (fixed by `next` on all visible interfaces at the end) * The selector is not very specific, causing it to hide the IP nested rows (fixed by changing the interfaces selector) All fixed with ```diff --- a/netbox/project-static/js/interface_toggles.js +++ b/netbox/project-static/js/interface_toggles.js @@ -2,9 +2,9 @@ $('button.toggle-ips').click(function() { var selected = $(this).attr('selected'); if (selected) { - $('#interfaces_table tr.ipaddresses').hide(); + $('#interfaces_table tr.interface:visible + tr.ipaddresses').hide(); } else { - $('#interfaces_table tr.ipaddresses').show(); + $('#interfaces_table tr.interface:visible + tr.ipaddresses').show(); } $(this).attr('selected', !selected); $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked'); @@ -15,7 +15,7 @@ $('button.toggle-ips').click(function() { $('input.interface-filter').on('input', function() { var filter = new RegExp(this.value); - for (interface of $(this).closest('div.panel').find('tbody > tr')) { + for (interface of $('#interfaces_table > tbody > tr')) { // Slice off 'interface_' at the start of the ID if (filter && filter.test(interface.id.slice(10))) { // Match the toggle in case the filter now matches the interface @@ -27,4 +27,9 @@ $('input.interface-filter').on('input', function() { $(interface).hide(); } } + + // Show the ip addresses table row for the visible (matched) interfaces, if checked + if ($('button.toggle-ips').attr('selected')) { + $('#interfaces_table > tbody > tr:visible').next('tr.ipaddresses').show(); + } }); ``` Although now this brings up the idea of searching based on an IP address
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3221