mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Closes #3090: Filter field for interface
This commit is contained in:
		@@ -1,3 +1,9 @@
 | 
			
		||||
# v2.6.12 (FUTURE)
 | 
			
		||||
 | 
			
		||||
## Enhancements
 | 
			
		||||
 | 
			
		||||
* [#3090](https://github.com/netbox-community/netbox/issues/3090) - Add filter field for device interfaces
 | 
			
		||||
 | 
			
		||||
# v2.6.11 (2020-01-03)
 | 
			
		||||
 | 
			
		||||
## Bug Fixes
 | 
			
		||||
 
 | 
			
		||||
@@ -556,6 +556,9 @@
 | 
			
		||||
                                <span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
 | 
			
		||||
                            </button>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="col-md-2 pull-right noprint">
 | 
			
		||||
                            <input class="form-control interface-filter" type="text" placeholder="Filter (RegExp)" style="height: 24px" />
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
 | 
			
		||||
                        <thead>
 | 
			
		||||
@@ -912,6 +915,22 @@ $('button.toggle-ips').click(function() {
 | 
			
		||||
    $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
 | 
			
		||||
    return false;
 | 
			
		||||
});
 | 
			
		||||
$('input.interface-filter').on('input', function() {
 | 
			
		||||
    var filter = new RegExp(this.value);
 | 
			
		||||
 | 
			
		||||
    for (interface of $(this).closest('form').find('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
 | 
			
		||||
            $(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
 | 
			
		||||
            $(interface).show();
 | 
			
		||||
        } else {
 | 
			
		||||
            // Uncheck to prevent actions from including it when it doesn't match
 | 
			
		||||
            $(interface).find('input:checkbox[name=pk]').prop('checked', false);
 | 
			
		||||
            $(interface).hide();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
<script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
 | 
			
		||||
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -253,6 +253,9 @@
 | 
			
		||||
                        <span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
 | 
			
		||||
                    </button>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="col-md-2 pull-right noprint">
 | 
			
		||||
                    <input class="form-control interface-filter" type="text" placeholder="Filter (RegExp)" style="height: 24px" />
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
 | 
			
		||||
                <thead>
 | 
			
		||||
@@ -325,5 +328,21 @@ $('button.toggle-ips').click(function() {
 | 
			
		||||
    $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
 | 
			
		||||
    return false;
 | 
			
		||||
});
 | 
			
		||||
$('input.interface-filter').on('input', function() {
 | 
			
		||||
    var filter = new RegExp(this.value);
 | 
			
		||||
 | 
			
		||||
    for (interface of $(this).closest('form').find('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
 | 
			
		||||
            $(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
 | 
			
		||||
            $(interface).show();
 | 
			
		||||
        } else {
 | 
			
		||||
            // Uncheck to prevent actions from including it when it doesn't match
 | 
			
		||||
            $(interface).find('input:checkbox[name=pk]').prop('checked', false);
 | 
			
		||||
            $(interface).hide();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user