Institution: Renew Slice working, refresh missing
authorJordan Augé <jordan.auge@lip6.fr>
Tue, 4 Mar 2014 17:54:20 +0000 (18:54 +0100)
committerJordan Augé <jordan.auge@lip6.fr>
Tue, 4 Mar 2014 17:54:20 +0000 (18:54 +0100)
portal/static/js/institution.js

index 17858fe..dc44870 100644 (file)
@@ -51,6 +51,29 @@ $(document).ready(function() {
             }
         });
     });
+    $('button#renewslices').click(function() {
+        var now = new Date();
+        /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on...  */
+        var month = now.getMonth()+2;
+        var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
+        console.log(one_month_later);
+        $('input:checkbox.slice').each(function (index) {
+            if(this.checked){
+                var record_id = this.id;
+                $.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();
+                    }else{
+                        alert("Rest Error for "+record_id+": "+data.error);
+                    }
+                });
+                
+            }
+        });
+        // TODO: refresh table
+        //window.location="/portal/institution#slices";
+    });
 
     $('button#createslice').click(function() {
         window.location="/portal/slice_request/";