From: Loic Baron Date: Mon, 10 Mar 2014 17:27:42 +0000 (+0100) Subject: Rest actions using myslice.js - wip X-Git-Tag: myslice-1.1~208^2~4 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=eedc5fc666af9dfaa82660ba4da7107304188179;p=unfold.git Rest actions using myslice.js - wip --- diff --git a/portal/static/js/myslice.js b/portal/static/js/myslice.js index a67e3146..bf640168 100644 --- a/portal/static/js/myslice.js +++ b/portal/static/js/myslice.js @@ -44,38 +44,38 @@ var myslice = { }, apply: function() { - $('div#loading').show(); - this.pending = []; - this.save(); - setTimeout(function(){ - $('div#loading').hide(); - window.location.href = '/resources/' + this.slice + '?message=true'; - },6000); + //$('div#loading').show(); + //this.pending = []; + //this.save(); + //setTimeout(function(){ + //$('div#loading').hide(); + //window.location.href = '/resources/' + this.slice + '?message=true'; + //},6000); - // $.post("/rest/slice/", { 'fields': ['resource','slice_hrn'], 'filters': { 'slice_hrn' : this.slice } }, function(data) { - // console.log(data); - // resources = []; - // reserved = []; - // update = []; - // if ('resource' in data[0]) { - // $.each(data[0].resource, function(idx, r) { - // resources.push(r.urn); - // }); - // } - // //myslice.pending - // console.log(myslice.pending); - // console.log(resources); - // $.each(resources.concat(myslice.pending), function(idx, v) { - // update.push({ 'resource': v }); - // }); - // console.log(update); - // $.post("/update/slice/", { 'filters': { 'slice_hrn' : myslice.slice }, 'params' : update }, function(data) { - // console.log(data); - // }); - // }); - //console.log(this.slice); + $.post("/rest/slice/", { 'fields': ['resource','slice_hrn'], 'filters': { 'slice_hrn' : this.slice } }, function(data) { + console.log(data); + resources = []; + reserved = []; + update = []; + if ('resource' in data[0]) { + $.each(data[0].resource, function(idx, r) { + resources.push(r.urn); + }); + } + //myslice.pending + console.log(myslice.pending); + console.log(resources); + $.each(resources.concat(myslice.pending), function(idx, v) { + update.push( v ); + }); + console.log(update); + $.post("/update/slice/", { 'filters': { 'slice_hrn' : myslice.slice }, 'params' : update }, function(data) { + console.log(data); + }); + }); + console.log(this.slice); } };