Lab as a Service 2.0
[laas.git] / src / templates / config_bundle / steps / config_software.html
1 {% extends "workflow/viewport-element.html" %}
2 {% load staticfiles %}
3
4 {% load bootstrap3 %}
5
6 {% block content %}
7
8 <form action="/wf/workflow/" method="POST" id="software_config_form" class="form">
9     {% csrf_token %}
10     <p>Give it a name:</p>
11     {{ form.name }}
12
13     <p>And a description:</p>
14     {{ form.description }}
15     <p>Install OPNFV?</p>
16     {{ form.opnfv }}
17     <p>Choose your:</p>
18     <table>
19         <thead>
20             <tr>
21                 <th>Installer</th>
22                 <th>Scenario</th>
23             </tr>
24         </thead>
25         <tbody>
26             <tr>
27                 <td>{{form.installer}}</td>
28                 <td>{{form.scenario}}</td>
29             </tr>
30         </tbody>
31     </table>
32
33 </form>
34
35 <script>
36 var supported = {{supported|safe}};
37 var installer_drop = document.getElementById("id_installer");
38 installer_drop.addEventListener("change", filter);
39 var scenario_drop = document.getElementById("id_scenario");
40 var scenario_options = {};
41 for(var i=0; i<scenario_drop.options.length; i++){
42     var option = scenario_drop.options[i];
43     scenario_options[option.text] = option;
44 }
45
46 scenario_drop.disabled=true;
47
48 function filter(){
49     //clear out existing options
50     while(scenario_drop.firstChild){
51         scenario_drop.removeChild(scenario_drop.firstChild)
52     }
53     var installer = installer_drop.options[installer_drop.selectedIndex].text;
54     var options = supported[installer];
55     for(var i=0; i<options.length; i++){
56         scenario_drop.appendChild(scenario_options[options[i]]);
57     }
58     scenario_drop.disabled = false;
59 }
60 </script>
61
62 {% endblock content %}
63
64 {% block onleave %}
65 var ajaxForm = $("#software_config_form");
66 var formData = ajaxForm.serialize();
67 req = new XMLHttpRequest();
68 req.open("POST", "/wf/workflow/", false);
69 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
70 req.onerror = function() { alert("problem submitting form"); }
71 req.send(formData);
72 {% endblock %}