1 {% extends "base.html" %}
8 grid-template-columns: repeat(12, 1fr);
13 box-shadow: 0px 0px 7px 0px rgba(0,0,0,0.75);
18 grid-column-start: span 12;
21 grid-column-start: span 6;
23 .grid_element_1third {
24 grid-column-start: span 4;
26 .grid_element_2third {
27 grid-column-start: span 8;
30 {% bootstrap_form_errors form type='non_fields' %}
31 <form id="quick_booking_form" action="/booking/quick/" method="POST" class="form">
33 <div class="grid_container">
34 <div class="grid_element host_select_pane grid_element_wide">
35 <p>Please select a host type you wish to book. Only available types are shown.</p>
36 {% bootstrap_field form.filter_field show_label=False %}
38 <div class="grid_element booking_info_pane grid_element_1third">
39 {% bootstrap_field form.purpose %}
40 {% bootstrap_field form.project %}
41 {% bootstrap_field form.length %}
42 <p style="display:inline;">Days: </p><output id="daysout" style="display:inline;">0</output>
44 document.getElementById("id_length").setAttribute("oninput", "daysout.value=this.value");
45 document.getElementById("daysout").value = document.getElementById("id_length").value;
48 <div class="grid_element collaborator_pane grid_element_1third">
49 <label>Collaborators</label>
52 <div class="grid_element_1third">
53 <div class="configuration_pane grid_element">
54 {% bootstrap_field form.hostname %}
55 {% bootstrap_field form.image %}
57 <div class="configuration_pane grid_element">
58 <strong>OPNFV: (Optional)</strong>
59 {% bootstrap_field form.installer %}
60 {% bootstrap_field form.scenario %}
64 <script type="text/javascript">
65 var normalize = function(data)
67 //converts the top level keys in data to map to lists
69 for( var key in data ){
71 for( var subkey in data[key] ){
72 normalized[key].push(data[key][subkey]);
77 var update_page_contents = function(response)
80 document.write(response);
85 submit_form = function()
87 //altered from initial prototype: form submits automatically,
88 //but needs formatting for multiple select field
89 var data = normalize(result);
90 data = JSON.stringify(data);
91 document.getElementById("filter_field").value = data;
94 var sup_image_dict = {{ image_filter|safe }};
95 var sup_installer_dict = {{ installer_filter|safe }};
96 var sup_scenario_dict = {{ scenario_filter|safe }};
98 function imageHider() {
99 var data = normalize(result);
100 var drop = document.getElementById("id_image");
101 for( var i=0; i < drop.length; i++ )
103 if ( drop.options[i].text == '---------' )
105 drop.selectedIndex = i;
109 $('#id_image').children().hide();
113 for ( var i=0; i < drop.childNodes.length; i++ )
115 var image_object = sup_image_dict[drop.childNodes[i].value];
116 if( image_object ) //weed out empty option
119 for( var j in data["labs"][0] )
121 if( j in {} ) { continue; }
122 else { lab_pk = j; break; }
125 for( var j in data["hosts"][0] )
127 if( j in {} ) { continue; }
128 else { host_pk = j; break; }
130 if( image_object.host_profile == host_pk && image_object.lab == lab_pk )
132 drop.childNodes[i].style.display = "inherit";
138 $('#id_image').children().hide();
139 $('#id_installer').children().hide();
140 $('#id_scenario').children().hide();
143 Array.from(document.getElementsByClassName("grid-item-select-btn")).forEach(function(element) {
144 element.addEventListener('click', imageHider);
147 function installerHider() {
148 dropFilter("id_installer", sup_installer_dict, "id_image");
151 document.getElementById('id_image').addEventListener('change', installerHider);
153 function scenarioHider() {
154 dropFilter("id_scenario", sup_scenario_dict, "id_installer");
156 document.getElementById('id_installer').addEventListener('change', scenarioHider);
158 function dropFilter(target, target_filter, master) {
159 ob = document.getElementById(target);
161 for(var i=0; i<ob.options.length; i++) {
162 if ( ob.options[i].text == '---------' ) {
163 ob.selectedIndex = i;
167 targ_id = "#" + target;
168 $(targ_id).children().hide();
169 var drop = document.getElementById(master);
170 var opts = target_filter[drop.options[drop.selectedIndex].value];
176 var map = Object.create(null);
177 for (var i = 0; i < opts.length; i++) {
182 for (var i = 0; i < document.getElementById(target).childNodes.length; i++) {
183 if (document.getElementById(target).childNodes[i].value in opts && !(document.getElementById(target).childNodes[i].value in emptyMap) ) {
184 document.getElementById(target).childNodes[i].style.display = "inherit";
189 <button onclick="submit_form();" class="btn btn-success">Confirm</button>
193 var prefill_host_selection = "{{host_select_field_prefill_data|default:""|safe}}";
194 var prefill_purpose = "{{prefill_purpose|default:""|safe}}";
195 var prefill_project = "{{prefill_project|default:""|safe}}";
196 var prefill_hostname = "{{prefill_hostname|default:""|safe}}";
199 function prefill_host_select_field(data)
204 make_selection(data);
208 //call init functions
209 prefill_host_select_field(prefill_host_selection);