X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fstatic%2Fjs%2Fmyslice.js;h=85c7ac8b0e9e480954fa5093b28ea4b429c1a1e8;hb=1cf51eaae7a6b154305847af2edbe55cbdfaa062;hp=0807d4950ac5cb0fa0722d79b854258040eeb27e;hpb=c4fc97ad3d1638026464196b113229376d35656f;p=unfold.git diff --git a/portal/static/js/myslice.js b/portal/static/js/myslice.js index 0807d495..85c7ac8b 100644 --- a/portal/static/js/myslice.js +++ b/portal/static/js/myslice.js @@ -106,18 +106,52 @@ var myslice = { user: function() { if ($.isEmptyObject(this.user)) { //this.login(function() { return this.user; }); - this.user = localStorage.getItem('user'); + if(localStorage.getItem('user')!='undefined'){ + this.user = JSON.parse(localStorage.getItem('user')); + }else{ + return false; + } } return this.user; }, + loadSlices: function(slices) { + if (typeof(slices) == "undefined"){ + + if(myslice.user != null && typeof(myslice.user.slices) != "undefined" && myslice.user.slices.length>0){ + slices == myslice.user.slices + } + } + // myslice.user is in LocalStorage + if(typeof(slices) != "undefined"){ + /* + Launch queries to get the resources and leases in Manifold Cache + */ + $.post("/rest/resource/", function( data ) { + }); + $.post("/rest/lease/", function( data ) { + }); + + $.each( slices, function(i, val) { + /* + Launch a Query for each slice to get resources and leases in Manifold Cache + */ + $.post("/rest/slice/", { 'filters': { 'slice_hrn' : val } }, function(data) { + }); + }); + } + }, login: function(fn) { - $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) { - myslice.user = new user(data[0]); - localStorage.setItem('user', JSON.stringify(myslice.user)); - }); + user = localStorage.getItem('user'); + if($.isEmptyObject(user)){ + // REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2 + $.post("/rest/myslice:user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) { + //myslice.user = new user(data[0]); + localStorage.setItem('user', JSON.stringify(data[0])); + myslice.loadSlices(data[0].slices); + }); + } }, - getSlices: function(name) { },