Smartfire portal changes
[unfold.git] / portal / templates / smartfire / smartfire_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                                                                 </span>
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                         </tr>
264                                 {% for row in my_slices %}     
265                         <tr class="border_bottom">
266                                 <td class="odd"> {{ row.slice_name }} </td>
267                                         <td class="odd"> {{ row.cred_exp }} </td>
268                                         <td class="odd"> 
269                                                 <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}}';">
270                                                         <span class="glyphicon glyphicon-download"></span> Download
271                                                 </button> 
272                                         </td>
273                         </tr>
274                         {%endfor%}
275                         </table>
276                         <p></p>
277                         <table class="mytable table table-bordered table-hover">
278                                 <caption><b>Delegated Authority Credentials</b></caption>
279                                 <tr class="odd"> 
280                                 <th>Authority Name</th> 
281                                 <th>Expiration Date</th>
282                                         <th>Download</th>
283                                 </tr>
284                                 {% for row in my_auths %}
285                                 <tr class="border_bottom">
286                                 <td class="odd"> {{ row.auth_name }} </td>
287                                 <td class="odd"> {{ row.cred_exp }} </td>
288                                         <td class="odd">
289                                                 <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}}';">
290                                                         <span class="glyphicon glyphicon-download"></span> Download
291                                                 </button>
292                                         </td>
293                                 </tr>
294                                 {%endfor%}
295                         </table>
296                         <p></p>
297                          {%if '' not in my_users%}      
298                         <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>
299                         {%else%}
300                         <p><button class="btn btn-danger btn-lg btn-block disabled"   name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
301                         {%endif%}
302                 </div>
303         </div>
304
305
306         <div class="tab-pane row" id="access">
307                 <div class="col-md-12">
308         
309                 <h3>Testbed Access <small>Reference Accounts in the following testbeds</small></h3>
310         <table class="mytable table table-bordered table-hover"> 
311             <tr class="odd"> 
312                 <th>Platform</th> 
313                 <th>Account Type</th>
314                                 <th>Reference to</th>
315                                 <th>Remove Account</th>
316             </tr>   
317             {% for row in ref_acc %}         
318             <tr class="border_bottom">
319                 <td class="odd"> {{ row.platform_name }} </td>
320                 <td class="odd"> {{ row.account_type }} </td>
321                                 <td class="odd"> {{ row.account_reference }} </td>
322                                 <td class="odd">
323                                 <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}}';">
324                                                 <span class="glyphicon glyphicon-minus"></span>
325                                         </button>
326                                 </td>
327             </tr> 
328             {%endfor%}               
329         </table>                
330                 
331                 
332                 <h3>Add reference account to the following testbeds</h3>
333         <table class="mytable table table-bordered table-hover"> 
334             <tr class="odd"> 
335                 <th>Platforms</th> 
336                 <th>Add Account</th>
337             </tr>   
338             {% for platform in platform_list %}         
339             <tr class="border_bottom">
340                 <td class="odd"> {{ platform.platform_no_access }} </td>
341                 <td class="odd">
342                                         <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}}';">
343                                                 <span class="glyphicon glyphicon-plus"></span>
344                                         </button>
345                                 </td>
346             </tr> 
347             {%endfor%}               
348         </table>
349         </div>
350 {%endif%} 
351 </div>
352 </div>
353
354 </form>
355 <script>
356     $(document).ready(function() {
357             {%if 'no_creds' in user_cred or 'creds_expired' in user_cred %}
358         localStorage.clear();
359         $.post("/cache/clear/", function( data ) {
360         });
361         {% endif %}
362         $('.nav-tabs a').click(function (e) {
363                         e.preventDefault();
364                         $(this).tab('show');
365                         id = $(this).attr('href').substr(1);
366                 });
367                 
368         $('button#createslice').click(function() {
369             window.location="/portal/slice_request/";
370         });
371     });
372 </script>
373
374 {% endblock %}