X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fstatic%2Fjs%2Fmyslice.js;h=bf6401687737bec5964de2bfb2015411b089891c;hb=eedc5fc666af9dfaa82660ba4da7107304188179;hp=e1a6de179fc391033aeb2825156e079c45fd0892;hpb=fecbbac04ddd2f55989661f4666dcabae647dc50;p=unfold.git diff --git a/portal/static/js/myslice.js b/portal/static/js/myslice.js index e1a6de17..bf640168 100644 --- a/portal/static/js/myslice.js +++ b/portal/static/js/myslice.js @@ -3,7 +3,9 @@ */ var myslice = { + slice: null, pending: [], + reserved: [], add: function(resource) { if (!this.has(resource)) { @@ -39,6 +41,41 @@ var myslice = { if (!this.pending) { this.pending = []; } + }, + + apply: function() { + //$('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( v ); + }); + console.log(update); + $.post("/update/slice/", { 'filters': { 'slice_hrn' : myslice.slice }, 'params' : update }, function(data) { + console.log(data); + }); + }); + console.log(this.slice); } };