dashboard: fixed javascript error if no slice
[myslice.git] / portal / templates / onelab / onelab_home-view.html
index 6fd7e1d..090f66b 100644 (file)
@@ -1,4 +1,4 @@
-{% extends "base.html" %}
+{% extends "layout.html" %}
 
 {% block content %}
 <div class="row" id="home-dashboard">
@@ -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 %}
@@ -59,7 +59,7 @@
                        </tr>
                        <tr>
                                <td><a href="/portal/institution"><img src="{{ STATIC_URL }}img/icon_authority_color.png" alt="" /></a></td>
-                               <td><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></td>
+                               <td><a href="/portal/institution#slices"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a></td>
                                <td><a href="/portal/validate"><img src="{{ STATIC_URL }}img/icon_testbed_color.png" alt="" /></a></td>
                        </tr>
                        <tr>
                                {% endif %}
                                </td>
                                <td>
-                                   <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create a Slice</button>
+                                       {% if person %}
+                                   <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 %}
                                    <button id="validaterequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Validate Requests</button>
+                                       {% endif %}
                                </td>
                        </tr>
                </table>
                {% if person %}
         $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
                  var items = [];
-                 $.each( data[0].slice, function( key, val ) {
-                       items.push( "<li><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</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 %}
        });