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 -moz-appearance: none;
34 input[type=range]::-moz-range-track {
38 {% bootstrap_form_errors form type='non_fields' %}
39 <form id="quick_booking_form" action="/booking/quick/" method="POST" class="form">
41 <div class="grid_container">
42 <div class="grid_element host_select_pane grid_element_wide">
43 <p>Please select a host type you wish to book. Only available types are shown.</p>
44 {% bootstrap_field form.filter_field show_label=False %}
46 <div class="grid_element booking_info_pane grid_element_1third">
47 {% bootstrap_field form.purpose %}
48 {% bootstrap_field form.project %}
49 {% bootstrap_field form.length %}
50 <p style="display:inline;">Days: </p><output id="daysout" style="display:inline;">0</output>
52 document.getElementById("id_length").setAttribute("oninput", "daysout.value=this.value");
53 document.getElementById("daysout").value = document.getElementById("id_length").value;
56 <div class="grid_element collaborator_pane grid_element_1third">
57 <label>Collaborators</label>
60 <div class="grid_element_1third">
61 <div class="configuration_pane grid_element">
62 {% bootstrap_field form.hostname %}
63 {% bootstrap_field form.image %}
65 <div class="configuration_pane grid_element">
66 <strong>OPNFV: (Optional)</strong>
67 {% bootstrap_field form.installer %}
68 {% bootstrap_field form.scenario %}
72 <script type="text/javascript">
73 var normalize = function(data)
75 //converts the top level keys in data to map to lists
77 for( var key in data ){
79 for( var subkey in data[key] ){
80 normalized[key].push(data[key][subkey]);
85 var update_page_contents = function(response)
88 document.write(response);
93 submit_form = function()
95 //altered from initial prototype: form submits automatically,
96 //but needs formatting for multiple select field
97 var data = normalize(result);
98 data = JSON.stringify(data);
99 document.getElementById("filter_field").value = data;
102 var sup_image_dict = {{ image_filter|safe }};
103 var sup_installer_dict = {{ installer_filter|safe }};
104 var sup_scenario_dict = {{ scenario_filter|safe }};
106 function imageHider() {
107 var data = normalize(result);
108 var drop = document.getElementById("id_image");
109 for( var i=0; i < drop.length; i++ )
111 if ( drop.options[i].text == '---------' )
113 drop.selectedIndex = i;
117 $('#id_image').children().hide();
119 for( var i = 0; i < drop.childNodes.length; i++ )
121 drop.childNodes[i].disabled = true; // closest we can get on safari to hiding it outright
127 for ( var i=0; i < drop.childNodes.length; i++ )
129 var image_object = sup_image_dict[drop.childNodes[i].value];
130 if( image_object ) //weed out empty option
133 for( var j in data["labs"][0] )
135 if( j in {} ) { continue; }
136 else { lab_pk = j; break; }
139 for( var j in data["hosts"][0] )
141 if( j in {} ) { continue; }
142 else { host_pk = j; break; }
144 if( image_object.host_profile == host_pk && image_object.lab == lab_pk )
146 drop.childNodes[i].style.display = "inherit";
147 drop.childNodes[i].disabled = false;
154 $('#id_installer').children().hide();
155 $('#id_scenario').children().hide();
158 Array.from(document.getElementsByClassName("grid-item-select-btn")).forEach(function(element) {
159 element.addEventListener('click', imageHider);
162 function installerHider() {
163 dropFilter("id_installer", sup_installer_dict, "id_image");
166 document.getElementById('id_image').addEventListener('change', installerHider);
168 function scenarioHider() {
169 dropFilter("id_scenario", sup_scenario_dict, "id_installer");
171 document.getElementById('id_installer').addEventListener('change', scenarioHider);
173 function dropFilter(target, target_filter, master) {
174 ob = document.getElementById(target);
176 for(var i=0; i<ob.options.length; i++) {
177 if ( ob.options[i].text == '---------' ) {
178 ob.selectedIndex = i;
182 targ_id = "#" + target;
184 $(targ_id).children().hide();
186 for (var i = 0; i < document.getElementById(target).childNodes.length; i++)
188 document.getElementById(target).childNodes[i].disabled = true;
190 var drop = document.getElementById(master);
191 var opts = target_filter[drop.options[drop.selectedIndex].value];
197 var map = Object.create(null);
198 for (var i = 0; i < opts.length; i++) {
203 for (var i = 0; i < document.getElementById(target).childNodes.length; i++) {
204 if (document.getElementById(target).childNodes[i].value in opts && !(document.getElementById(target).childNodes[i].value in emptyMap) ) {
205 document.getElementById(target).childNodes[i].style.display = "inherit";
206 document.getElementById(target).childNodes[i].disabled = false;
211 <button onclick="submit_form();" class="btn btn-success">Confirm</button>
215 var prefill_host_selection = "{{host_select_field_prefill_data|default:""|safe}}";
216 var prefill_purpose = "{{prefill_purpose|default:""|safe}}";
217 var prefill_project = "{{prefill_project|default:""|safe}}";
218 var prefill_hostname = "{{prefill_hostname|default:""|safe}}";
221 function prefill_host_select_field(data)
226 make_selection(data);
230 //call init functions
231 prefill_host_select_field(prefill_host_selection);