1 $(document).ready(function() {
2 $('li#nav-institution').addClass("active");
4 $('a.home-tab').click(function() {
5 $('ul.nav-tabs li').removeClass('active');
6 $(this).parent().addClass('active');
7 $('div.home-panel').hide();
8 $('div#'+$(this).data('panel')).show();
10 var url = window.location;
13 tab = url.href.split("#")[1];
14 tab_exists = $('div#'+tab).length;
16 $('ul.nav-tabs li').removeClass('active');
17 $('li#'+tab+'-tab').addClass('active');
18 $('div.home-panel').hide();
23 /* TODO: factorize into functions */
24 $('button#deleteusers').click(function() {
25 $('input:checkbox.user').each(function (index) {
27 var record_id = this.id;
28 $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) {
30 $('tr[id="'+record_id+'"]').fadeOut("slow");
31 $('tr[id="'+record_id+'"]').remove();
33 alert("Rest Error for "+record_id+": "+data.error);
40 $('button#deleteslices').click(function() {
41 $('input:checkbox.slice').each(function (index) {
43 var record_id = this.id;
44 $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
46 $('tr[id="'+record_id+'"]').fadeOut("slow");
47 $('tr[id="'+record_id+'"]').remove();
49 alert("Rest Error for "+record_id+": "+data.error);
56 $('button#renewslices').click(function() {
58 /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
59 var month = now.getMonth()+2;
60 var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
61 console.log(one_month_later);
62 $('input:checkbox.slice').each(function (index) {
64 var record_id = this.id;
65 $.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
67 // TODO: highlight row after success
68 //$('tr[id="'+record_id+'"]').highlight();
70 alert("Rest Error for "+record_id+": "+data.error);
76 // TODO: refresh table
77 //window.location="/portal/institution#slices";
80 $('button#createslice').click(function() {
81 window.location="/portal/slice_request/";
83 $('button#slicerequestbtn').click(function() {
85 window.location="/portal/slice_request/";