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