1 {% extends "layout_wide.html" %}
4 <script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
8 <div class="container">
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>
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" style="float:left; width:50%;"></div>
25 <div id="onelab_membership" style="float:right; width:50%;">
26 <img src="{{ STATIC_URL }}img/onelab-logo.png" alt="" /><br>
27 <div id="onelab-data"></div>
33 <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
34 <div class="col-md-12">
35 <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
36 <div id="user-tab-loaded" style="display:none;">
49 <button id="deleteusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Users</button>
56 <div class="tab-pane row" id="slices">
58 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> create slice</button>
60 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> request slice</button>
62 <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
63 <div id="slice-tab-loaded" style="display:none;">
64 <table id="slice-tab">
77 <button id="renewslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
78 <button id="deleteslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
85 $(document).ready(function() {
87 {% if user_details.parent_authority %}
89 $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
90 var authority_data = [];
92 /* 'city','enabled','legal','longitude','onelab_membership','address','parent_authority','slice','user','country',
93 'tech','abbreviated_name','url','postcode','description','scientific','authority_hrn','latitude','name' */
94 $.each( data, function( key, val ) {
95 authority_row = "<img src='{{ STATIC_URL }}img/institutions/{{user_details.parent_authority}}.gif' alt='' /><br>";
96 authority_row += "<br>";
97 authority_row += "<b>authority:</b> "+val.authority_hrn+"<br>";
98 authority_row += "<br>";
99 authority_row += "<b>"+val.name+"</b><br>";
100 authority_row += "<br>";
101 authority_row += "<b>Address:</b> "+val.address+"<br>";
102 authority_row += "<b>City:</b> "+val.postcode+" "+val.city+"<br>";
103 authority_row += "<br>";
104 authority_row += "<b>Country:</b> "+val.country+"<br>";
105 authority_row += "<br>";
106 authority_row += "<br>";
107 authority_row += "<h2>Contacts</h2>";
108 authority_row += "<b>Legal:</b> ";
111 TODO: find a way to express JSON correctly given the constrains: CSV / JSON
113 legal = jQuery.parseJSON(val.legal);
114 if($.isArray(legal)){
115 $.each(legal, function(k,v){
116 authority_row += k+" "+v+"<br>";
120 authority_row += val.legal+"<br>";
122 authority_row += "<br>";
123 authority_row += "<b>Scientific:</b> ";
125 scientific = jQuery.parseJSON(val.scientific);
126 if($.isArray(scientific)){
127 $.each(scientific, function(v){
128 authority_row += v+", ";
132 authority_row += val.scientific+"<br>";
134 onelab_membership = "<b>Status: </b>"+val.onelab_membership;
135 onelab_data.push(onelab_membership);
136 authority_data.push(authority_row);
139 $("div#authority-data").html(authority_data.join( "" ));
140 $("div#onelab-data").html(onelab_data.join( "" ));
141 $("div#authority-tab-loaded").css("display","block");
142 $("div#authority-tab-loading").css("display","none");
145 $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
146 var list_slices = [];
147 var table_slices = [];
148 /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
149 $.each( data, function( key, val ) {
150 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
151 if(val.nodes=="undefined" || val.nodes==null){
154 nodes_length=val.nodes.length;
157 if(val.users=="undefined" || val.users==null){
160 users_length=val.users.length;
163 if(val.slice_url=="undefined" || val.slice_url==null){
166 slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
169 slice_row = "<tr id='"+val.slice_hrn+"'>";
170 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
171 slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
172 slice_row += "<td>"+users_length+"</td>";
173 slice_row += "<td>"+slice_url+"</td>";
174 slice_row += "<td>"+nodes_length+"</td>";
175 slice_row += "<td>"+val.slice_expires+"</td>";
176 slice_row += "</tr>";
177 table_slices.push(slice_row);
181 /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
182 $("table#slice-tab tr:last").after(table_slices.join( "" ));
183 $("div#slice-tab-loaded").css("display","block");
184 $("div#slice-tab-loading").css("display","none");
188 $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
190 var table_users = [];
192 user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
193 user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
195 $.each( data, function( key, val ) {
196 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
197 user_row = "<tr id='"+val.user_hrn+"'>";
198 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
199 user_row += "<td>"+val.user_email+"</td>";
200 user_row += "<td>"+val.user_hrn+"</td>";
201 user_row += "<td>"+val.user_first_name+"</td>";
202 user_row += "<td>"+val.user_last_name+"</td>";
203 user_row += "<td>"+val.user_enabled+"</td>";
205 table_users.push(user_row);
208 $("table#user-tab tr:last").after(table_users.join( "" ));
209 $("div#user-tab-loaded").css("display","block");
210 $("div#user-tab-loading").css("display","none");
213 $('button#deleteusers').click(function() {
214 $('input:checkbox.user').each(function (index) {
216 var record_id = this.id;
217 $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) {
219 $('tr[id="'+record_id+'"]').fadeOut("slow");
220 $('tr[id="'+record_id+'"]').remove();
222 alert("Rest Error for "+record_id+": "+data.error);