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 /* TODO: factorize into functions */
20 $('button#deleteusers').click(function() {
21 $('input:checkbox.user').each(function (index) {
23 var record_id = this.id;
24 $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) {
26 $('tr[id="'+record_id+'"]').fadeOut("slow");
27 $('tr[id="'+record_id+'"]').remove();
29 alert("Rest Error for "+record_id+": "+data.error);
36 $('button#deleteslices').click(function() {
37 $('input:checkbox.slice').each(function (index) {
39 var record_id = this.id;
40 $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
42 $('tr[id="'+record_id+'"]').fadeOut("slow");
43 $('tr[id="'+record_id+'"]').remove();
45 alert("Rest Error for "+record_id+": "+data.error);
52 $('button#renewslices').click(function() {
54 /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
55 var month = now.getMonth()+2;
56 var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
57 console.log(one_month_later);
58 $('input:checkbox.slice').each(function (index) {
60 var record_id = this.id;
61 $.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
63 // TODO: highlight row after success
64 //$('tr[id="'+record_id+'"]').highlight();
66 alert("Rest Error for "+record_id+": "+data.error);
72 // TODO: refresh table
73 //window.location="/portal/institution#slices";
76 $('button#createslice').click(function() {
77 window.location="/portal/slice_request/";
79 $('button#slicerequestbtn').click(function() {
81 window.location="/portal/slice_request/";
86 function loadUsers() {
87 $('div#users table').load('/table/user/',
89 'fields' : [ 'user_hrn', 'user_first_name', 'user_last_name', 'user_email', 'user_phone' ],
90 'filters' : { 'parent_authority' : $('div#users').data('authority') },
91 'options' : [ 'checkbox' ]