X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fstatic%2Fjs%2Finstitution.js;h=c952a7a4746a7843c4b2335f899bb4458483a9d3;hb=225a0f7799c43d63e04ec5639f14690bc941b5b2;hp=1545263f8002d807d0299a6f9069070f3e16ca36;hpb=280555f7f9ec076b52cc7925a2dbd3a3368cb495;p=unfold.git diff --git a/portal/static/js/institution.js b/portal/static/js/institution.js index 1545263f..c952a7a4 100644 --- a/portal/static/js/institution.js +++ b/portal/static/js/institution.js @@ -12,6 +12,49 @@ function spin_all(){ } }); } +function post_renew(obj){ + var record_id = obj.id; + $.post("/sfa/Renew/",{'hrn':record_id,'type':'slice'}, function(data) { + txt = ''; + errors = ''; + $.each(data, function (index, val) { + console.log(index, val); + if (index != 'columns' && !('error' in val)){ + if('code' in val && val['code']['geni_code']==0){ + if('output' in val && val['output']!=''){ + txt += index+': '+val['output']+'
'; + } + if('value' in val && val['value']!=''){ + if(typeof val['value'] == 'string' || val['value'] instanceof String){ + txt += index+': '+val['value']+'
'; + }else{ + txt += index+': expiration = '+val['value'][0]['geni_expires']+'
'; + } + } + }else{ + if('output' in val && val['output']!=''){ + errors += index+': '+val['output']+'
'; + } + if('value' in val && val['value']!=''){ + errors += index+': '+val['value']+'
'; + } + } + } + if('error' in val){ + errors += index+': '+val['error_msg']+'
'; + } + }); + console.log(txt); + console.log(record_id); + if(txt != ''){ + mysliceAlert('Success: '+record_id+'
'+txt,'success', false, record_id); + } + if(errors != ''){ + mysliceAlert('Warning: '+record_id+'
'+errors,'warning', false, record_id); + } + unspin_all(); + }); +} $(document).ready(function() { loadedTabs = []; @@ -85,6 +128,7 @@ $(document).ready(function() { }); }); $('button#renewslices').click(function() { + var record_id; spin_all(); var now = new Date(); /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */ @@ -92,20 +136,11 @@ $(document).ready(function() { var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds(); $('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 - //$('tr[id="'+record_id+'"]').highlight(); - mysliceAlert('Success: slice renewed','success', true); - }else{ - mysliceAlert('Rest Error for: '+data.error,'warning', true); - //alert("Rest Error for "+record_id+": "+data.error); - } - unspin_all(); - }); - + console.log(this.id); + record_id = $(this).attr('id'); + $('#'+this.id+'-loading').spin(); + // /sfa/Renew?hrn=onelab.upmc.projectx.slicex&type=slice + post_renew(this); } }); // TODO: refresh table