Added files in FIBRE
[myslice.git] / portal / templates / fibre / fibre_institution.html
1 {% extends "layout.html" %}
2 {% block head %} 
3 <script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
4 {% endblock head %}
5 {% block content %}
6 <div class="row">
7         <h1><img src="{{ STATIC_URL }}img/icon_authority_color_small.png" alt="" /> Institution: {{user_details.parent_authority}}</h1>
8 </div>
9 <div class="row" id="institution">
10     <ul class="nav nav-tabs">
11       <li class="active" id="authority-tab"><a class="home-tab" data-panel="institution" href="#">INFO</a></li>
12       <li id="users-tab"><a class="home-tab" data-panel="users" href="#">USERS</a></li>
13       <li id="slices-tab"><a class="home-tab" data-panel="slices" href="#">SLICES</a></li>
14     </ul>
15     <div class="home-panel" id="institution">
16         <div id="authority-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Authority" /></div>
17         <div id="authority-tab-loaded" style="display:none;">
18             <div id="authority-data" style="float:left; width:50%;"></div>
19         </div>
20     </div>
21     <div class="home-panel" id="users" style="display:none;">
22         <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
23         <div id="user-tab-loaded" style="display:none;">
24             <table id="user-tab">
25                 <tr>
26                     <th>+/-</th>
27                     <th>Email</th>
28                     <th>user_hrn</th>
29                     <th>First name</th>
30                     <th>Last name</th>
31                     <th>Enabled</th>
32                 </tr>
33             </table>
34             <br>
35             <button id="deleteusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Users</button>
36         </div>
37         </div>
38     <div class="home-panel" id="slices" style="display:none;">
39         <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> create slice</button>
40         <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
41         <div id="slice-tab-loaded" style="display:none;">
42             <table id="slice-tab">
43                 <tr>
44                     <th>+/-</th>
45                     <th>slice_hrn</th>
46                     <th>users</th>
47                     <th>url</th>
48                     <th>nodes</th>
49                     <th>expiration</th>
50                 </tr>
51             </table>
52             <br>
53             <div>
54                 <button id="renewslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
55                 <button id="deleteslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
56             </div>
57         </div>
58     </div>
59 </div>
60 <script>
61     $(document).ready(function() {
62         {% if person %}
63         {% if user_details.parent_authority %}
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_row += "<br>";
74                 /*
75                 authority_row += "<b>"+val.name+"</b><br>";
76                 authority_row += "<br>";
77                 authority_row += "<b>Address:</b> "+val.address+"<br>";
78                 authority_row += "<b>City:</b> "+val.postcode+" "+val.city+"<br>";
79                 authority_row += "<br>";
80                 authority_row += "<b>Country:</b> "+val.country+"<br>";
81                 authority_row += "<br>";
82                 authority_row += "<br>";
83                 authority_row += "<h2>Contacts</h2>";
84                 authority_row += "<b>Legal:</b> ";
85                 */
86                 /*
87
88                 TODO: find a way to express JSON correctly given the constrains: CSV / JSON
89
90                 legal = jQuery.parseJSON(val.legal);
91                 if($.isArray(legal)){
92                     $.each(legal, function(k,v){
93                         authority_row += k+" "+v+"<br>";
94                     });
95                 }else{
96                     authority_row += val.legal+"<br>";
97                 //}
98                 authority_row += "<br>";
99                 authority_row += "<b>Scientific:</b> ";
100                 scientific = jQuery.parseJSON(val.scientific);
101                 if($.isArray(scientific)){
102                     $.each(scientific, function(v){
103                         authority_row += v+", ";
104                     });
105                 }else{
106                 
107                     authority_row += val.scientific+"<br>";
108                 }
109                 onelab_membership = "<b>Status: </b>"+val.onelab_membership;
110                 onelab_data.push(onelab_membership);
111                 */
112                 authority_data.push(authority_row);
113             });
114             $("div#authority-data").html(authority_data.join( "" ));
115             $("div#onelab-data").html(onelab_data.join( "" ));
116             $("div#authority-tab-loaded").css("display","block");
117             $("div#authority-tab-loading").css("display","none");
118          });
119
120         $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
121             var list_slices = [];
122             var table_slices = [];
123             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "user", "slice_urn", "slice_expires" */
124             $.each( data, function( key, val ) {
125                 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
126                 if(val.nodes=="undefined" || val.nodes==null){
127                     nodes_length=0;
128                 }else{
129                     nodes_length=val.nodes.length;
130                 }
131
132                 if(val.user=="undefined" || val.user==null){
133                     user_length=0;
134                 }else{
135                     user_length=val.user.length;
136                 }
137
138                 if(val.slice_url=="undefined" || val.slice_url==null){
139                     slice_url="";
140                 }else{
141                     slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
142                 }
143                 
144                 slice_row = "<tr id='"+val.slice_hrn+"'>";
145                 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
146                 slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
147                 slice_row += "<td>"+user_length+"</td>";
148                 slice_row += "<td>"+slice_url+"</td>";
149                 slice_row += "<td>"+nodes_length+"</td>";
150                 slice_row += "<td>"+val.slice_expires+"</td>";
151                 slice_row += "</tr>";
152                 table_slices.push(slice_row);
153                 
154             });
155            
156             /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
157             $("table#slice-tab tr:last").after(table_slices.join( "" ));
158             $("div#slice-tab-loaded").css("display","block");
159             $("div#slice-tab-loading").css("display","none");
160         });
161
162         $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
163             var list_users = [];
164             var table_users = [];
165                         /* Available fields
166                         user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
167                         user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
168                         */
169             $.each( data, function( key, val ) {
170                 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
171
172                 user_row = "<tr id='"+val.user_hrn+"'>";
173                 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
174                 user_row += "<td>"+val.user_email+"</td>";
175                 user_row += "<td>"+val.user_hrn+"</td>";
176                 user_row += "<td>"+val.user_first_name+"</td>";
177                 user_row += "<td>"+val.user_last_name+"</td>";
178                                 user_row += "<td>"+val.user_enabled+"</td>";
179                 user_row += "</tr>";
180                 table_users.push(user_row);
181                 
182             });
183             $("table#user-tab tr:last").after(table_users.join( "" ));
184             $("div#user-tab-loaded").css("display","block");
185             $("div#user-tab-loading").css("display","none");
186          });
187          {% endif %}
188          {% endif %}
189     });
190 </script>
191 {% endblock %}