X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=portal%2Fstatic%2Fjs%2Finstitution.js;h=a48a9a4b0e07d7a73241ffe57f069aba8ba98e73;hb=c457730e8d49ee507846edeb8a474374f0122f25;hp=173021f904936e6068a8f2757c5fd7b1849a3b7e;hpb=f7750e08d78ebb75b222baf901853370cd7ffff5;p=unfold.git diff --git a/portal/static/js/institution.js b/portal/static/js/institution.js index 173021f9..a48a9a4b 100644 --- a/portal/static/js/institution.js +++ b/portal/static/js/institution.js @@ -20,27 +20,40 @@ $(document).ready(function() { $('input:checkbox.user').each(function (index) { if(this.checked){ var record_id = this.id; - $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) { + var user_email = this.dataset.email; + console.log(this); + // Delete in SFA Registry + $.post("/delete/user/",{'filters':{'user_hrn':record_id}}, function(data) { if(data.success){ - $('tr[id="'+record_id+'"]').fadeOut("slow"); - $('tr[id="'+record_id+'"]').remove(); - mysliceAlert('Success: user deleted','success', true); + $.post("/local_user/delete/",{'filters':{'email':user_email}}, function(data) { + console.log(data); + if (data == true){ + mysliceAlert('Success: user deleted','success', true); + }else{ + mysliceAlert('Local DB Error for: '+record_id,'warning', true); + } + $('tr[id="'+record_id+'"]').fadeOut("slow"); + $('tr[id="'+record_id+'"]').remove(); + }); + //$.post("/delete/local:user/",{'filters':{'user_hrn':this.id}}, function(data) { }else{ mysliceAlert('Rest Error for: '+data.error,'warning', true); //alert("Rest Error for "+record_id+": "+data.error); } - }); + }); } }); }); /* TODO: factorize into functions */ $('button#deleteslices').click(function() { + var flag = false; $('input:checkbox.slice').each(function (index) { if(this.checked){ var record_id = this.id; $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) { if(data.success){ + localStorage.clear(); $('tr[id="'+record_id+'"]').fadeOut("slow"); $('tr[id="'+record_id+'"]').remove(); mysliceAlert('Success: slice deleted','success', true); @@ -57,7 +70,6 @@ $(document).ready(function() { /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */ var month = now.getMonth()+2; var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds(); - console.log(one_month_later); $('input:checkbox.slice').each(function (index) { if(this.checked){ var record_id = this.id; @@ -77,10 +89,34 @@ $(document).ready(function() { // TODO: refresh table //window.location="/portal/institution#slices"; }); + $('button#deleteprojects').click(function() { + var flag = false; + $('input:checkbox.project').each(function (index) { + if(this.checked){ + var record_id = this.id; + console.log(record_id); + $.post("/delete/myslice:authority/",{'filters':{'authority_hrn':this.id}}, function(data) { + if(data.success){ + localStorage.clear(); + $('tr[id="'+record_id+'"]').fadeOut("slow"); + $('tr[id="'+record_id+'"]').remove(); + mysliceAlert('Success: project deleted','success', true); + }else{ + mysliceAlert('Rest Error for: '+data.error,'warning', true); + //alert("Rest Error for "+record_id+": "+data.error); + } + }); + } + }); + }); $('button#createslice').click(function() { window.location="/portal/slice_request/"; }); + + $('button#createproject').click(function() { + window.location="/portal/project_request/"; + }); $('button#slicerequestbtn').click(function() { /* window.location="/portal/slice_request/";