X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Ftemplates%2Ffed4fire%2Ffed4fire_institution.html;h=7e9c176efeca7ba159b712ad2b25afb6fa604aa4;hb=c457730e8d49ee507846edeb8a474374f0122f25;hp=b9a4a8e408c83cd31db00b855ba9e3958f58bbc1;hpb=50b903c99c3a28b4630b36f49ccb3e6c598d615a;p=unfold.git
diff --git a/portal/templates/fed4fire/fed4fire_institution.html b/portal/templates/fed4fire/fed4fire_institution.html
index b9a4a8e4..7e9c176e 100644
--- a/portal/templates/fed4fire/fed4fire_institution.html
+++ b/portal/templates/fed4fire/fed4fire_institution.html
@@ -87,8 +87,8 @@
- {% if pi %}
+ {% if pi %}
Create project
Delete selected projects
{% else %}
@@ -158,7 +158,14 @@ $(document).ready(function() {
slice_row = "
";
slice_row += " ";
- slice_row += "" + val.slice_hrn + " ";
+
+ // filter links to slices, only those that the user has credentials for
+ s = myslice.user.slices;
+ if(s.length > 0 && $.inArray(val.slice_hrn, myslice.user.slices)!=-1){
+ slice_row += "" + val.slice_hrn + " ";
+ }else{
+ slice_row += "" + val.slice_hrn + " ";
+ }
slice_row += ""+users_length+" ";
slice_row += ""+slice_url+" ";
//slice_row += ""+nodes_length+" ";
@@ -179,7 +186,7 @@ $(document).ready(function() {
var table_users = [];
$.each( data[0].pi_users, function( key, val ) {
- console.log(val);
+ //console.log(val);
user_row = " ";
user_row += " ";
user_row += ""+val+" ";
@@ -192,7 +199,7 @@ $(document).ready(function() {
});
{% else %}
- $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+ $.post("/rest/myslice:user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
var list_users = [];
var table_users = [];
/* Available fields
@@ -202,7 +209,7 @@ $(document).ready(function() {
$.each( data, function( key, val ) {
list_users.push( "" + val.user_email + " " );
user_row = " ";
- user_row += " ";
+ user_row += " ";
user_row += ""+val.user_email+" ";
user_row += ""+val.user_hrn+" ";
/*
@@ -224,7 +231,14 @@ $(document).ready(function() {
console.log(val);
project_row = " ";
project_row += " ";
- project_row += ""+val.authority_hrn+" ";
+
+ // filter links to projects, only those that the user has credentials for
+ p = myslice.projects;
+ if(p.length > 0 && $.inArray(val.authority_hrn, p)!=-1){
+ project_row += ""+val.authority_hrn+" ";
+ }else{
+ project_row += ""+val.authority_hrn+" ";
+ }
project_row += " ";
table_projects.push(project_row);
});
@@ -276,9 +290,52 @@ $(document).ready(function() {
}
});
if(flag == true){
- $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'fed4fire.upmc'},'params':{'pi_users':pi_users}}, function(data) {
+ $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
+ if(data.success){
+ mysliceAlert('Success: User rights added to: {{user_details.parent_authority}}','success', true);
+ }else{
+ mysliceAlert('Rest Error for: '+data.error,'warning', true);
+ //alert("Rest Error for "+record_id+": "+data.error);
+ }
+ });
+ }
+ });
+ });
+});
+//downgrade to user [in projects:remove from project]
+$(document).ready(function() {
+ $('button#removepi').click(function() {
+ var flag = false;
+ var pi_users = [];
+ $.post("/rest/myslice:authority/",{'filters':{'authority_hrn': '{{user_details.parent_authority}}'}}, function( data ) {
+ pi_users = data[0]["pi_users"];
+ // http://stackoverflow.com/questions/9792927/javascript-array-search-and-remove-string
+ $('input:checkbox.user').each(function (index) {
+ if(this.checked){
+ var record_id = this.id;
+ for (var i=pi_users.length-1; i>=0; i--) {
+ if (pi_users[i] === record_id) {
+ pi_users.splice(i, 1);
+ }
+ }
+ flag = true;
+ }
+ });
+ if(flag == true){
+ $.post("/update/myslice:authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'},'params':{'pi_users':pi_users}}, function(data) {
if(data.success){
- mysliceAlert('Success: slice renewed','success', true);
+ mysliceAlert('Success: User rights removed from: {{user_details.parent_authority}}','success', true);
+ {% if project %}
+ // remove the user from the list of pis of the project displayed
+ $('input:checkbox.user').each(function (index) {
+ if(this.checked){
+ var record_id = this.id;
+ $('tr[id="'+record_id+'"]').fadeOut("slow");
+ $('tr[id="'+record_id+'"]').remove();
+ }
+
+ });
+ {% endif %}
}else{
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
@@ -288,5 +345,8 @@ $(document).ready(function() {
});
});
});
+
+
+
{% endblock %}