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>
31 <li><a href="#requests">Requests</a></li>
36 <div class="container tab-content">
37 <div class="tab-pane active row" id="about">
38 <div class="col-md-12 el">
39 <h2>{{user_details.parent_authority}}</h2>
43 <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
44 <div class="col-md-12 el">
45 <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
46 <div id="user-tab-loaded" style="display:none;">
47 <table id="user-tab" class="table">
66 <button id="removepi" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Remove from project</button>
68 <button id="makepi" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-up"></span> Upgrade to PI</button>
69 <button id="removepi" type="button" class="btn"><span class="glyphicon glyphicon-arrow-down"></span> Downgrade to user</button>
70 <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
78 <div class="tab-pane row" id="projects" data-authority="{{user_details.parent_authority}}">
79 <div class="col-md-12 el">
80 <div id="project-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Projects" /></div>
81 <div id="project-tab-loaded" style="display:none;">
82 <table id="project-tab" class="table">
92 <button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create project</button>
93 <button id="deleteprojects" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected projects</button>
95 <button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request project</button>
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">
111 <!-- <th>nodes</th> -->
118 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
119 <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
120 <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
122 <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
127 <div class="tab-pane row" id="requests">
128 <div id="spinner" style="padding-top:40px; padding-left:40px;"/>
132 $(document).ready(function() {
134 {% if user_details.parent_authority %}
135 $('#spinner').spin();
137 $.post("/rest/myslice:slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'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){
146 nodes_length=val.nodes.length;
149 if(val.users=="undefined" || val.users==null){
152 users_length=val.users.length;
155 if(val.url=="undefined" || val.url==null){
158 slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
161 slice_row = "<tr id='"+val.slice_hrn+"'>";
162 slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
164 // filter links to slices, only those that the user has credentials for
165 s = myslice.user.slices;
166 if(s.length > 0 && $.inArray(val.slice_hrn, myslice.user.slices)!=-1){
167 slice_row += "<td><a href='/slice/"+val.slice_hrn+"'>" + val.slice_hrn + "</a></td>";
169 slice_row += "<td>" + val.slice_hrn + "</td>";
171 slice_row += "<td>"+users_length+"</td>";
172 slice_row += "<td>"+slice_url+"</td>";
173 //slice_row += "<td>"+nodes_length+"</td>";
174 slice_row += "<td>"+val.slice_date_created+"</td>";
175 slice_row += "</tr>";
176 table_slices.push(slice_row);
180 /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
181 $("table#slice-tab tr:last").after(table_slices.join( "" ));
182 $("div#slice-tab-loaded").css("display","block");
183 $("div#slice-tab-loading").css("display","none");
187 $.post("/rest/myslice:authority/",{'fields':['pi_users'],'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
189 var table_users = [];
190 $.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+"'></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+"'></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 ) {
234 project_row = "<tr id='"+val.authority_hrn+"'>";
235 project_row += "<td><input type='checkbox' class='project' id='"+val.authority_hrn+"'></td>";
237 // filter links to projects, only those that the user has credentials for
238 p = myslice.projects;
239 if(p.length > 0 && $.inArray(val.authority_hrn, p)!=-1){
240 project_row += "<td><a href='/portal/project/"+val.authority_hrn+"'>"+val.authority_hrn+"</a></td>";
242 project_row += "<td>"+val.authority_hrn+"</td>";
244 project_row += "</tr>";
245 table_projects.push(project_row);
247 $("table#project-tab tr:last").after(table_projects.join( "" ));
248 $("div#project-tab-loaded").css("display","block");
249 $("div#project-tab-loading").css("display","none");
257 }); // End document.ready
259 $(document).ready(function() {
260 $('.nav-tabs a').click(function (e) {
263 var id = $(this).attr('href').substr(1);
264 if ((id == 'requests')){
265 $("#" + id).load('/management/' + id);
268 if ((id == 'requests') || (id == 'about'))
269 $("#" + id).load('/management/' + id);
272 var hash = window.location.hash;
274 $('.nav-tabs a[href='+hash+']').click();
276 $('.nav-tabs a[href=#about]').click();
280 //upgrade users to PI
281 $(document).ready(function() {
282 $('button#makepi').click(function() {
285 $.post("/rest/myslice:authority/",{'filters':{'authority_hrn': '{{user_details.parent_authority}}'}}, function( data ) {
286 pi_users = data[0]["pi_users"];
287 $('input:checkbox.user').each(function (index) {
289 var record_id = this.id;
290 pi_users.push(record_id)
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 $(document).ready(function() {
309 $('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);
327 $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
329 mysliceAlert('Success: User rights removed from: {{user_details.parent_authority}}','success', true);
331 // remove the user from the list of pis of the project displayed
332 $('input:checkbox.user').each(function (index) {
334 var record_id = this.id;
335 $('tr[id="'+record_id+'"]').fadeOut("slow");
336 $('tr[id="'+record_id+'"]').remove();
342 mysliceAlert('Rest Error for: '+data.error,'warning', true);
343 //alert("Rest Error for "+record_id+": "+data.error);