| {% 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 %} |
| ]; |
| |
| site_login_bases = [ |
| {% for s in site_login_bases %} |
| [{{ s.0 }}, "{{ s.1 }}"], |
| {% endfor %} |
| ]; |
| |
| function update_nodes(deployment_select, flavor_select, node_select) { |
| deployment_id = $(deployment_select).val(); |
| flavor_name = $(flavor_select).children(":selected").text() |
| html=""; |
| for (i in deployment_nodes) { |
| dn = deployment_nodes[i]; |
| if ((dn[0] == deployment_id) && (dn[2].lastIndexOf(flavor_name,0) === 0)) { |
| html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n' |
| } |
| } |
| if (!html) { |
| // now try it without the flavor hostname prefix matching |
| for (i in deployment_nodes) { |
| dn = deployment_nodes[i]; |
| if (dn[0] == deployment_id) { |
| html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n' |
| } |
| } |
| } |
| html = "<option value=''>---------</option>\n" + html; |
| //console.log(html); |
| node_select.empty().append(html); |
| } |
| |
| function update_flavors(deployment_select, flavor_select) { |
| 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.empty().append(html); |
| } |
| |
| function sliver_deployment_changed(any_control) { |
| /* This function handles someone changing the deploymentNetwork control |
| in the add-sliver line. It updats the flavors and nodes dialogs |
| accordingly. |
| */ |
| |
| /* the inscrutable jquery selector below says: |
| find the closest parent "tr" to the current element |
| then find the child with class "field-deploymentNetwork" |
| then find the child with that is a select |
| then return it's id |
| then turn it into a jquery object |
| */ |
| deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deploymentNetwork select')[0].id); |
| node_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-node select')[0].id); |
| flavor_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-flavor select')[0].id); |
| update_nodes(deployment_select, flavor_select, node_select); |
| update_flavors(deployment_select, flavor_select); |
| } |
| |
| function sliver_flavor_changed(any_control) { |
| /* this is like sliver_flavor changed, but does not update the flavors |
| control |
| */ |
| deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deploymentNetwork select')[0].id); |
| node_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-node select')[0].id); |
| flavor_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-flavor select')[0].id); |
| update_nodes(deployment_select, flavor_select, node_select); |
| } |
| |
| function update_slice_prefix(site_select, slice_name_id) { |
| site_id = $(site_select).val(); |
| slice_prefix=""; |
| for (i in site_login_bases) { |
| if (site_login_bases[i][0] == site_id) { |
| slice_prefix=site_login_bases[i][1]+"_"; |
| } |
| } |
| $("#"+slice_name_id).val(slice_prefix); |
| } |
| </script> |
| |
| {% endblock %} |
| |