blob: 9fb97583ca41a5adbddc8979b10ac5fe6bd22a32 [file] [log] [blame]
{% extends 'admin/change_form.html' %}
{% block extrahead %}
{{ block.super }}
<script>
deployment_nodes = [
{% for dn in deployment_nodes %}
[{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"],
{% endfor %}
];
deployment_flavors = [
{% for dn in deployment_flavors %}
[{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"],
{% endfor %}
];
sites = [
{% for s in sites %}
[{{ s.0 }}, {{ s.1 }}],
{% endfor %}
];
function update_nodes(deployment_select, node_select_id) {
deployment_id = $(deployment_select).val();
html = "<option value=''>---------</option>\n";
for (i in deployment_nodes) {
dn = deployment_nodes[i];
if (dn[0] == deployment_id) {
html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n'
}
}
//console.log(html);
$("#"+node_select_id).empty().append(html);
}
function update_flavors(deployment_select, flavor_select_id) {
deployment_id = $(deployment_select).val();
html = "<option value=''>---------</option>\n";
for (i in deployment_flavors) {
dn = deployment_flavors[i];
if (dn[0] == deployment_id) {
html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n'
}
}
//console.log(html);
$("#"+flavor_select_id).empty().append(html);
}
function sliver_deployment_changed(deployment_select) {
/* the inscrutable jquery selector below says:
find the closest parent "tr" to the current element
then find the child with class "field-node"
then find the child with that is a select
then return its id
*/
nodes_select_id = $($(deployment_select).closest('tr')[0]).find('.field-node select')[0].id;
update_nodes(deployment_select, nodes_select_id);
flavors_select_id = $($(deployment_select).closest('tr')[0]).find('.field-flavor select')[0].id;
update_flavors(deployment_select, flavors_select_id);
}
function update_slice_prefix(site_select, slice_name_id) {
site_id = $(site_select).val();
slice_prefix="";
if (site_id in sites) {
slice_prefix=sites[site_id]+"_";
}
$("#"+slice_name_id).val(slice_prefix);
}
</script>
{% endblock %}