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 <div class="breadcrumbs">
13 Management > Project: <span id="authority_name">{{user_details.parent_authority}}</span>
15 Management > Institution: <span id="authority_name">{{user_details.parent_authority}}</span>
21 <div class="container">
23 <div class="col-md-12">
24 <ul class="nav nav-tabs nav-section">
25 <li class="active"><a href="#about">About</a></li>
26 <li><a href="#users">Users</a></li>
28 <li><a href="#projects">Projects</a></li>
30 <li><a href="#slices">Slices</a></li>
32 <li><a href="#requests">Requests</a></li>
37 <div class="container tab-content">
38 <div class="tab-pane active row" id="about">
39 <div class="col-md-12 el">
40 <h2>{{user_details.parent_authority}}</h2>
44 <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
45 <div class="col-md-12 el">
46 <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
47 <div id="user-tab-loaded" style="display:none;">
48 <table id="user-tab" class="table">
67 <button id="removepi" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Remove from project</button>
69 <button id="makepi" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-up"></span> Upgrade to PI</button>
70 <button id="removepi" type="button" class="btn"><span class="glyphicon glyphicon-arrow-down"></span> Downgrade to user</button>
71 <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
79 <div class="tab-pane row" id="projects" data-authority="{{user_details.parent_authority}}">
80 <div class="col-md-12 el">
81 <div id="project-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Projects" /></div>
82 <div id="project-tab-loaded" style="display:none;">
83 <table id="project-tab" class="table">
93 <button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create project</button>
94 <button id="deleteprojects" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected projects</button>
96 <button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request project</button>
102 <div class="tab-pane row" id="slices">
103 <div class="col-md-12 el">
104 <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
105 <div id="slice-tab-loaded" style="display:none;">
106 <table id="slice-tab" class="table">
112 <!-- <th>nodes</th> -->
119 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
120 <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
121 <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
123 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
128 <div class="tab-pane row" id="requests">
129 <div id="spinner" style="padding-top:40px; padding-left:40px;"></div>
133 $(document).ready(function() {
135 {% if user_details.parent_authority %}
136 $('#spinner').spin();
137 $('#loading').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;
151 if(val.users=="undefined" || val.users==null){
154 users_length=val.users.length;
157 if(val.url=="undefined" || val.url==null){
160 slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
163 slice_row = "<tr id='"+val.slice_hrn+"'>";
164 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'><div id='loading' style='float: right;'></div></td>";
166 // filter links to slices, only those that the user has credentials for
167 s = myslice.user.slices;
168 if(s.length > 0 && $.inArray(val.slice_hrn, myslice.user.slices)!=-1){
169 slice_row += "<td><a href='/slice/"+val.slice_hrn+"'>" + val.slice_hrn + "</a></td>";
171 slice_row += "<td>" + val.slice_hrn + "</td>";
173 slice_row += "<td>"+users_length+"</td>";
174 slice_row += "<td>"+slice_url+"</td>";
175 //slice_row += "<td>"+nodes_length+"</td>";
176 slice_row += "<td>"+val.slice_date_created+"</td>";
177 slice_row += "</tr>";
178 table_slices.push(slice_row);
182 /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
183 $("table#slice-tab tr:last").after(table_slices.join( "" ));
184 $("div#slice-tab-loaded").css("display","block");
185 $("div#slice-tab-loading").css("display","none");
189 $.post("/rest/myslice:authority/",{'fields':['pi_users'],'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
191 var table_users = [];
192 $.each( data[0].pi_users, function( key, val ) {
194 user_row = "<tr id='"+val+"'>";
195 user_row += "<td><input type='checkbox' class='user' id='"+val+"'></td>";
196 user_row += "<td>"+val+"</td>";
198 table_users.push(user_row);
200 $("table#user-tab tr:last").after(table_users.join( "" ));
201 $("div#user-tab-loaded").css("display","block");
202 $("div#user-tab-loading").css("display","none");
206 $.post("/rest/myslice:user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
208 var table_users = [];
210 user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
211 user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
213 $.each( data, function( key, val ) {
214 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
215 user_row = "<tr id='"+val.user_hrn+"'>";
216 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"' data-email='"+val.user_email+"'></td>";
217 user_row += "<td>"+val.user_email+"</td>";
218 user_row += "<td>"+val.user_hrn+"</td>";
220 user_row += "<td>"+val.user_first_name+"</td>";
221 user_row += "<td>"+val.user_last_name+"</td>";
222 user_row += "<td>"+val.user_enabled+"</td>";
225 table_users.push(user_row);
227 $("table#user-tab tr:last").after(table_users.join( "" ));
228 $("div#user-tab-loaded").css("display","block");
229 $("div#user-tab-loading").css("display","none");
231 $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS{{user_details.parent_authority}}'}}, function( data ) {
233 var table_projects = [];
234 $.each( data, function( key, val ) {
236 project_row = "<tr id='"+val.authority_hrn+"'>";
237 project_row += "<td><input type='checkbox' class='project' id='"+val.authority_hrn+"'></td>";
239 // filter links to projects, only those that the user has credentials for
240 p = myslice.projects;
241 if(p.length > 0 && $.inArray(val.authority_hrn, p)!=-1){
242 project_row += "<td><a href='/portal/project/"+val.authority_hrn+"'>"+val.authority_hrn+"</a></td>";
244 project_row += "<td>"+val.authority_hrn+"</td>";
246 project_row += "</tr>";
247 table_projects.push(project_row);
249 $("table#project-tab tr:last").after(table_projects.join( "" ));
250 $("div#project-tab-loaded").css("display","block");
251 $("div#project-tab-loading").css("display","none");
259 }); // End document.ready
261 $(document).ready(function() {
262 $('.nav-tabs a').click(function (e) {
265 var id = $(this).attr('href').substr(1);
266 if ((id == 'requests')){
267 $("#" + id).load('/management/' + id);
270 if ((id == 'requests') || (id == 'about'))
271 $("#" + id).load('/management/' + id);
274 var hash = window.location.hash;
276 $('.nav-tabs a[href='+hash+']').click();
278 $('.nav-tabs a[href=#about]').click();
282 //upgrade users to PI
283 $(document).ready(function() {
284 $('button#makepi').click(function() {
287 $.post("/rest/myslice:authority/",{'filters':{'authority_hrn': '{{user_details.parent_authority}}'}}, function( data ) {
288 pi_users = data[0]["pi_users"];
289 $('input:checkbox.user').each(function (index) {
291 var record_id = this.id;
292 pi_users.push(record_id)
293 $.post("/credentials/clear/",{'emails':[this.dataset['email']]}, function(data) {
294 }); // post credentials clear
299 $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
301 mysliceAlert('Success: User rights added to: {{user_details.parent_authority}}','success', true);
303 mysliceAlert('Rest Error for: '+data.error,'warning', true);
304 //alert("Rest Error for "+record_id+": "+data.error);
311 //downgrade to user [in projects:remove from project]
312 $(document).ready(function() {
313 $('button#removepi').click(function() {
316 $.post("/rest/myslice:authority/",{'filters':{'authority_hrn': '{{user_details.parent_authority}}'}}, function( data ) {
317 pi_users = data[0]["pi_users"];
318 // http://stackoverflow.com/questions/9792927/javascript-array-search-and-remove-string
319 $('input:checkbox.user').each(function (index) {
321 var record_id = this.id;
322 for (var i=pi_users.length-1; i>=0; i--) {
323 if (pi_users[i] === record_id) {
324 pi_users.splice(i, 1);
325 $.post("/credentials/clear/",{'emails':[this.dataset['email']]}, function(data) {
326 }); // post credentials clear
333 $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
335 mysliceAlert('Success: User rights removed from: {{user_details.parent_authority}}','success', true);
337 // remove the user from the list of pis of the project displayed
338 $('input:checkbox.user').each(function (index) {
340 var record_id = this.id;
341 $('tr[id="'+record_id+'"]').fadeOut("slow");
342 $('tr[id="'+record_id+'"]').remove();
348 mysliceAlert('Rest Error for: '+data.error,'warning', true);
349 //alert("Rest Error for "+record_id+": "+data.error);
353 mysliceAlert('No action: User had no rights on: {{user_details.parent_authority}}','success', true);