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