ffa882f918447d6e70854d3eab61810b9a8afc04
[myslice.git] / portal / templates / onelab / onelab_account-view.html
1 {% extends "layout.html" %}
2 {% load portal_filters %}
3 {% block content %}
4 {% widget "_widget-no_credentials.html" %}
5 {% widget "_widget-tradeoff.html" %}
6 <div class="row">
7         <div class="col-md-12">
8                  <div class="breadcrumbs">
9                          Account &nbsp;>&nbsp; <a href="/account">{{ person.email }}</a>
10                  </div>
11         </div>
12          {%if 'no_creds' in user_cred %}
13     <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
14     {%endif%}
15          {%if 'creds_expired' in user_cred %}
16     <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
17     {%endif%}
18
19 </div>
20 {% if messages %}
21 <ul class="messages">
22     {% for message in messages %}
23     <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
24     {% endfor %}
25 </ul>
26 {% endif %}
27
28 <form id="editForm" method="post" action="account_process" enctype="multipart/form-data">
29 <input type="hidden" id="button_value"  name="button_value" value="" />
30
31 <div class="row">
32         <div class="col-md-12">
33                 <ul class="nav nav-tabs nav-section">
34                         <li class="active"><a href="#profile">User Profile</a></li>
35                         <li><a href="#account">Account</a></li>
36                         <li><a href="#access">Testbed Access</a></li>
37                 </ul>
38     </div>
39 </div>
40 <div class="tab-content">
41         <div class="tab-pane active row" id="profile">
42                 
43                 <div class="col-md-12">
44
45                                 {% csrf_token %}
46                                         <table class="profile">          
47                                         <tr>
48                                                 <td colspan="2">
49                                                                 <div><h3>Platform: Myslice</h3></div>
50                                                 </td>
51                                         </tr>
52                                         <tr>
53                                                 <td class="key">Email</td>
54                                                 <td class="value">
55                                                                 <span id="emailval" class="value" >{{ person.email }}</span>
56                                                                 <button class="btn btn-default" type="button" id="edit_email" onclick="editAlert();"  title="To change your affiliation please contact the administrator">
57                                                                 <span class="glyphicon glyphicon-question-sign"></span> Edit
58                                                                 </button>
59                                                         </td>
60                                         </tr>
61                                         <tr class="odd">
62                                                         <td class="key">Password</td>
63                                                         <td class="value"> 
64                                                                 <button class="btn btn-default btn-xs" type="button" title="Password" name="edit_pass" id="edit_pass">
65                                                                         <span class="glyphicon glyphicon-edit"></span> Edit
66                                                                 </button>
67                                                                 <span id="passval"class="value">******** </span>
68                                                                 <span class="hide_this" id="span_pass">
69                                                                 <button type="button" class="btn btn-default btn-xs" title="Cancel" id="cancel_pass_change"> Cancel </button>
70                                                                 <div style='display:none;' id="pass_form">
71                                                                 <input type='hidden'  value='' /></div>
72                                                                 <table id="edit_password">
73                                                                         <tr>
74                                                                                         <td>Enter password: </td>
75                                                                                         <td class="field"> <input type="password" name="password" id="password" /> </td>
76                                                                                 </tr>
77                                                                                 <tr>
78                                                                                         <td>Confirm password: </td>
79                                                                                         <td class="field"> 
80                                                                                                 <input type="password" name="confirmpassword" id="confirmpassword" /> 
81                                                                                                 <input type="submit" class="btn btn-default btn-xs" name="submit_pass" value="Save"/> 
82                                                                                         </td>
83                                                                         </tr>
84                                                                 </table>
85                                                                 </span> 
86                                                         </td>
87                                         </tr>
88                                         <tr class="even">
89                                                         <td class="key">Full Name</td>
90                                                         <td class="value">
91                                                                 <span id="nameval" class="value" >{{ fullname }} </span>
92                                                                 <span class="hide_this" id="span_name">
93                                                                 <button type="button" class="btn btn-default btn-xs" title="Cancel" id="cancel_name_change"> Cancel </button> 
94                                                                 <div style='display:none;'><input type='hidden'  name='nameform'  /></div>
95                                                                 <input id="fname" type="text" name="fname" class="required"  maxlength="200" value="{{firstname}}" />
96                                                                 <input id="lname" type="text" name="lname" class="required"  maxlength="200" value="{{lastname}}" />
97                                                                 <input type="submit" class="btn btn-default btn-xs" name="submit_name" value="Save"/>
98                                                                 </span>
99                                                                 <button class="btn btn-default btn-xs" type="button"title="Full Name" id="edit_name">
100                                                                         <span class="glyphicon glyphicon-edit"></span> Edit
101                                                                 </button>
102                                                         </td>
103                                         </tr>
104                                         <tr class="odd">
105                                                         <td class="key">Authority</td>
106                                                         <td class="value">
107                                                                 <span id="affval" class="value">{{ authority }}</span>
108                                                                  <button class="btn btn-default btn-xs" type="button" id="edit_auth" onclick="editAlert()"  title="To change your authority please contact the administrator">
109                                                                 <span class="glyphicon glyphicon-question-sign"></span> Edit
110                                                                  </button>
111                                                         </td>
112                                                 </tr>
113                                                 {%if 'Enabled'  in user_status %}
114                                                 <tr class="even">
115                                                         <td class="key">Generate Keys</td>
116                                                         <td>
117                                                                 <input type="submit" name="generate" class="btn btn-primary" value="Generate a new Key Pair" id="generate_keypair" 
118                                                                            onclick="return confirm('Are you sure? If you do so, your current credentials will be overwritten.');" 
119                                                                            title="It will generate a new key Pair and your current credentials will be overwritten."/>
120                                                 </td> 
121                                         </tr>
122                                         <tr class="odd">
123                                                 <td class="key">Public Key</td>
124                                                 <td class="value">
125                                                                 <span id="keyval" class="value">******** </span>
126                                                                 <span class="hide_this" id="span_upload">
127                                                                         <button type="button" class="btn btn-default" title="Cancel" id="cancel_upload"> Cancel </button>
128                                                                         <div style='display:none;'>
129                                                                                 <input type='hidden'  name='upload'  /></div>
130                                                                                 <input type="file" name="pubkey" class="required" id="pubkey"/>  
131                                                                                 <input class="btn btn-default btn-xs" name="upload_key" id="upload_key"  type="submit" title="Upload your public key" value="Upload"
132                                                                                    onclick="return confirm('Are you sure? It will overwrite your current credentials and you have delegate it manually.');"/>
133                                                         
134                                                                 <div style='display:none;'> <input type='hidden'  name='dload'  /> </div> 
135                                                                 <button type="submit" name="dl_pubkey" class="btn btn-default btn-xs" title="Download your public key" id="dl_pubkey" onclick="javascript:document.getElementById('button_value').value='dl_pubkey';">
136                                                                         <span class="glyphicon glyphicon-download"></span> Download
137                                                                 </button>
138                                                                 <button class="btn btn-default btn-xs" id="upload_file" type="button" title="Upload a public key">
139                                                                         <span class="glyphicon glyphicon-upload"></span> Upload
140                                                                 </button>       
141                                                 </td>
142                                         </tr>
143                                         <tr class="even" id="pkey_row">
144                                                  {%if 'N/A' not in user_private_key%}
145                                                 <td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
146                                                 <td class="value">********<a href="#"></a>
147                                                         <button type="submit" name="dl_pkey" class="btn btn-default" title="Download your privaye key" id="dl_pkey" value="dl_pkey" onclick="javascript:document.getElementById('button_value').value='dl_pkey';">
148                                                                         <span class="glyphicon glyphicon-download"></span> Download     
149                                                                 </button>
150                                                         <input class="btn btn-danger btn-xs" id="delete" name="delete" type="submit"  value="Delete" title="Delete your private key"
151                                                                                 onclick="javascript:document.getElementById('button_value').value='delete'; return confirm('Are you sure? If you do so, you have to delegate your credentials manually.');"/> 
152                                                 </td>
153                                                   {%else%}
154                                                         <td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
155                                                         <td class="value">********<a href="#"></a>
156                                                         <button type="submit" name="dl_pkey" class="btn btn-default disabled" title="Download your privaye key" id="dl_pkey" value="dl_pkey">
157                                                                 <span class="glyphicon glyphicon-download"></span> Download 
158                                                         </button>
159                                                         <input class="btn btn-danger btn-xs disabled" id="delete" name="delete" type="submit" title="Delete your private key" value="Delete" />
160                                                         </td>
161                                                  {%endif%}              
162                                                 </tr>
163                                         <tr class="even" id="sfi_config_row">
164                                                 <td class="key">sfi_config </td>
165                                                 <td class="value">use sfi_config file with sfi.py package (pip install sfa)<a href="#"></a>
166                                                         <button type="submit" name="dl_sfi_config" class="btn btn-default btn-xs" title="Download your sfi_config" id="dl_sfi_config" value="dl_sfi_config" onclick="javascript:document.getElementById('button_value').value='dl_sfi_config';">
167                                                                         <span class="glyphicon glyphicon-download"></span> Download
168                                                                 </button>
169                                                 </td>
170                         </tr>
171                                                 <tr class="odd">
172                                                         {%if 'N/A' not in user_private_key%}
173                                                         <td class="key">Identity</td> 
174                                                 <td>
175                                                                 <button type="submit" name="dl_identity" class="btn btn-default btn-xs" title="You will require it to use jfed" id="dl_identity" onclick="javascript:document.getElementById('button_value').value='dl_identity';">
176                                                                 <span class="glyphicon glyphicon-download"></span> Download 
177                                                                 </button>
178                                                         </td>
179                                                         {%else%}
180                                                         <td class="key">Identity</td> 
181                                                         <td>
182                                                         <button type="submit" name="dl_identity" class="btn btn-default btn-xs disabled" title="You will require it to use jfed" id="dl_identity">
183                                                                 <span class="glyphicon glyphicon-download"></span> Download 
184                                                         </button>
185                                                         </td>
186                                                         {%endif%} 
187                                                 </tr>
188
189                                                 <tr class="even">
190                                                 <td colspan="2">
191                                                                 <p class="command">
192                                                                         <a href="#" style="color:green" data-toggle="modal" data-target="#tradeoffmodal">Automatic vs. Manual delegation of credentials:</a>
193                                                                         Trade-off between ease-of-use & security</p>
194                                                                 </p>
195                                                 </td>
196                                                 </tr>
197                                                 {%endif%}
198                                         </table>
199                         
200                 </div>
201         </div>
202
203         <div class="tab-pane row" id="account">
204                 <div class="col-md-12">
205         
206                 <h3>Principal Account <small>Account used for delegating credentials</small></h3>
207                 <table class="table"> 
208                         <tr class="odd"> 
209                         <th>Platform</th> 
210                         <th>Account Type</th>
211                                 <th>Account Delegation</th>
212                         <th>User hrn</th>
213                                 <th>User Status</th>
214                         <!--<th>Pub Key</th> -->
215                 </tr>   
216                         {% for row in principal_acc %}         
217                         <tr class="border_bottom">
218                         <td class="odd"> {{ row.platform_name }} </td>
219                         <td class="odd"> {{ row.account_type }} </td>
220                                 <td class="odd"> {{ row.delegation_type }} </td>
221                         <td class="odd"> {{ row.usr_hrn }}  </td>
222                                 <td class="odd"> {{ row.user_status }}  </td>
223                 <!--    <td class="even"> {{ row.usr_pubkey }} </td> -->
224                 </tr> 
225                         {%endfor%}               
226                 </table>
227         
228                 </div>
229
230         {%if 'Enabled'  in user_status %}
231                 <div class="col-md-12">
232                 <h3>Credentials <small>Delegated to Principal Account</small></h3>
233                     <table class="table">
234                                 <caption><b>Delegated User Credential</b></caption> 
235                         <tr class="odd"> 
236                             <th>Expiration Date</th>
237                                         <th>Download</th>
238                         </tr>
239                                 {% for row in my_users %}         
240                                 <tr class="border_bottom">
241                                 <td class="odd"> {{ row.cred_exp }} </td>
242                                         <td class="odd">
243                                                 <button class="btn btn-default btn-xs" name= "dl_user_cred" type="submit" title="Download User Credential" onclick="javascript:document.getElementById('button_value').value='dl_user_cred';">
244                                                         <span class="glyphicon glyphicon-download"></span> Credential
245                                                 </button>
246                                                 <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate" onclick="javascript:document.getElementById('button_value').value='dl_user_cert';">
247                                                         <span class="glyphicon glyphicon-download"></span> Certificate
248                                                 </button>
249                          <button class="btn btn-default btn-xs" name= "dl_user_p12" type="submit" title="Download User PKCS12" onclick="javascript:document.getElementById('button_value').value='dl_user_p12';">
250                              <span class="glyphicon glyphicon-download"></span> PKCS p12
251                          </button>
252                                         </td>
253                                 </tr>
254                                 {%endfor%}
255                          </table>
256                         <p></p>
257                         <table class="mytable table table-bordered table-hover">
258                                 <caption><b>Delegated Slice Credentials</b></caption>  
259                         <tr class="odd"> 
260                                         <th>Slice Name</th> 
261                                 <th>Expiration Date</th>
262                                         <th>Download</th>
263                     <th>Delete</th>
264                         </tr>
265                                 {% for row in my_slices %}     
266                         <tr class="border_bottom">
267                                 <td class="odd"> {{ row.slice_name }} </td>
268                                         <td class="odd"> {{ row.cred_exp }} </td>
269                                         <td class="odd"> 
270                                                 <button class="btn btn-default btn-xs" name= "dl_{{row.slice_name}}" type="submit" title="Download Slice Credentials" onclick="javascript:document.getElementById('button_value').value='dl_{{row.slice_name}}';">
271                                                         <span class="glyphicon glyphicon-download"></span> Download
272                                                 </button> 
273                                         </td>
274                     <td class="odd"> 
275                         <button class="btn btn-danger btn-xs" name= "del_{{row.slice_name}}" type="submit" title="Download Slice Credentials" onclick="return confirm('Are you sure? If you do so, the slice will be permanently deleted.'); javascript:document.getElementById('button_value').value='del_{{row.slice_name}}';">
276                             <span class="glyphicon glyphicon-remove"></span> Delete
277                         </button> 
278                     </td>
279                         </tr>
280                         {%endfor%}
281                         </table>
282                         <p></p>
283                         <table class="mytable table table-bordered table-hover">
284                                 <caption><b>Delegated Authority Credentials</b></caption>
285                                 <tr class="odd"> 
286                                 <th>Authority Name</th> 
287                                 <th>Expiration Date</th>
288                                         <th>Download</th>
289                                 </tr>
290                                 {% for row in my_auths %}
291                                 <tr class="border_bottom">
292                                 <td class="odd"> {{ row.auth_name }} </td>
293                                 <td class="odd"> {{ row.cred_exp }} </td>
294                                         <td class="odd">
295                                                 <button class="btn btn-default btn-xs" name= "dl_{{row.auth_name}}" type="submit" title="Download Authority Credentials" onclick="javascript:document.getElementById('button_value').value='dl_{{row.auth_name}}';">
296                                                         <span class="glyphicon glyphicon-download"></span> Download
297                                                 </button>
298                                         </td>
299                                 </tr>
300                                 {%endfor%}
301                         </table>
302                         <p></p>
303                          {%if '' not in my_users%}      
304                         <p><button class="btn btn-danger btn-lg btn-block"   name= "clear_cred" type="submit" title="Clear All Credentials" onclick="javascript:document.getElementById('button_value').value='clear_cred';">Clear Credentials</button></p>
305                         {%else%}
306                         <p><button class="btn btn-danger btn-lg btn-block disabled"   name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
307                         {%endif%}
308                 </div>
309         </div>
310
311
312         <div class="tab-pane row" id="access">
313                 <div class="col-md-12">
314         
315                 <h3>Testbed Access <small>Reference Accounts in the following testbeds</small></h3>
316         <table class="mytable table table-bordered table-hover"> 
317             <tr class="odd"> 
318                 <th>Platform</th> 
319                 <th>Account Type</th>
320                                 <th>Reference to</th>
321                                 <th>Remove Account</th>
322             </tr>   
323             {% for row in ref_acc %}         
324             <tr class="border_bottom">
325                 <td class="odd"> {{ row.platform_name }} </td>
326                 <td class="odd"> {{ row.account_type }} </td>
327                                 <td class="odd"> {{ row.account_reference }} </td>
328                                 <td class="odd">
329                                 <button class="btn btn-danger" name="delete_{{row.platform_name}}" type="submit" title="Delete account from this platform" onclick="javascript:document.getElementById('button_value').value='delete_{{row.platform_name}}';">
330                                                 <span class="glyphicon glyphicon-minus"></span>
331                                         </button>
332                                 </td>
333             </tr> 
334             {%endfor%}               
335         </table>                
336                 
337                 
338                 <h3>Add reference account to the following testbeds</h3>
339         <table class="mytable table table-bordered table-hover"> 
340             <tr class="odd"> 
341                 <th>Platforms</th> 
342                 <th>Add Account</th>
343             </tr>   
344             {% for platform in platform_list %}         
345             <tr class="border_bottom">
346                 <td class="odd"> {{ platform.platform_no_access }} </td>
347                 <td class="odd">
348                                         <button class="btn btn-success btn-sm" name= "add_{{platform.platform_no_access}}" type="submit" title="Add account to this platform" onclick="javascript:document.getElementById('button_value').value='add_{{platform.platform_no_access}}';">
349                                                 <span class="glyphicon glyphicon-plus"></span>
350                                         </button>
351                                 </td>
352             </tr> 
353             {%endfor%}               
354         </table>
355         </div>
356 {%endif%} 
357 </div>
358 </div>
359
360 </form>
361 <script>
362     $(document).ready(function() {
363             {%if 'no_creds' in user_cred or 'creds_expired' in user_cred %}
364         localStorage.clear();
365         $.post("/cache/clear/", function( data ) {
366         });
367         {% endif %}
368         $('.nav-tabs a').click(function (e) {
369                         e.preventDefault();
370                         $(this).tab('show');
371                         id = $(this).attr('href').substr(1);
372                 });
373                 
374         $('button#createslice').click(function() {
375             window.location="/portal/slice_request/";
376         });
377     });
378 </script>
379
380 {% endblock %}