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