mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Merge pull request #3838 from hSaria/3090-interface-filtering
Fixes #3090: Interface filtering
This commit is contained in:
commit
959a0da0ed
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
* [#2050](https://github.com/netbox-community/netbox/issues/2050) - Preview image attachments when hovering the link
|
* [#2050](https://github.com/netbox-community/netbox/issues/2050) - Preview image attachments when hovering the link
|
||||||
* [#2589](https://github.com/netbox-community/netbox/issues/2589) - Toggle for showing available prefixes/ip addresses
|
* [#2589](https://github.com/netbox-community/netbox/issues/2589) - Toggle for showing available prefixes/ip addresses
|
||||||
|
* [#3090](https://github.com/netbox-community/netbox/issues/3090) - Add filter field for device interfaces
|
||||||
* [#3187](https://github.com/netbox-community/netbox/issues/3187) - Add rack selection field to rack elevations
|
* [#3187](https://github.com/netbox-community/netbox/issues/3187) - Add rack selection field to rack elevations
|
||||||
* [#3851](https://github.com/netbox-community/netbox/issues/3851) - Allow passing initial data to custom script forms
|
* [#3851](https://github.com/netbox-community/netbox/issues/3851) - Allow passing initial data to custom script forms
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
// "Toggle" checkbox for object lists (PK column)
|
// "Toggle" checkbox for object lists (PK column)
|
||||||
$('input:checkbox.toggle').click(function() {
|
$('input:checkbox.toggle').click(function() {
|
||||||
$(this).closest('table').find('input:checkbox[name=pk]').prop('checked', $(this).prop('checked'));
|
$(this).closest('table').find('input:checkbox[name=pk]:visible').prop('checked', $(this).prop('checked'));
|
||||||
|
|
||||||
// Show the "select all" box if present
|
// Show the "select all" box if present
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(':checked')) {
|
||||||
@ -400,8 +400,8 @@ $(document).ready(function() {
|
|||||||
window.addEventListener('hashchange', headerOffsetScroll);
|
window.addEventListener('hashchange', headerOffsetScroll);
|
||||||
|
|
||||||
// Offset between the preview window and the window edges
|
// Offset between the preview window and the window edges
|
||||||
const IMAGE_PREVIEW_OFFSET_X = 20
|
const IMAGE_PREVIEW_OFFSET_X = 20;
|
||||||
const IMAGE_PREVIEW_OFFSET_Y = 10
|
const IMAGE_PREVIEW_OFFSET_Y = 10;
|
||||||
|
|
||||||
// Preview an image attachment when the link is hovered over
|
// Preview an image attachment when the link is hovered over
|
||||||
$('a.image-preview').on('mouseover', function(e) {
|
$('a.image-preview').on('mouseover', function(e) {
|
||||||
@ -435,6 +435,6 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
// Fade the image out; it will be deleted when another one is previewed
|
// Fade the image out; it will be deleted when another one is previewed
|
||||||
$('a.image-preview').on('mouseout', function() {
|
$('a.image-preview').on('mouseout', function() {
|
||||||
$('#image-preview-window').fadeOut('fast')
|
$('#image-preview-window').fadeOut('fast');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
30
netbox/project-static/js/interface_toggles.js
Normal file
30
netbox/project-static/js/interface_toggles.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Toggle the display of IP addresses under interfaces
|
||||||
|
$('button.toggle-ips').click(function() {
|
||||||
|
var selected = $(this).attr('selected');
|
||||||
|
if (selected) {
|
||||||
|
$('#interfaces_table tr.ipaddresses').hide();
|
||||||
|
} else {
|
||||||
|
$('#interfaces_table tr.ipaddresses').show();
|
||||||
|
}
|
||||||
|
$(this).attr('selected', !selected);
|
||||||
|
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Inteface filtering
|
||||||
|
$('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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -556,6 +556,9 @@
|
|||||||
<span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
|
<span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-2 pull-right noprint">
|
||||||
|
<input class="form-control interface-filter" type="text" placeholder="Filter" title="RegEx-enabled" style="height: 23px" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
|
<table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -900,19 +903,8 @@ function toggleConnection(elem) {
|
|||||||
$(".cable-toggle").click(function() {
|
$(".cable-toggle").click(function() {
|
||||||
return toggleConnection($(this));
|
return toggleConnection($(this));
|
||||||
});
|
});
|
||||||
// Toggle the display of IP addresses under interfaces
|
|
||||||
$('button.toggle-ips').click(function() {
|
|
||||||
var selected = $(this).attr('selected');
|
|
||||||
if (selected) {
|
|
||||||
$('#interfaces_table tr.ipaddresses').hide();
|
|
||||||
} else {
|
|
||||||
$('#interfaces_table tr.ipaddresses').show();
|
|
||||||
}
|
|
||||||
$(this).attr('selected', !selected);
|
|
||||||
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
<script src="{% static 'js/interface_toggles.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
<script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
|
<script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
|
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% load custom_links %}
|
{% load custom_links %}
|
||||||
|
{% load static %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
@ -253,6 +254,9 @@
|
|||||||
<span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
|
<span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-2 pull-right noprint">
|
||||||
|
<input class="form-control interface-filter" type="text" placeholder="Filter" title="RegEx-enabled" style="height: 23px" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
|
<table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -312,18 +316,5 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
<script src="{% static 'js/interface_toggles.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
// Toggle the display of IP addresses under interfaces
|
|
||||||
$('button.toggle-ips').click(function() {
|
|
||||||
var selected = $(this).attr('selected');
|
|
||||||
if (selected) {
|
|
||||||
$('#interfaces_table tr.ipaddresses').hide();
|
|
||||||
} else {
|
|
||||||
$('#interfaces_table tr.ipaddresses').show();
|
|
||||||
}
|
|
||||||
$(this).attr('selected', !selected);
|
|
||||||
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user