mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Closes #1801: Update list of rack groups when selecting a site to filter by in rack elevations list
This commit is contained in:
parent
e6bcc4a3fe
commit
3064948d8c
29
netbox/templates/dcim/inc/filter_rack_group.html
Normal file
29
netbox/templates/dcim/inc/filter_rack_group.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
var site_list = $('#id_site');
|
||||||
|
var rack_group_list = $('#id_group_id');
|
||||||
|
|
||||||
|
// Update rack group and rack options based on selected site
|
||||||
|
site_list.change(function() {
|
||||||
|
var selected_sites = $(this).val();
|
||||||
|
if (selected_sites) {
|
||||||
|
|
||||||
|
// Update rack group options
|
||||||
|
rack_group_list.empty();
|
||||||
|
$.ajax({
|
||||||
|
url: netbox_api_path + 'dcim/rack-groups/?limit=500&site=' + selected_sites.join('&site='),
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (response, status) {
|
||||||
|
$.each(response["results"], function (index, group) {
|
||||||
|
var option = $("<option></option>").attr("value", group.id).text(group.name);
|
||||||
|
rack_group_list.append(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
@ -45,9 +45,10 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
{% include 'dcim/inc/filter_rack_group.html' %}
|
||||||
$(function() {
|
<script type="text/javascript">
|
||||||
$('[data-toggle="popover"]').popover()
|
$(function() {
|
||||||
})
|
$('[data-toggle="popover"]').popover()
|
||||||
</script>
|
})
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -21,34 +21,6 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
{% include 'dcim/inc/filter_rack_group.html' %}
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
var site_list = $('#id_site');
|
|
||||||
var rack_group_list = $('#id_group_id');
|
|
||||||
|
|
||||||
// Update rack group and rack options based on selected site
|
|
||||||
site_list.change(function() {
|
|
||||||
var selected_sites = $(this).val();
|
|
||||||
if (selected_sites) {
|
|
||||||
|
|
||||||
// Update rack group options
|
|
||||||
rack_group_list.empty();
|
|
||||||
$.ajax({
|
|
||||||
url: netbox_api_path + 'dcim/rack-groups/?limit=500&site=' + selected_sites.join('&site='),
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (response, status) {
|
|
||||||
$.each(response["results"], function (index, group) {
|
|
||||||
var option = $("<option></option>").attr("value", group.id).text(group.name);
|
|
||||||
rack_group_list.append(option);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user