X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Ftemplates%2Fadmin%2Fcore%2Fslice%2Fchange_form.html;h=6800dfdf8283ddb578afebe06f5c5d38b41ccf51;hb=c337d32fe0372701ccd90d8212b21b88804ce351;hp=1084004af4e000ce84d26c66d72bea2095a1901b;hpb=ec23b99bb293e15eeae1c181fe8142f77cad81c1;p=plstackapi.git
diff --git a/planetstack/templates/admin/core/slice/change_form.html b/planetstack/templates/admin/core/slice/change_form.html
index 1084004..6800dfd 100644
--- a/planetstack/templates/admin/core/slice/change_form.html
+++ b/planetstack/templates/admin/core/slice/change_form.html
@@ -14,49 +14,107 @@ deployment_flavors = [
{% endfor %}
];
+deployment_images = [
+{% for dn in deployment_images %}
+ [{{ 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, node_select_id) {
+function option_html(val, text, selected) {
+ if (selected) {
+ return '\n';
+ } else {
+ return '\n';
+ }
+}
+
+function update_nodes(deployment_select, flavor_select, node_select) {
deployment_id = $(deployment_select).val();
- html = "\n";
+ node_id = $(node_select).val();
+ flavor_name = $(flavor_select).children(":selected").text()
+ html="";
for (i in deployment_nodes) {
+ // this is for EC2, where the node hostnames imply the flavor.
dn = deployment_nodes[i];
- if (dn[0] == deployment_id) {
- html = html + '\n'
+ if ((dn[0] == deployment_id) && (dn[2].lastIndexOf(flavor_name,0) === 0)) {
+ html = html + option_html(dn[1], dn[2], dn[1]==node_id);
+ }
+ }
+ 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_html(dn[1], dn[2], dn[1]==node_id);
+ }
}
}
- //console.log(html);
- $("#"+node_select_id).empty().append(html);
+ html = "\n" + html;
+ node_select.empty().append(html);
}
-function update_flavors(deployment_select, flavor_select_id) {
+function update_flavors(deployment_select, flavor_select) {
deployment_id = $(deployment_select).val();
+ flavor_id = $(flavor_select).val();
html = "\n";
for (i in deployment_flavors) {
dn = deployment_flavors[i];
if (dn[0] == deployment_id) {
- html = html + '\n'
+ html = html + option_html(dn[1], dn[2], dn[1] == flavor_id);
}
}
- //console.log(html);
- $("#"+flavor_select_id).empty().append(html);
+ flavor_select.empty().append(html);
}
-function sliver_deployment_changed(deployment_select) {
+function update_images(deployment_select, image_select) {
+ deployment_id = $(deployment_select).val();
+ image_id = $(image_select).val();
+ html = "\n";
+ for (i in deployment_images) {
+ dn = deployment_images[i];
+ if (dn[0] == deployment_id) {
+ html = html + option_html(dn[1], dn[2], dn[1] == image_id);
+ }
+ }
+ image_select.empty().append(html);
+}
+
+function sliver_deployment_changed(any_control) {
+ /* This function handles someone changing the deployment 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-node"
+ then find the child with class "field-deployment"
then find the child with that is a select
- then return its id
+ then return it's id
+ then turn it into a jquery object
+ */
+ deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deployment 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);
+ image_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-image select')[0].id);
+ update_nodes(deployment_select, flavor_select, node_select);
+ update_flavors(deployment_select, flavor_select);
+ update_images(deployment_select, image_select);
+}
+
+function sliver_flavor_changed(any_control) {
+ /* this is like sliver_flavor changed, but does not update the flavors
+ control
*/
- 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);
+ deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deployment 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) {