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