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