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