Added virtualization filters

This commit is contained in:
Jeremy Stretch
2017-08-16 17:00:17 -04:00
parent 2f2bd5fe70
commit fbf3eb612e
10 changed files with 281 additions and 20 deletions

View File

@@ -12,7 +12,7 @@
Import virtual machines
</a>
{% endif %}
{% include 'inc/export_button.html' with obj_type='virtualmachines' %}
{% include 'inc/export_button.html' with obj_type='virtual machines' %}
</div>
<h1>{% block title %}Virtual Machines{% endblock %}</h1>
<div class="row">
@@ -24,3 +24,32 @@
</div>
</div>
{% endblock %}
{% block javascript %}
<script type="text/javascript">
$(document).ready(function() {
var cluster_group_list = $('#id_cluster_group');
var cluster_list = $('#id_cluster_id');
// Update cluster options based on selected group
cluster_group_list.change(function() {
var selected_groups = $(this).val();
if (selected_groups) {
cluster_list.empty();
$.ajax({
url: netbox_api_path + 'virtualization/clusters/?limit=500&group=' + selected_groups.join('&group='),
dataType: 'json',
success: function (response, status) {
$.each(response["results"], function (index, cluster) {
var option = $("<option></option>").attr("value", cluster.id).text(cluster.name);
cluster_list.append(option);
});
}
});
}
});
});
</script>
{% endblock %}