dashboard: fixed javascript error if no slice
[myslice.git] / portal / templates / onelab / onelab_home-view.html
index 4915b9e..090f66b 100644 (file)
@@ -35,7 +35,7 @@
                                </td>
                                <td>
                                {% if person %}
-                                       <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
+                                       <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
                                        <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
                                {% else %}
                                {% endif %}
@@ -73,7 +73,7 @@
                                </td>
                                <td>
                                        {% if person %}
-                                   <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Slice</button>
+                                   <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Slice</button>
                                        {% endif %}
                                </td>
                                <td class="support">
                {% if person %}
         $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
                  var items = [];
-                 $.each( data[0].slices, function(i, val) {
-                       items.push( "<li><a href=\"/slice/"+val+"\">" + val + "</a></li>" );
-                 });
-                 
-                 $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
-                 
+          if(data.length > 0){
+                   $.each( data[0].slices, function(i, val) {
+                           items.push( "<li><a href=\"/slice/"+val+"\">" + val + "</a></li>" );
+                   });
+                   $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
+                 }else{
+                   $("div#home-slice-list").html("no slice");
+          }
                });
                {% endif %}
        });