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
18 <div class="container">
19   <div class="row">
20     <div class="col-md-12">
21       <ul class="nav nav-tabs nav-section">
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
30 <div class="container tab-content">
31         <div class="tab-pane active row" id="users" data-authority="{{user_details.parent_authority}}">
32                 <div class="col-md-12 el">
33                         <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
34                                 <div id="user-tab-loaded" style="display:none;">
35                                 <table id="user-tab" class="table">
36                                         <tr>
37                                         <th>+/-</th>
38                                         <th>User hrn </th>
39                                         <th>Email</th>
40                                         <th>First name</th>
41                                         <th>Last name</th>
42                                         <th>Enabled</th>
43                                         </tr>
44                                 </table>
45                                 
46                         </div>
47                         {%if 'is_pi'  in pi %}  
48                         <div>
49                                 <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
50                         </div>
51                         <p></p>
52                         <p></p>
53                         <div> <button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button> </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             <p></p>
83             <p></p>
84             <div><button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button></div>
85         </div>
86                 {% endif %} 
87            </div>
88         </div>
89         <div class="tab-pane row" id="requests">
90         </div>
91 </div>
92 <script>
93 $(document).ready(function() {
94     {% if person %}
95     {% if user_details.parent_authority %}
96
97         $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
98             var list_slices = [];
99             var table_slices = [];
100             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
101             $.each( data, function( key, val ) {
102                 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
103                 if(val.nodes=="undefined" || val.nodes==null){
104                     nodes_length=0;
105                 }else{
106                     nodes_length=val.nodes.length;
107                 }
108                 console.log(val);
109                 if(val.users=="undefined" || val.users==null){
110                     users_length=0;
111                 }else{
112                     users_length=val.users.length;
113                 }
114
115                 if(val.slice_url=="undefined" || val.slice_url==null){
116                     slice_url="";
117                 }else{
118                     slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
119                 }
120                 
121                 slice_row = "<tr id='"+val.slice_hrn+"'>";
122                 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
123                 slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
124                 slice_row += "<td>"+val.users[0]+"</td>";
125                 slice_row += "<td>"+slice_url+"</td>";
126                 //slice_row += "<td>"+nodes_length+"</td>";
127                 slice_row += "<td>"+val.slice_expires+"</td>";
128                 slice_row += "</tr>";
129                 table_slices.push(slice_row);
130             });
131            
132             /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
133             $("table#slice-tab tr:last").after(table_slices.join( "" ));
134             $("div#slice-tab-loaded").css("display","block");
135             $("div#slice-tab-loading").css("display","none");
136         });
137                 
138                 
139         $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
140             var username ="{{person.username}}";
141             var list_users = [];
142             var table_users = [];
143                     /* Available fields
144                     user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
145                     user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
146                     */
147             $.each( data, function( key, val ) {
148                 if (val.user_hrn.indexOf('@') != -1 ){
149                   if (val.user_hrn.split("@")[1] == username.split("@")[1]){
150                     list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
151                     user_row = "<tr id='"+val.user_hrn+"'>";
152                     user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
153                     user_row += "<td>"+val.user_hrn+"</td>";
154                     user_row += "<td>"+val.user_email+"</td>";
155                     user_row += "<td>"+val.user_first_name+"</td>";
156                     user_row += "<td>"+val.user_last_name+"</td>";
157                                 user_row += "<td>"+val.user_enabled+"</td>";
158                     user_row += "</tr>";
159                 table_users.push(user_row);}
160                 }
161             });
162             $("table#user-tab tr:last").after(table_users.join( "" ));
163             $("div#user-tab-loaded").css("display","block");
164             $("div#user-tab-loading").css("display","none");
165         });
166
167     {% endif %}
168     {% endif %}
169
170 }); // End document.ready
171
172 $(document).ready(function() {
173         $('.nav-tabs a').click(function (e) {
174                 e.preventDefault();
175                 $(this).tab('show');
176         var id = $(this).attr('href').substr(1);
177         if ((id == 'requests') || (id == 'about'))
178                 $("#" + id).load('/management/' + id);
179         });
180         var hash = window.location.hash;
181         if (hash) {
182                 $('.nav-tabs a[href='+hash+']').click();
183         } else {
184                 $('.nav-tabs a[href=#about]').click();
185         }
186 });
187 </script>
188 {% endblock %}