MyAcc: Clear button disabled when there is no credentials to clear
[myslice.git] / portal / templates / validate_pending.html
1 {% extends "layout-unfold1.html" %}
2
3 {% block head %}
4 <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/validate_pending.css" />
5 <script type="text/javascript">
6         function on_click_event() {
7                 var ids = []; 
8                 $('.portal__validate__checkbox').each(function(i, el) {
9                         if ($(el).prop('checked')) {
10                                 // portal__validate__checkbox__slice__2
11                                 var id_array = $(el).attr('id').split('__');
12                                 // push(slice__2)
13                                 ids.push(id_array[3] + '__' + id_array[4]);
14                         }
15                 });
16                 if (ids.length > 0) {
17                         var id_str = ids.join('/');
18
19                         // XXX spinner
20
21                         $.getJSON('/portal/validate_action/' + id_str,
22                                 function(status) {
23                                         $.each(status, function(request_type__id, request_status) {
24                                                 // request_status: NAME -> dict (status, description)
25                                                 var status_str = '';
26                                                 $.each(request_status, function(name, result) {
27                                                         if (status_str != '')
28                                                                 status_str += ' -- ';
29
30                                                         if (result.status) {
31                                                                 status_str += '<font color="green">OK</font>';
32                                                                 $('#portal__validate__checkbox__' + request_type__id).hide();
33                                                         } else {
34                                                                 status_str += '<font color="red">ERROR: ' + result.description + '</font>';
35                                                         }
36                                                 });
37                                                 $('#portal__status__' + request_type__id).html(status_str)
38
39
40                                         });
41                                 }
42                         );
43                 }
44         }
45 </script>
46 {% endblock %}
47
48 {% block unfold_main %}
49 <div class="onelab-title well-lg">
50 <h1>Pending requests</h1>
51 </div>
52 <hr/>
53 <h2>My authorities</h2>
54
55 {% if my_authorities %}
56
57 {% for authority, requests in my_authorities.items %}
58 <h3>{{authority}}</h3>
59 <div class="container">
60     <table width=100% border=1 style="color:white;">
61       <th>
62         <td>type</td>
63         <td>id</td>
64         <td>details</td>
65         <td>timestamp</td>
66         <td>status</td>
67       </th>
68     {% for request in requests %}
69
70           <tr>
71                 <td>
72                 {% if request.allowed == 'allowed' %}
73                 <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
74                 {% else %}
75                         {% if request.allowed == 'expired' %}
76                                 expired
77                         {% else %} {# denied #}
78                                 denied
79                         {% endif %}
80                 {% endif %}
81                 </td>
82                 <td>{{ request.type }}</td>
83                 <td>{{ request.id }}</td>
84                 <td>
85         {% if request.type == 'user' %}
86         Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
87         {% else %}
88             {% if request.type == 'slice' %}
89         Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
90             {% else %} {# authority #}
91         TODO
92             {% endif %}
93         {% endif %}
94                 </td>
95                 <td>{{ request.timestamp }}</td>
96                 
97                 <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
98
99     <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
100           </tr>
101
102     {% endfor %}
103         </table>
104 {% endfor %}
105
106 {% else %}
107 <i>There is no pending request waiting for validation.</i>
108 {% endif %}
109
110
111 {% if delegation_authorities %}
112 <hr/>
113 <h2>Authorities with delegation</h2>
114
115 {% for authority, requests in delegation_authorities.items %}
116 <h3>{{authority}}</h3>
117     <table width=100% border=1>
118       <th>
119         <td>type</td>
120         <td>id</td>
121         <td>details</td>
122         <td>timestamp</td>
123         <td>status</td>
124       </th>
125     {% for request in requests %}
126           <tr>
127                 <td>
128                 {% if request.allowed == 'allowed' %}
129                 <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
130                 {% else %}
131                         {% if request.allowed == 'expired' %}
132                                 expired
133                         {% else %} {# denied #}
134                                 denied
135                         {% endif %}
136                 {% endif %}
137                 </td>
138                 <td>{{ request.type }}</td>
139                 <td>{{ request.id }}</td>
140                 <td>
141         {% if request.type == 'user' %}
142         Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
143         {% else %}
144             {% if request.type == 'slice' %}
145         Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
146             {% else %} {# authority #}
147         TODO
148             {% endif %}
149         {% endif %}
150                 </td>
151                 <td>{{ request.timestamp }}</td>
152                 
153                 <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
154
155     <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
156           </tr>
157     {% endfor %}
158     </table>
159 {% endfor %}
160 <hr/>
161
162 {% endif %}
163
164 <input type='button' id='portal__validate' value='Validate' onclick='on_click_event();'/>
165 </div>
166 <!-- End of the container div -->
167 {% endblock %}