1 | {{extend 'layout.html'}} |
---|
2 | |
---|
3 | |
---|
4 | <script src="{{=URL('static', 'js/moment.min.js')}}"></script> |
---|
5 | <link href="{{=URL('static', 'css/bootstrap-datetimepicker.min.css')}}" rel="stylesheet"> |
---|
6 | <script src="{{=URL('static', 'js/bootstrap-datetimepicker.min.js')}}"></script> |
---|
7 | |
---|
8 | |
---|
9 | <link href="{{=URL('static', 'css/setup.css')}}" rel="stylesheet" type="text/css" /> |
---|
10 | |
---|
11 | <script type="text/javascript"> |
---|
12 | |
---|
13 | $(function(){ |
---|
14 | let params = { |
---|
15 | inline: false, |
---|
16 | sideBySide: true, |
---|
17 | format: 'DD/MM/YYYY HH:mm:ss', |
---|
18 | } |
---|
19 | |
---|
20 | $("#pre_reserves_init_time").datetimepicker(params); |
---|
21 | $("#pre_reserves_finish_time").datetimepicker(params); |
---|
22 | }); |
---|
23 | |
---|
24 | xhr = new XMLHttpRequest(); |
---|
25 | |
---|
26 | function requestAJAX(url, parametros, callbackFunction){ |
---|
27 | |
---|
28 | xhr.open("POST", url, true); |
---|
29 | xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); |
---|
30 | xhr.send(parametros); |
---|
31 | console.log('xhr') |
---|
32 | console.log(xhr) |
---|
33 | |
---|
34 | xhr.onreadystatechange = function() { |
---|
35 | if (xhr.readyState == 4 && xhr.status == 200) { |
---|
36 | var respuesta = JSON.parse(xhr.responseText); |
---|
37 | |
---|
38 | if (respuesta.error === undefined) { |
---|
39 | |
---|
40 | // Use callback for synchronize ajax response with html view |
---|
41 | callbackFunction(respuesta); |
---|
42 | |
---|
43 | } else { |
---|
44 | alert(respuesta.error); |
---|
45 | refresh_page(); |
---|
46 | //document.getElementById("buttonConsole").style.display = 'block'; |
---|
47 | //reset_progress_bar(); |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | function check_min_finish_time(event) { |
---|
55 | let init_time = document.getElementById('pre_reserves_init_time').value; |
---|
56 | let finish_time = document.getElementById('pre_reserves_finish_time').value; |
---|
57 | if (init_time > finish_time) { |
---|
58 | alert('¡¡Finish time must be lower than init time!!'); |
---|
59 | } |
---|
60 | document.getElementById('pre_reserves_finish_time').focus(); |
---|
61 | } |
---|
62 | |
---|
63 | function set_image_id(event) { |
---|
64 | let image_id_select = document.getElementById('pre_reserves_image_name'); |
---|
65 | image_id = image_id_select.options[image_id_select.selectedIndex].getAttribute('data-image_id') |
---|
66 | document.getElementById('pre_reserves_image_id').value = image_id; |
---|
67 | } |
---|
68 | |
---|
69 | function populate_images(images) { |
---|
70 | let image_select = document.getElementById('pre_reserves_image_name') |
---|
71 | for ( let i = image_select.length - 1; i >= 0; i -- ) { |
---|
72 | image_select.remove(i); |
---|
73 | } |
---|
74 | |
---|
75 | for ( let j = 0; j < images.length; j ++ ) { |
---|
76 | //console.log(images[i]['id']); |
---|
77 | //console.log(images[i]['os']); |
---|
78 | const option = document.createElement('option'); |
---|
79 | option.text = images[j]['os']; |
---|
80 | option.value = images[j]['os']; |
---|
81 | option.setAttribute('data-image_id', images[j]['id']); |
---|
82 | image_select.add(option); |
---|
83 | } |
---|
84 | set_image_id(); |
---|
85 | |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | function set_lab_name(event) { |
---|
90 | // console.log(event.target.options[event.target.selectedIndex].text); |
---|
91 | var list_hosts = {{=max_hosts_lab}}; |
---|
92 | var list_ous = {{=lab_ous}}; |
---|
93 | |
---|
94 | var lab_id = document.getElementById('pre_reserves_lab_id').value; |
---|
95 | document.getElementById('pre_reserves_num_reserves').max = list_hosts[lab_id]; |
---|
96 | document.getElementById('pre_reserves_num_reserves').value = list_hosts[lab_id]; |
---|
97 | |
---|
98 | document.getElementById('pre_reserves_ou_id').value = list_ous[lab_id]; |
---|
99 | |
---|
100 | |
---|
101 | var lab_name = event.target.options[event.target.selectedIndex].text; |
---|
102 | document.getElementById('pre_reserves_lab_name').value = lab_name; |
---|
103 | |
---|
104 | requestAJAX('{{=URL("setup", "get_images_lab")}}', |
---|
105 | 'ou_id=' + list_ous[lab_id] + |
---|
106 | '&lab_id=' + lab_id, |
---|
107 | populate_images); |
---|
108 | |
---|
109 | |
---|
110 | } |
---|
111 | |
---|
112 | </script> |
---|
113 | |
---|
114 | <div class="container_setup"> |
---|
115 | <div class="menu_config"> |
---|
116 | {{include 'setup/menu.html'}} |
---|
117 | </div> |
---|
118 | |
---|
119 | <div class="form_config"> |
---|
120 | {{=grid}} |
---|
121 | </div> |
---|
122 | </div> |
---|
123 | |
---|