2 $('input:checkbox').each(function (index) {
4 this.nextElementSibling.style.display = "none";
9 $('input:checkbox').each(function (index) {
11 this.nextElementSibling.style.display = "inline";
15 $(document).ready(function() {
18 $('.nav-tabs a').click(function (e) {
21 id = $(this).attr('href').substr(1);
22 if (!(id in loadedTabs)) {
26 loadedTabs[id] = true;
33 $('button#deleteusers').click(function() {
35 $('input:checkbox.user').each(function (index) {
37 var record_id = this.id;
38 var user_email = this.dataset.email;
40 // Delete in SFA Registry
41 $.post("/delete/user/",{'filters':{'user_hrn':record_id}}, function(data) {
43 $.post("/local_user/delete/",{'email':user_email}, function(data) {
46 mysliceAlert('Success: user deleted','success', true);
48 mysliceAlert('Local DB Error for: '+record_id,'warning', true);
50 $('tr[id="'+record_id+'"]').fadeOut("slow");
51 $('tr[id="'+record_id+'"]').remove();
53 //$.post("/delete/local:user/",{'filters':{'user_hrn':this.id}}, function(data) {
55 mysliceAlert('Rest Error for: '+data.error,'warning', true);
56 //alert("Rest Error for "+record_id+": "+data.error);
64 /* TODO: factorize into functions */
65 $('button#deleteslices').click(function() {
68 $('input:checkbox.slice').each(function (index) {
70 var record_id = this.id;
71 $('#'+record_id+'-loading').spin();
72 $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
75 $('tr[id="'+record_id+'"]').fadeOut("slow");
76 $('tr[id="'+record_id+'"]').remove();
77 mysliceAlert('Success: slice deleted','success', true);
79 mysliceAlert('Rest Error for: '+data.error,'warning', true);
80 //alert("Rest Error for "+record_id+": "+data.error);
87 $('button#renewslices').click(function() {
90 /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
91 var month = now.getMonth()+2;
92 var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
93 $('input:checkbox.slice').each(function (index) {
95 var record_id = this.id;
96 $('#'+record_id+'-loading').spin();
97 $.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
99 // TODO: highlight row after success
100 //$('tr[id="'+record_id+'"]').highlight();
101 mysliceAlert('Success: slice renewed','success', true);
103 mysliceAlert('Rest Error for: '+data.error,'warning', true);
104 //alert("Rest Error for "+record_id+": "+data.error);
111 // TODO: refresh table
112 //window.location="/portal/institution#slices";
114 $('button#deleteprojects').click(function() {
117 $('input:checkbox.project').each(function (index) {
119 var record_id = this.id;
120 $('#'+record_id+'-loading').spin();
121 console.log(record_id);
122 $.post("/delete/myslice:authority/",{'filters':{'authority_hrn':this.id}}, function(data) {
124 localStorage.clear();
125 $('tr[id="'+record_id+'"]').fadeOut("slow");
126 $('tr[id="'+record_id+'"]').remove();
127 mysliceAlert('Success: project deleted','success', true);
129 mysliceAlert('Rest Error for: '+data.error,'warning', true);
130 //alert("Rest Error for "+record_id+": "+data.error);
138 $('button#createslice').click(function() {
139 window.location="/portal/slice_request/";
142 $('button#createproject').click(function() {
143 window.location="/portal/project_request/";
145 $('button#slicerequestbtn').click(function() {
147 window.location="/portal/slice_request/";
152 /*function loadUsers() {
153 $('div#users table').load('/table/user/',
155 'fields' : [ 'user_hrn', 'user_first_name', 'user_last_name', 'user_email', 'user_phone' ],
156 'filters' : { 'parent_authority' : $('div#users').data('authority') },
157 'options' : [ 'checkbox' ]