Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
[unfold.git] / portal / templates / management-tab-requests.html
1 <script type="text/javascript">
2         $(document).ready(function() {
3                 $("li#nav-request").addClass("active");
4         });
5         function on_click_event() {
6                 var ids = []; 
7                 $('.portal__validate__checkbox').each(function(i, el) {
8                         if ($(el).prop('checked')) {
9                                 // portal__validate__checkbox__slice__2
10                                 var id_array = $(el).attr('id').split('__');
11                                 // push(slice__2)
12                                 ids.push(id_array[3] + '__' + id_array[4]);
13                         }
14                 });
15                 if (ids.length > 0) {
16                         var id_str = ids.join('/');
17
18                         // XXX spinner
19
20                         $.getJSON('/portal/validate_action/' + id_str,
21                                 function(status) {
22                                         $.each(status, function(request_type__id, request_status) {
23                                                 // request_status: NAME -> dict (status, description)
24                                                 var status_str = '';
25                                                 $.each(request_status, function(name, result) {
26                                                         if (status_str != '')
27                                                                 status_str += ' -- ';
28
29                                                         if (result.status) {
30                                                                 status_str += '<font color="green">OK</font>';
31                                                                 $('#portal__validate__checkbox__' + request_type__id).hide();
32                                                         } else {
33                                                                 status_str += '<font color="red">ERROR: ' + result.description + '</font>';
34                                                         }
35                                                 });
36                                                 $('#portal__status__' + request_type__id).html(status_str);
37
38
39                                         });
40                                 }
41                         );
42                 }
43         }
44         function on_click_reject() {
45                 var ids = []; 
46                 $('.portal__validate__checkbox').each(function(i, el) {
47                         if ($(el).prop('checked')) {
48                                 // portal__validate__checkbox__slice__2
49                                 var id_array = $(el).attr('id').split('__');
50                                 // push(slice__2)
51                                 ids.push(id_array[3] + '__' + id_array[4]);
52                         }
53                 });
54                 if (ids.length > 0) {
55                         var id_str = ids.join('/');
56
57                         // XXX spinner
58
59                         $.getJSON('/portal/reject_action/' + id_str,
60                                 function(status) {
61                                         $.each(status, function(request_type__id, request_status) {
62                                                 // request_status: NAME -> dict (status, description)
63                                                 var status_str = '';
64                                                 $.each(request_status, function(name, result) {
65                                                         if (status_str != '')
66                                                                 status_str += ' -- ';
67
68                                                         if (result.status) {
69                                                                 status_str += '<font color="green">OK</font>';
70                                                                 $('#portal__validate__checkbox__' + request_type__id).hide();
71                                                         } else {
72                                                                 status_str += '<font color="red">ERROR: ' + result.description + '</font>';
73                                                         }
74                                                 });
75                                                 $('#portal__status__' + request_type__id).html(status_str);
76
77
78                                         });
79                                 }
80                         );
81                 }
82         }
83 </script>
84
85 <div class="col-md-12">
86         <h2>From your authorities</h2>
87 </div>
88 {% if my_authorities %}
89         
90         {% for authority, requests in my_authorities.items %}
91         
92         <div class="col-md-12">
93                 <h2>{{authority}}</h2>
94         </div>
95         
96     <table class="table">
97       <th>
98         <td>Type</td>
99         <td>Id</td>
100         <td>Details</td>
101         <td>Timestamp</td>
102         <td>Status</td>
103       </th>
104     {% for request in requests %}
105
106           <tr>
107                 <td>
108                 {% if request.allowed == 'allowed' %}
109                 <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
110                 {% else %}
111                         {% if request.allowed == 'expired' %}
112                                 expired
113                         {% else %} {# denied #}
114                                 denied
115                         {% endif %}
116                 {% endif %}
117                 </td>
118                 <td>{{ request.type }}</td>
119                 <td>{{ request.id }}</td>
120                 <td>
121         {% if request.type == 'user' %}
122         Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
123         {% else %}
124             {% if request.type == 'slice' %}
125         Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
126             {% else %} {# authority #}
127         Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
128             {% endif %}
129         {% endif %}
130                 </td>
131                 <td>{{ request.timestamp }}</td>
132                 
133                 <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
134
135     <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
136           </tr>
137
138     {% endfor %}
139         </table>
140         </div>
141         {% endfor %}
142
143 {% else %}
144         <div class="col-md-12">
145                 <i>There is no pending request waiting for validation.</i>
146         </div>
147 {% endif %}
148 <br />
149 <div class="col-md-12">
150         <h2>From your sub-authorities</h2>
151 </div>
152 {% if sub_authorities %}
153         
154         {% for authority, requests in sub_authorities.items %}
155         <div class="col-md-12">
156         <h3>{{authority}}</h3>
157             <table class="table">
158               <th>
159                 <td>Type</td>
160                 <td>Id</td>
161                 <td>Details</td>
162                 <td>Timestamp</td>
163                 <td>Status</td>
164               </th>
165             {% for request in requests %}
166                   <tr>
167                         <td>
168                         {% if request.allowed == 'allowed' %}
169                         <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
170                         {% else %}
171                                 {% if request.allowed == 'expired' %}
172                                         expired
173                                 {% else %} {# denied #}
174                                         denied
175                                 {% endif %}
176                         {% endif %}
177                         </td>
178                         <td>{{ request.type }}</td>
179                         <td>{{ request.id }}</td>
180                         <td>
181                 {% if request.type == 'user' %}
182                 Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
183                 {% else %}
184                     {% if request.type == 'slice' %}
185                 Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
186                     {% else %} {# authority #}
187                 Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
188                     {% endif %}
189                 {% endif %}
190                         </td>
191                         <td>{{ request.timestamp }}</td>
192                         
193                         <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
194         
195             <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
196                   </tr>
197             {% endfor %}
198             </table>
199         </div>
200         {% endfor %}
201 {% else %}
202 <div class="col-md-12">
203         <i>There is no pending request waiting for validation.</i>
204 </div>
205 {% endif %}
206 <br />
207 <div class="col-md-12">
208         <h2>From your authorities with delegation</h2>
209 </div>
210
211 {% if delegation_authorities %}
212         
213         {% for authority, requests in delegation_authorities.items %}
214         <div class="col-md-12">
215                 <h3>{{authority}}</h3>
216                     <table class="table">
217                       <th>
218                         <td>Type</td>
219                         <td>Id</td>
220                         <td>Details</td>
221                         <td>Timestamp</td>
222                         <td>Status</td>
223                       </th>
224                     {% for request in requests %}
225                           <tr>
226                                 <td>
227                                 {% if request.allowed == 'allowed' %}
228                                 <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
229                                 {% else %}
230                                         {% if request.allowed == 'expired' %}
231                                                 expired
232                                         {% else %} {# denied #}
233                                                 denied
234                                         {% endif %}
235                                 {% endif %}
236                                 </td>
237                                 <td>{{ request.type }}</td>
238                                 <td>{{ request.id }}</td>
239                                 <td>
240                         {% if request.type == 'user' %}
241                         Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
242                         {% else %}
243                             {% if request.type == 'slice' %}
244                         Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
245                             {% else %} {# authority #}
246                         Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
247                             {% endif %}
248                        {% endif %}
249                                 </td>
250                                 <td>{{ request.timestamp }}</td>
251                                 
252                                 <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
253                 
254                     <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
255                           </tr>
256                     {% endfor %}
257                     </table>
258                 </div>
259                 {% endfor %}
260 {% else %}
261 <div class="col-md-12">
262         <i>There is no pending request waiting for validation.</i>
263 </div>
264 {% endif %}
265 <br />
266 <div class="col-md-12">
267         <button class="btn btn-onelab" type="button" id="portal__validate" onclick="on_click_event();"><span class="glyphicon glyphicon-ok"></span> Validate</button>
268         <button class="btn btn-onelab" type="button" id="portal__reject" onclick="on_click_reject();"><span class="glyphicon glyphicon-remove"></span> Reject</button>
269 </div>