FIBRE: updated to the new version, wip on institution page
[myslice.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><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         <div class="tab-pane active row" id="about">
31         <div class="col-md-6">
32                 <div>
33                         <img src="{{ STATIC_URL|add:'img/institutions/'|add:authority.authority_hrn|add:'.gif'|file_exists }}" alt="{{authority.name}}">
34                 </div>
35                 <br />
36                 <h3><a href="{{authority.url}}">{{authority.name}}</a></h3>
37                 <p>
38                         {{authority.address}} <br />
39                         {{authority.postcode}} {{authority.city}} <br />
40                         {{authority.country}}
41                 </p>
42                 <br />
43                 <h4>Onelab membership</h4> 
44                 <p>
45                         {{ authority.onelab_membership }}
46                 </p>
47         </div>
48         <div class="col-md-6">
49                 <h4>Legal Contact:</h4>
50                 <p>
51                 {% for c in authority_contacts.legal %}
52                          {{ c }} <br />
53                 {% endfor %}
54                 </p>
55                 <br />
56                 <h4>Scientific Contact:</h4>
57                 <p>
58                 {% for c in authority_contacts.scientific %}
59                         {{ c }} <br />
60                 {% endfor %}
61                 </p>
62                 <br />
63                 <h4>Technical Contact:</h4>
64                 <p>
65                 {% for c in authority_contacts.technical %}
66                         {{ c }} <br />
67                 {% endfor %}
68                 </p>
69         </div>
70         <script>
71         $(document).ready(function() {
72             $('#authority_name').text("{{ authority.name|default:authority.authority_hrn }}");
73         });
74         </script>
75         </div>
76         
77         <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
78                 <div class="col-md-12 el">
79                         <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
80                                 <div id="user-tab-loaded" style="display:none;">
81                                 <table id="user-tab" class="table">
82                                         <tr>
83                                         <th>+/-</th>
84                                         <th>Email</th>
85                                         <th>User hrn</th>
86                                         <th>First name</th>
87                                         <th>Last name</th>
88                                         <th>Enabled</th>
89                                         </tr>
90                                 </table>
91                                 
92                         </div>
93                         {%if 'is_pi'  in pi %}  
94                         <div>
95                                 <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
96                         </div>
97                         {% endif %}
98                 </div>
99         </div>
100
101         <div class="tab-pane row" id="slices">
102                 <div class="col-md-12 el">
103             <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
104             <div id="slice-tab-loaded" style="display:none;">
105                 <table id="slice-tab" class="table">
106                     <tr>
107                         <th>+/-</th>
108                         <th>Slice hrn</th>
109                         <th>Users</th>
110                         <th>Url</th>
111                         <!-- <th>nodes</th> -->
112                         <th>Expiration</th>
113                     </tr>
114                 </table>                        
115             </div>
116         {% if 'is_pi'  in pi %}
117         <div>
118                 {% if 'is_pi'  in pi %}
119                         <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
120                         {% else %}
121                         <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
122                         {% endif %}
123             <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
124             <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
125         </div>
126                 {% endif %} 
127            </div>
128         </div>
129         <div class="tab-pane row" id="requests">
130         </div>
131 </div>
132 <script>
133 $(document).ready(function() {
134     {% if person %}
135     {% if user_details.parent_authority %}
136
137         $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
138             var list_slices = [];
139             var table_slices = [];
140             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
141             $.each( data, function( key, val ) {
142                 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
143                 if(val.nodes=="undefined" || val.nodes==null){
144                     nodes_length=0;
145                 }else{
146                     nodes_length=val.nodes.length;
147                 }
148                 console.log(val);
149                 if(val.users=="undefined" || val.users==null){
150                     users_length=0;
151                 }else{
152                     users_length=val.users.length;
153                 }
154
155                 if(val.slice_url=="undefined" || val.slice_url==null){
156                     slice_url="";
157                 }else{
158                     slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
159                 }
160                 
161                 slice_row = "<tr id='"+val.slice_hrn+"'>";
162                 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
163                 slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
164                 slice_row += "<td>"+users_length+"</td>";
165                 slice_row += "<td>"+slice_url+"</td>";
166                 //slice_row += "<td>"+nodes_length+"</td>";
167                 slice_row += "<td>"+val.slice_expires+"</td>";
168                 slice_row += "</tr>";
169                 table_slices.push(slice_row);
170                 
171             });
172            
173             /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
174             $("table#slice-tab tr:last").after(table_slices.join( "" ));
175             $("div#slice-tab-loaded").css("display","block");
176             $("div#slice-tab-loading").css("display","none");
177         });
178                 
179                 
180         $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
181             var list_users = [];
182             var table_users = [];
183                     /* Available fields
184                     user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
185                     user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
186                     */
187             $.each( data, function( key, val ) {
188                 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
189                 user_row = "<tr id='"+val.user_hrn+"'>";
190                 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
191                 user_row += "<td>"+val.user_email+"</td>";
192                 user_row += "<td>"+val.user_hrn+"</td>";
193                 user_row += "<td>"+val.user_first_name+"</td>";
194                 user_row += "<td>"+val.user_last_name+"</td>";
195                             user_row += "<td>"+val.user_enabled+"</td>";
196                 user_row += "</tr>";
197                 table_users.push(user_row);
198             });
199             $("table#user-tab tr:last").after(table_users.join( "" ));
200             $("div#user-tab-loaded").css("display","block");
201             $("div#user-tab-loading").css("display","none");
202         });
203
204     {% endif %}
205     {% endif %}
206
207 }); // End document.ready
208 /*
209 $(document).ready(function() {
210         $('.nav-tabs a').click(function (e) {
211                 e.preventDefault();
212                 $(this).tab('show');
213         var id = $(this).attr('href').substr(1);
214         if ((id == 'requests') || (id == 'about'))
215                 $("#" + id).load('/management/' + id);
216         });
217         var hash = window.location.hash;
218         if (hash) {
219                 $('.nav-tabs a[href='+hash+']').click();
220         } else {
221                 $('.nav-tabs a[href=#about]').click();
222         }
223 });
224 */
225 </script>
226 {% endblock %}