1 {% extends "layout_wide.html" %}
4 <script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
5 <script type="text/javascript" src="{{STATIC_URL}}js/requests.js"></script>
9 <div class="container">
11 <div class="col-md-12">
12 <div class="breadcrumbs">
14 Management > Project: <span id="authority_name">{{user_details.parent_authority}}</span>
16 Management > Institution: <span id="authority_name">{{user_details.parent_authority}}</span>
22 <div class="container">
24 <div class="col-md-12">
25 <ul class="nav nav-tabs nav-section">
26 <li class="active"><a href="#about">About</a></li>
27 <li><a href="#users">Users</a></li>
29 <li><a href="#projects">Projects</a></li>
31 <li><a href="#slices">Slices</a></li>
33 <li><a href="#requests">Requests</a></li>
38 <div class="container tab-content">
39 <div class="tab-pane active row" id="about">
40 <div class="col-md-12 el">
41 <h2>{{user_details.parent_authority}}</h2>
45 <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
46 <div class="col-md-12 el">
47 <div id="user-tab-loading" style="padding-bottom:10px;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
48 <div id="user-tab-loaded" style="display:none;">
49 <table id="user-tab" class="table">
68 <button id="removepi" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Remove from project</button>
70 <button id="makepi" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-up"></span> Upgrade to PI</button>
71 <button id="removepi" type="button" class="btn"><span class="glyphicon glyphicon-arrow-down"></span> Downgrade to user</button>
72 <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
80 <div class="tab-pane row" id="projects" data-authority="{{user_details.parent_authority}}">
81 <div class="col-md-12 el">
82 <div id="project-tab-loading" style="padding-bottom:10px;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Projects" /></div>
83 <div id="project-tab-loaded" style="display:none;">
84 <table id="project-tab" class="table">
94 <button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create project</button>
95 <button id="deleteprojects" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected projects</button>
97 <button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request project</button>
103 <div class="tab-pane row" id="slices">
104 <div class="col-md-12 el">
105 <div id="slice-tab-loading" style="padding-bottom:10px;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
106 <div id="slice-tab-loaded" style="display:none;">
107 <table id="slice-tab" class="table">
113 <!-- <th>nodes</th> -->
120 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
121 <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
122 <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
124 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
129 <div class="tab-pane row" id="requests">
130 <div id="spinner" style="padding-top:40px; padding-left:40px;"></div>
134 $(document).ready(function() {
136 {% if user_details.parent_authority %}
137 $('#spinner').spin();
139 $.post("/rest/myslice:slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
140 var list_slices = [];
141 var table_slices = [];
142 /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
143 $.each( data, function( key, val ) {
144 list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
145 if(val.nodes=="undefined" || val.nodes==null){
148 nodes_length=val.nodes.length;
150 if(val.users=="undefined" || val.users==null){
153 users_length=val.users.length;
156 if(val.url=="undefined" || val.url==null){
159 slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
162 slice_row = "<tr id='"+val.slice_hrn+"'>";
163 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'><div id='"+val.slice_hrn+"-loading' style='display:none;padding-left:3px;'><img src='{{ STATIC_URL }}img/loading.gif'></div></td>";
165 // filter links to slices, only those that the user has credentials for
166 s = myslice.user.slices;
167 if(s.length > 0 && $.inArray(val.slice_hrn, myslice.user.slices)!=-1){
168 slice_row += "<td><a href='/slice/"+val.slice_hrn+"'>" + val.slice_hrn + "</a></td>";
170 slice_row += "<td>" + val.slice_hrn + "</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_date_created+"</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/myslice:authority/",{'fields':['pi_users'],'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
190 var table_users = [];
191 $.each( data[0].pi_users, function( key, val ) {
192 user_row = "<tr id='"+val+"'>";
193 user_row += "<td><input type='checkbox' class='user' id='"+val+"'><div id='"+val+"-loading' style='display:none;padding-left:3px;'><img src='{{ STATIC_URL }}img/loading.gif'></div></td>";
194 user_row += "<td>"+val+"</td>";
196 table_users.push(user_row);
198 $("table#user-tab tr:last").after(table_users.join( "" ));
199 $("div#user-tab-loaded").css("display","block");
200 $("div#user-tab-loading").css("display","none");
204 $.post("/rest/myslice:user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
206 var table_users = [];
208 user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
209 user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
211 $.each( data, function( key, val ) {
212 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
213 user_row = "<tr id='"+val.user_hrn+"'>";
214 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"' data-email='"+val.user_email+"'><div id='"+val.user_hrn+"-loading' style='display:none;padding-left:3px;'><img src='{{ STATIC_URL }}img/loading.gif'></div></td>";
215 user_row += "<td>"+val.user_email+"</td>";
216 user_row += "<td>"+val.user_hrn+"</td>";
218 user_row += "<td>"+val.user_first_name+"</td>";
219 user_row += "<td>"+val.user_last_name+"</td>";
220 user_row += "<td>"+val.user_enabled+"</td>";
223 table_users.push(user_row);
225 $("table#user-tab tr:last").after(table_users.join( "" ));
226 $("div#user-tab-loaded").css("display","block");
227 $("div#user-tab-loading").css("display","none");
229 $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS{{user_details.parent_authority}}'}}, function( data ) {
231 var table_projects = [];
232 $.each( data, function( key, val ) {
233 project_row = "<tr id='"+val.authority_hrn+"'>";
234 project_row += "<td><input type='checkbox' class='project' id='"+val.authority_hrn+"'><div id='"+val.authority_hrn+"-loading' style='display:none;padding-left:3px;'><img src='{{ STATIC_URL }}img/loading.gif'></div></td>";
236 // filter links to projects, only those that the user has credentials for
237 p = myslice.projects;
238 if(p.length > 0 && $.inArray(val.authority_hrn, p)!=-1){
239 project_row += "<td><a href='/portal/project/"+val.authority_hrn+"'>"+val.authority_hrn+"</a></td>";
241 project_row += "<td>"+val.authority_hrn+"</td>";
243 project_row += "</tr>";
244 table_projects.push(project_row);
246 $("table#project-tab tr:last").after(table_projects.join( "" ));
247 $("div#project-tab-loaded").css("display","block");
248 $("div#project-tab-loading").css("display","none");
256 }); // End document.ready
258 $(document).ready(function() {
259 $('.nav-tabs a').click(function (e) {
262 var id = $(this).attr('href').substr(1);
263 if ((id == 'requests')){
264 $("#" + id).load('/management/' + id);
267 if ((id == 'requests') || (id == 'about'))
268 $("#" + id).load('/management/' + id);
271 var hash = window.location.hash;
273 $('.nav-tabs a[href='+hash+']').click();
275 $('.nav-tabs a[href=#about]').click();
278 //upgrade users to PI
279 $('button#makepi').click(function() {
283 $.post("/rest/myslice:authority/",{'filters':{'authority_hrn': '{{user_details.parent_authority}}'}}, function( data ) {
284 pi_users = data[0]["pi_users"];
285 $('input:checkbox.user').each(function (index) {
287 var record_id = this.id;
288 pi_users.push(record_id)
289 $.post("/credentials/clear/",{'emails':[this.dataset['email']]}, function(data) {
290 }); // post credentials clear
295 $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
297 mysliceAlert('Success: User rights added to: {{user_details.parent_authority}}','success', true);
299 mysliceAlert('Rest Error for: '+data.error,'warning', true);
300 //alert("Rest Error for "+record_id+": "+data.error);
307 //downgrade to user [in projects:remove from project]
308 $('button#removepi').click(function() {
312 $.post("/rest/myslice:authority/",{'filters':{'authority_hrn': '{{user_details.parent_authority}}'}}, function( data ) {
313 pi_users = data[0]["pi_users"];
314 // http://stackoverflow.com/questions/9792927/javascript-array-search-and-remove-string
315 $('input:checkbox.user').each(function (index) {
317 var record_id = this.id;
318 for (var i=pi_users.length-1; i>=0; i--) {
319 if (pi_users[i] === record_id) {
320 pi_users.splice(i, 1);
321 $.post("/credentials/clear/",{'emails':[this.dataset['email']]}, function(data) {
322 }); // post credentials clear
329 $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
331 mysliceAlert('Success: User rights removed from: {{user_details.parent_authority}}','success', true);
333 // remove the user from the list of pis of the project displayed
334 $('input:checkbox.user').each(function (index) {
336 var record_id = this.id;
337 $('tr[id="'+record_id+'"]').fadeOut("slow");
338 $('tr[id="'+record_id+'"]').remove();
344 mysliceAlert('Rest Error for: '+data.error,'warning', true);
345 //alert("Rest Error for "+record_id+": "+data.error);
350 mysliceAlert('No action: User had no rights on: {{user_details.parent_authority}}','success', true);