1 $(document).ready(function() {
4 $('.nav-tabs a').click(function (e) {
7 id = $(this).attr('href').substr(1);
8 if (!(id in loadedTabs)) {
12 loadedTabs[id] = true;
19 $('button#deleteusers').click(function() {
20 $('input:checkbox.user').each(function (index) {
22 var record_id = this.id;
23 var user_email = this.dataset.email;
25 // Delete in SFA Registry
26 $.post("/delete/user/",{'filters':{'user_hrn':record_id}}, function(data) {
28 $.post("/local_user/delete/",{'email':user_email}, function(data) {
31 mysliceAlert('Success: user deleted','success', true);
33 mysliceAlert('Local DB Error for: '+record_id,'warning', true);
35 $('tr[id="'+record_id+'"]').fadeOut("slow");
36 $('tr[id="'+record_id+'"]').remove();
38 //$.post("/delete/local:user/",{'filters':{'user_hrn':this.id}}, function(data) {
40 mysliceAlert('Rest Error for: '+data.error,'warning', true);
41 //alert("Rest Error for "+record_id+": "+data.error);
48 /* TODO: factorize into functions */
49 $('button#deleteslices').click(function() {
51 $('input:checkbox.slice').each(function (index) {
53 var record_id = this.id;
54 $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
57 $('tr[id="'+record_id+'"]').fadeOut("slow");
58 $('tr[id="'+record_id+'"]').remove();
59 mysliceAlert('Success: slice deleted','success', true);
61 mysliceAlert('Rest Error for: '+data.error,'warning', true);
62 //alert("Rest Error for "+record_id+": "+data.error);
68 $('button#renewslices').click(function() {
70 /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
71 var month = now.getMonth()+2;
72 var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
73 $('input:checkbox.slice').each(function (index) {
75 var record_id = this.id;
76 $.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
78 // TODO: highlight row after success
79 //$('tr[id="'+record_id+'"]').highlight();
80 mysliceAlert('Success: slice renewed','success', true);
82 mysliceAlert('Rest Error for: '+data.error,'warning', true);
83 //alert("Rest Error for "+record_id+": "+data.error);
89 // TODO: refresh table
90 //window.location="/portal/institution#slices";
92 $('button#deleteprojects').click(function() {
94 $('input:checkbox.project').each(function (index) {
96 var record_id = this.id;
97 console.log(record_id);
98 $.post("/delete/myslice:authority/",{'filters':{'authority_hrn':this.id}}, function(data) {
100 localStorage.clear();
101 $('tr[id="'+record_id+'"]').fadeOut("slow");
102 $('tr[id="'+record_id+'"]').remove();
103 mysliceAlert('Success: project deleted','success', true);
105 mysliceAlert('Rest Error for: '+data.error,'warning', true);
106 //alert("Rest Error for "+record_id+": "+data.error);
113 $('button#createslice').click(function() {
114 window.location="/portal/slice_request/";
117 $('button#createproject').click(function() {
118 window.location="/portal/project_request/";
120 $('button#slicerequestbtn').click(function() {
122 window.location="/portal/slice_request/";
127 /*function loadUsers() {
128 $('div#users table').load('/table/user/',
130 'fields' : [ 'user_hrn', 'user_first_name', 'user_last_name', 'user_email', 'user_phone' ],
131 'filters' : { 'parent_authority' : $('div#users').data('authority') },
132 'options' : [ 'checkbox' ]