+function unspin_all(){
+ $('input:checkbox').each(function (index) {
+ if(this.checked){
+ this.nextElementSibling.style.display = "none";
+ }
+ });
+}
+function spin_all(){
+ $('input:checkbox').each(function (index) {
+ if(this.checked){
+ this.nextElementSibling.style.display = "inline";
+ }
+ });
+}
$(document).ready(function() {
loadedTabs = [];
});
$('button#deleteusers').click(function() {
+ spin_all();
$('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/",{'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);
}
- });
+ unspin_all();
+ });
}
});
});
/* TODO: factorize into functions */
$('button#deleteslices').click(function() {
+ spin_all();
var flag = false;
$('input:checkbox.slice').each(function (index) {
if(this.checked){
var record_id = this.id;
+ $('#'+record_id+'-loading').spin();
$.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
if(data.success){
localStorage.clear();
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
});
});
$('button#renewslices').click(function() {
+ spin_all();
var now = new Date();
/* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
var month = now.getMonth()+2;
$('input:checkbox.slice').each(function (index) {
if(this.checked){
var record_id = this.id;
+ $('#'+record_id+'-loading').spin();
$.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
if(data.success){
// TODO: highlight row after success
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
//window.location="/portal/institution#slices";
});
$('button#deleteprojects').click(function() {
+ spin_all();
var flag = false;
$('input:checkbox.project').each(function (index) {
if(this.checked){
var record_id = this.id;
+ $('#'+record_id+'-loading').spin();
console.log(record_id);
$.post("/delete/myslice:authority/",{'filters':{'authority_hrn':this.id}}, function(data) {
if(data.success){
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
});