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();
121 for ( var i=0; i < drop.childNodes.length; i++ )
123 var image_object = sup_image_dict[drop.childNodes[i].value];
124 if( image_object ) //weed out empty option
127 for( var j in data["labs"][0] )
129 if( j in {} ) { continue; }
130 else { lab_pk = j; break; }
133 for( var j in data["hosts"][0] )
135 if( j in {} ) { continue; }
136 else { host_pk = j; break; }
138 if( image_object.host_profile == host_pk && image_object.lab == lab_pk )
140 drop.childNodes[i].style.display = "inherit";
146 $('#id_image').children().hide();
147 $('#id_installer').children().hide();
148 $('#id_scenario').children().hide();
151 Array.from(document.getElementsByClassName("grid-item-select-btn")).forEach(function(element) {
152 element.addEventListener('click', imageHider);
155 function installerHider() {
156 dropFilter("id_installer", sup_installer_dict, "id_image");
159 document.getElementById('id_image').addEventListener('change', installerHider);
161 function scenarioHider() {
162 dropFilter("id_scenario", sup_scenario_dict, "id_installer");
164 document.getElementById('id_installer').addEventListener('change', scenarioHider);
166 function dropFilter(target, target_filter, master) {
167 ob = document.getElementById(target);
169 for(var i=0; i<ob.options.length; i++) {
170 if ( ob.options[i].text == '---------' ) {
171 ob.selectedIndex = i;
175 targ_id = "#" + target;
176 $(targ_id).children().hide();
177 var drop = document.getElementById(master);
178 var opts = target_filter[drop.options[drop.selectedIndex].value];
184 var map = Object.create(null);
185 for (var i = 0; i < opts.length; i++) {
190 for (var i = 0; i < document.getElementById(target).childNodes.length; i++) {
191 if (document.getElementById(target).childNodes[i].value in opts && !(document.getElementById(target).childNodes[i].value in emptyMap) ) {
192 document.getElementById(target).childNodes[i].style.display = "inherit";
197 <button onclick="submit_form();" class="btn btn-success">Confirm</button>
201 var prefill_host_selection = "{{host_select_field_prefill_data|default:""|safe}}";
202 var prefill_purpose = "{{prefill_purpose|default:""|safe}}";
203 var prefill_project = "{{prefill_project|default:""|safe}}";
204 var prefill_hostname = "{{prefill_hostname|default:""|safe}}";
207 function prefill_host_select_field(data)
212 make_selection(data);
216 //call init functions
217 prefill_host_select_field(prefill_host_selection);