c8a668f1f299631d6c9afab9790559605313b938
[myslice.git] / portal / templates / onelab / onelab_institution.html
1 {% extends "layout_wide.html" %}
2
3 {% block head %} 
4 <script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
5 {% endblock head %}
6
7 {% block content %}
8 <div class="container">
9         <div class="row">
10                 <div class="col-md-12">
11                          <div class="breadcrumbs">
12                                  Management &nbsp;>&nbsp; Institution: <span id="authority_name"></span>
13                          </div>
14                 </div>
15         </div>
16 </div>
17 <div class="container">
18         <div class="row">
19                 <div class="col-md-12">
20                         <ul class="nav nav-tabs nav-section">
21                                 <li class="active"><a href="#about">About</a></li>
22                                 <li><a href="#users">Users</a></li>
23                                 <li><a href="#slices">Slices</a></li>
24                                 <li><a href="#requests">Requests</a></li>
25                         </ul>
26             </div>
27         </div>
28 </div>
29 <div class="container tab-content">
30         <div class="tab-pane active row" id="about">
31         </div>
32         
33         <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
34                 <div class="col-md-12 el">
35                         <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
36                                 <div id="user-tab-loaded" style="display:none;">
37                                 <table id="user-tab" class="table">
38                                         <tr>
39                                         <th>+/-</th>
40                                         <th>Email</th>
41                                         <th>User hrn</th>
42                                         <th>First name</th>
43                                         <th>Last name</th>
44                                         <th>Enabled</th>
45                                         </tr>
46                                 </table>
47                                 
48                         </div>
49                         {%if 'is_pi'  in pi %}  
50                         <div>
51                                 <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
52                         </div>
53                         {% endif %}
54                 </div>
55         </div>
56
57         <div class="tab-pane row" id="slices">
58                 <div class="col-md-12 el">
59             <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
60             <div id="slice-tab-loaded" style="display:none;">
61                 <table id="slice-tab" class="table">
62                     <tr>
63                         <th>+/-</th>
64                         <th>Slice hrn</th>
65                         <th>Users</th>
66                         <th>Url</th>
67                         <!-- <th>nodes</th> -->
68                         <th>Expiration</th>
69                     </tr>
70                 </table>                        
71             </div>
72         {% if 'is_pi'  in pi %}
73         <div>
74                 {% if 'is_pi'  in pi %}
75                         <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
76                         {% else %}
77                         <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
78                         {% endif %}
79             <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
80             <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
81         </div>
82                 {% endif %} 
83            </div>
84         </div>
85         <div class="tab-pane row" id="requests">
86         </div>
87 </div>
88 <script>
89 $(document).ready(function() {
90     {% if person %}
91     {% if user_details.parent_authority %}
92
93         $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
94             var list_slices = [];
95             var table_slices = [];
96             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
97             $.each( data, function( key, val ) {
98                 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
99                 if(val.nodes=="undefined" || val.nodes==null){
100                     nodes_length=0;
101                 }else{
102                     nodes_length=val.nodes.length;
103                 }
104                 console.log(val);
105                 if(val.users=="undefined" || val.users==null){
106                     users_length=0;
107                 }else{
108                     users_length=val.users.length;
109                 }
110
111                 if(val.slice_url=="undefined" || val.slice_url==null){
112                     slice_url="";
113                 }else{
114                     slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
115                 }
116                 
117                 slice_row = "<tr id='"+val.slice_hrn+"'>";
118                 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
119                 slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
120                 slice_row += "<td>"+users_length+"</td>";
121                 slice_row += "<td>"+slice_url+"</td>";
122                 //slice_row += "<td>"+nodes_length+"</td>";
123                 slice_row += "<td>"+val.slice_expires+"</td>";
124                 slice_row += "</tr>";
125                 table_slices.push(slice_row);
126                 
127             });
128            
129             /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
130             $("table#slice-tab tr:last").after(table_slices.join( "" ));
131             $("div#slice-tab-loaded").css("display","block");
132             $("div#slice-tab-loading").css("display","none");
133         });
134                 
135                 
136         $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
137             var list_users = [];
138             var table_users = [];
139                     /* Available fields
140                     user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
141                     user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
142                     */
143             $.each( data, function( key, val ) {
144                 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
145                 user_row = "<tr id='"+val.user_hrn+"'>";
146                 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
147                 user_row += "<td>"+val.user_email+"</td>";
148                 user_row += "<td>"+val.user_hrn+"</td>";
149                 user_row += "<td>"+val.user_first_name+"</td>";
150                 user_row += "<td>"+val.user_last_name+"</td>";
151                             user_row += "<td>"+val.user_enabled+"</td>";
152                 user_row += "</tr>";
153                 table_users.push(user_row);
154             });
155             $("table#user-tab tr:last").after(table_users.join( "" ));
156             $("div#user-tab-loaded").css("display","block");
157             $("div#user-tab-loading").css("display","none");
158         });
159
160     {% endif %}
161     {% endif %}
162
163 }); // End document.ready
164
165 $(document).ready(function() {
166         $('.nav-tabs a').click(function (e) {
167                 e.preventDefault();
168                 $(this).tab('show');
169         var id = $(this).attr('href').substr(1);
170         if ((id == 'requests') || (id == 'about'))
171                 $("#" + id).load('/management/' + id);
172         });
173         var hash = window.location.hash;
174         if (hash) {
175                 $('.nav-tabs a[href='+hash+']').click();
176         } else {
177                 $('.nav-tabs a[href=#about]').click();
178         }
179 });
180 </script>
181 {% endblock %}