Lab as a Service 2.0
[laas.git] / src / templates / config_bundle / steps / define_software.html
1 {% extends "workflow/viewport-element.html" %}
2 {% load staticfiles %}
3
4 {% load bootstrap3 %}
5
6
7 {% block extrahead %}
8     <!-- DataTables CSS -->
9     <link href="{% static "bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" %}"
10           rel="stylesheet">
11
12     <!-- DataTables Responsive CSS -->
13     <link href="{% static "bower_components/datatables-responsive/css/dataTables.responsive.css" %}" rel="stylesheet">
14 {% endblock extrahead %}
15
16 {% block content %}
17 {% if error %}
18     <h1 style="text-align:center;">{{ error }}</h1>
19 {% else %}
20     <form style="width: 90%; margin: 5%;" method="post" action="" class="form" id="softwaredefinitionform">
21         {% csrf_token %}
22
23     <div class="row">
24         <div class="col-lg-12">
25                     <div class="dataTables_wrapper">
26                         <table class="table table-striped table-bordered table-hover" id="table" cellspacing="0"
27                                width="100%">
28
29                             {% block table %}
30                                 <thead>
31                                     <tr>
32                                         <th>Device</th>
33                                         <th>Role</th>
34                                         <th>Image</th>
35                                     </tr>
36                                 </thead>
37                                 <tbody>
38                             {% for form in formset %}
39                                 <tr>
40                                 {% for field in form %}
41                                     <td>{{ field }}</td>
42                                 {% endfor %}
43                                 </tr>
44                             {% endfor %}
45                             {{formset.management_form}}
46
47                             {% endblock table %}
48
49                         </table>
50                     </div>
51                     <!-- /.table-responsive -->
52                 <!-- /.panel-body -->
53             <!-- /.panel -->
54         </div>
55         <!-- /.col-lg-12 -->
56     </div>
57     </form>
58
59     <script>
60 function filter_images(){
61     var filter_data = {{filter_data|safe}};
62     for(var key in filter_data){
63         var dropdown = document.getElementById(key);
64         var to_remove = filter_data[key];
65         for(var i=0; i<to_remove.length; i++){
66             for(var j=dropdown.children.length-1; j>=0; j--){
67                 if(dropdown.children[j].text == to_remove[i]){
68                     dropdown.removeChild(dropdown.children[j]);
69                 }
70             }
71         }
72     }
73 }
74
75 filter_images();
76     </script>
77 {% endif %}
78 {% endblock content %}
79
80 {% block extrajs %}
81     {{ block.super }}
82     <!-- DataTables JavaScript -->
83
84     <script src={% static "bower_components/datatables/media/js/jquery.dataTables.min.js" %}></script>
85     <script src={% static "bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js" %}></script>
86
87     <script src={% static "js/dataTables-sort.js" %}></script>
88
89     {% block tablejs %}
90     {% endblock tablejs %}
91 {% endblock extrajs %}
92
93
94 {% block onleave %}
95 var form = $("#softwaredefinitionform");
96 var formData = form.serialize();
97 var req = new XMLHttpRequest();
98 req.open("POST", "/wf/workflow/", false);
99 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
100 req.onerror = function() { alert("problem with form submission"); }
101 req.send(formData);
102 {% endblock %}