Scott Baker | 510fdbb | 2014-08-05 17:19:24 -0700 | [diff] [blame] | 1 | {% extends 'admin/change_form.html' %} |
Scott Baker | 7a61dc4 | 2014-09-02 17:08:20 -0700 | [diff] [blame] | 2 | {% block extrahead %} |
Scott Baker | 510fdbb | 2014-08-05 17:19:24 -0700 | [diff] [blame] | 3 | {{ block.super }} |
| 4 | <script> |
| 5 | deployment_nodes = [ |
| 6 | {% for dn in deployment_nodes %} |
| 7 | [{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"], |
| 8 | {% endfor %} |
| 9 | ]; |
Scott Baker | 34b502f | 2014-08-05 18:33:31 -0700 | [diff] [blame] | 10 | |
Scott Baker | 7a61dc4 | 2014-09-02 17:08:20 -0700 | [diff] [blame] | 11 | deployment_flavors = [ |
| 12 | {% for dn in deployment_flavors %} |
| 13 | [{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"], |
| 14 | {% endfor %} |
| 15 | ]; |
| 16 | |
Tony Mack | 7283fdf | 2014-09-02 00:37:36 -0400 | [diff] [blame] | 17 | sites = [ |
| 18 | {% for s in sites %} |
| 19 | [{{ s.0 }}, {{ s.1 }}], |
| 20 | {% endfor %} |
| 21 | ]; |
Scott Baker | 7a61dc4 | 2014-09-02 17:08:20 -0700 | [diff] [blame] | 22 | |
Tony Mack | 7283fdf | 2014-09-02 00:37:36 -0400 | [diff] [blame] | 23 | |
Scott Baker | 34b502f | 2014-08-05 18:33:31 -0700 | [diff] [blame] | 24 | function update_nodes(deployment_select, node_select_id) { |
| 25 | deployment_id = $(deployment_select).val(); |
| 26 | html = "<option value=''>---------</option>\n"; |
| 27 | for (i in deployment_nodes) { |
| 28 | dn = deployment_nodes[i]; |
| 29 | if (dn[0] == deployment_id) { |
| 30 | html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n' |
| 31 | } |
| 32 | } |
| 33 | //console.log(html); |
| 34 | $("#"+node_select_id).empty().append(html); |
| 35 | } |
Tony Mack | 7283fdf | 2014-09-02 00:37:36 -0400 | [diff] [blame] | 36 | |
Scott Baker | 7a61dc4 | 2014-09-02 17:08:20 -0700 | [diff] [blame] | 37 | function update_flavors(deployment_select, flavor_select_id) { |
| 38 | deployment_id = $(deployment_select).val(); |
| 39 | html = "<option value=''>---------</option>\n"; |
| 40 | for (i in deployment_flavors) { |
| 41 | dn = deployment_flavors[i]; |
| 42 | if (dn[0] == deployment_id) { |
| 43 | html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n' |
| 44 | } |
| 45 | } |
| 46 | //console.log(html); |
| 47 | $("#"+flavor_select_id).empty().append(html); |
| 48 | } |
| 49 | |
| 50 | function sliver_deployment_changed(deployment_select) { |
| 51 | /* the inscrutable jquery selector below says: |
| 52 | find the closest parent "tr" to the current element |
| 53 | then find the child with class "field-node" |
| 54 | then find the child with that is a select |
| 55 | then return its id |
| 56 | */ |
| 57 | nodes_select_id = $($(deployment_select).closest('tr')[0]).find('.field-node select')[0].id; |
| 58 | update_nodes(deployment_select, nodes_select_id); |
| 59 | flavors_select_id = $($(deployment_select).closest('tr')[0]).find('.field-flavor select')[0].id; |
| 60 | update_flavors(deployment_select, flavors_select_id); |
| 61 | } |
| 62 | |
Tony Mack | 7283fdf | 2014-09-02 00:37:36 -0400 | [diff] [blame] | 63 | function update_slice_prefix(site_select, slice_name_id) { |
| 64 | site_id = $(site_select).val(); |
| 65 | slice_prefix=""; |
| 66 | if (site_id in sites) { |
| 67 | slice_prefix=sites[site_id]+"_"; |
| 68 | } |
| 69 | $("#"+slice_name_id).val(slice_prefix); |
| 70 | } |
Scott Baker | 510fdbb | 2014-08-05 17:19:24 -0700 | [diff] [blame] | 71 | </script> |
Scott Baker | 34b502f | 2014-08-05 18:33:31 -0700 | [diff] [blame] | 72 | |
Scott Baker | 510fdbb | 2014-08-05 17:19:24 -0700 | [diff] [blame] | 73 | {% endblock %} |
| 74 | |