X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Ftemplates%2Fbase.html;h=decd041ebf251a589393f06cfa5d215e1971a9c4;hb=348934a41a30d1cf44ded1078718d783d130f653;hp=6bb7e232b3f4d729e6afe721abcc9b2221372a99;hpb=c624b017611ae21cda21f28529cd8412dfc12669;p=myslice.git
diff --git a/portal/templates/base.html b/portal/templates/base.html
index 6bb7e232..decd041e 100644
--- a/portal/templates/base.html
+++ b/portal/templates/base.html
@@ -38,30 +38,34 @@ XXX TODO: session
This list of slices should go into SESSION !
*/
$(document).ready(function() {
+ {% if username %}
+ myslice.login();
user = myslice.user();
- if(user.length>0){
- $.each( user.slices, function(i, val) {
- items.push( "
" + val + "" );
+
+ var slices = [];
+ if($.isEmptyObject(user)){
+ $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
+ if(data.length > 0){
+ slices = data[0].slices;
+ }else{
+ slices.push("no slice");
+ }
+ drawSlices(slices);
});
- $("div#home-slice-list").html($( "", { html: items.join( "" ) }));
- $("ul#dropdown-slice-list").append(items.join( "" ));
+ }else{
+ slices = user.slices;
+ drawSlices(slices);
}
- {% if person %}
- $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
- var items = [];
- if(data.length > 0){
- $.each( data[0].slices, function(i, val) {
- items.push( "" + val + "" );
- });
-
- $("div#home-slice-list").html($( "", { html: items.join( "" ) }));
- $("ul#dropdown-slice-list").append(items.join( "" ));
- }else{
- $("div#home-slice-list").html("no slice");
- }
- });
- {% endif %}
+ function drawSlices(slices){
+ var items = [];
+ $.each( slices, function(i, val) {
+ items.push( "" + val + "" );
+ });
+ $("div#home-slice-list").html($( "", { html: items.join( "" ) }));
+ $("ul#dropdown-slice-list").append(items.join( "" ));
+ }
+ {% endif %}
});