style changes
[unfold.git] / portal / templates / institution.html
1 {% extends "layout.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="row">
9         <div class="col-md-12">
10                 <ul class="nav nav-tabs nav-section">
11                         <li class="active"><a href="#info"><img src="{{ STATIC_URL }}icons/authority-xs.png" alt="Institution" /> Institution {{user_details.parent_authority}}</a></li>
12                         <li><a href="#users">Users</a></li>
13                         <li><a href="#slices">Slices</a></li>
14                 </ul>
15     </div>
16 </div>
17 <div class="tab-content">
18         <div class="tab-pane active row" id="info">
19                 <div class="col-md-12">
20                         <div id="authority-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Authority" /></div>
21                     <div id="authority-tab-loaded" style="display:none;">
22                         <div id="authority-data"></div>
23                     </div>
24            </div>
25         </div>
26
27         <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
28                 <div class="col-md-12">
29                         <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
30                                 <div id="user-tab-loaded" style="display:none;">
31                                 <table id="user-tab">
32                                         <tr>
33                                         <th>+/-</th>
34                                         <th>email</th>
35                                         <th>user_hrn</th>
36                                         <th>first name</th>
37                                         <th>last name</th>
38                                         <th>enabled</th>
39                                         </tr>
40                                 </table>
41                                 {%if 'is_pi'  in pi %}  
42                                 <div>
43                                         <button id="deleteusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Users</button>
44                                 </div>
45                                 {%endif%}
46                         </div>
47                 </div>
48         </div>
49         
50         <div class="tab-pane row" id="slices">
51             <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
52             <div id="slice-tab-loaded" style="display:none;">
53                 {%if 'is_pi'  in pi %}
54                 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> create slice</button>
55                 {%else%}
56                 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> request slice</button>
57                 {%endif%}
58                 <table id="slice-tab">
59                     <tr>
60                         <th>+/-</th>
61                         <th>slice_hrn</th>
62                         <th>users</th>
63                         <th>url</th>
64                         <!-- <th>nodes</th> -->
65                         <th>expiration</th>
66                     </tr>
67                 </table>
68                 <br>
69                         {%if 'is_pi'  in pi %}
70                 <div>
71                     <button id="renewslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
72                     <button id="deleteslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
73                 </div>
74                         {%endif%} 
75             </div>
76         </div>
77 </div>
78 <script>
79 $(document).ready(function() {
80     {% if person %}
81     {% if user_details.parent_authority %}
82         
83         $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
84             var authority_data = [];
85             var onelab_data = [];
86                         /* 'city','enabled','legal','longitude','onelab_membership','address','parent_authority','slice','user','country',
87             'tech','abbreviated_name','url','postcode','description','scientific','authority_hrn','latitude','name'     */
88             $.each( data, function( key, val ) {
89                 authority_row = "<img src='{{ STATIC_URL }}img/institutions/{{user_details.parent_authority}}.gif' alt='' /><br>";
90                 authority_row += "<br>";
91                 authority_row += "<b>authority:</b> "+val.authority_hrn+"<br>";
92                 authority_data.push(authority_row);
93             });
94             $("div#authority-data").html(authority_data.join( "" ));
95             $("div#onelab-data").html(onelab_data.join( "" ));
96             $("div#authority-tab-loaded").css("display","block");
97             $("div#authority-tab-loading").css("display","none");
98          });
99
100         $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
101             var list_slices = [];
102             var table_slices = [];
103             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
104             $.each( data, function( key, val ) {
105                 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
106                 if(val.nodes=="undefined" || val.nodes==null){
107                     nodes_length=0;
108                 }else{
109                     nodes_length=val.nodes.length;
110                 }
111                 if(val.users=="undefined" || val.users==null){
112                     users_length=0;
113                 }else{
114                     users_length=val.users.length;
115                 }
116
117                 if(val.slice_url=="undefined" || val.slice_url==null){
118                     slice_url="";
119                 }else{
120                     slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
121                 }
122                 
123                 slice_row = "<tr id='"+val.slice_hrn+"'>";
124                 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
125                 slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
126                 slice_row += "<td>"+users_length+"</td>";
127                 slice_row += "<td>"+slice_url+"</td>";
128                 //slice_row += "<td>"+nodes_length+"</td>";
129                 slice_row += "<td>"+val.slice_expires+"</td>";
130                 slice_row += "</tr>";
131                 table_slices.push(slice_row);
132                 
133             });
134            
135             /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
136             $("table#slice-tab tr:last").after(table_slices.join( "" ));
137             $("div#slice-tab-loaded").css("display","block");
138             $("div#slice-tab-loading").css("display","none");
139         });
140
141                 $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
142              var list_users = [];
143              var table_users = [];
144                          /* Available fields
145                          user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
146                          user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
147                          */
148              $.each( data, function( key, val ) {
149                  list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
150                  user_row = "<tr id='"+val.user_hrn+"'>";
151                  user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
152                  user_row += "<td>"+val.user_email+"</td>";
153                  user_row += "<td>"+val.user_hrn+"</td>";
154                  user_row += "<td>"+val.user_first_name+"</td>";
155                  user_row += "<td>"+val.user_last_name+"</td>";
156                                  user_row += "<td>"+val.user_enabled+"</td>";
157                  user_row += "</tr>";
158                  table_users.push(user_row);
159              });
160              $("table#user-tab tr:last").after(table_users.join( "" ));
161              $("div#user-tab-loaded").css("display","block");
162              $("div#user-tab-loading").css("display","none");
163           });
164
165    {% endif %}
166    {% endif %}
167
168 }); // end document.ready
169 </script>
170 {% endblock %}