mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #1414: Selecting a site from the rack filters automatically updates the available rack groups
This commit is contained in:
@ -25,3 +25,36 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
<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>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user