Dashboard: added icon and info tooltip to list of slices and projects
[unfold.git] / portal / templates / base.html
index aed282c..4760849 100644 (file)
@@ -21,7 +21,7 @@
 <script src="{{ STATIC_URL }}js/jquery.dataTables.min.js"></script>
 <script src="{{ STATIC_URL }}js/jquery.qtip.min.js"></script>
 <script src="{{ STATIC_URL }}js/bootstrap.datatables.js"></script>
-<!-- <script src="{{ STATIC_URL }}js/stash.min.js"></script> -->
+<script src="{{ STATIC_URL }}js/common.functions.js"></script>
 <script src="{{ STATIC_URL }}js/myslice.js"></script>
 <script src="{{ STATIC_URL }}js/myslice-ui.js"></script>
 
@@ -66,7 +66,7 @@ This list of slices should go into SESSION !
 $(document).ready(function() {
 {% if username %}
     myslice.login(function(){
-        user = myslice.user();
+        user = myslice.get_user();
 
         var slices = [];
         if($.isEmptyObject(user)){
@@ -76,12 +76,15 @@ $(document).ready(function() {
             slices.push("no slice");
         }else{
             slices = user.slices;
+            {% if theme != "fed4fire" or  "onelab" in theme %}
             drawSlices(slices);
+            {% endif %}
         }
-        {% if theme == "fed4fire" %}
-        p = myslice.projects();
+        {% if theme == "fed4fire" or "onelab" in theme%}
+        p = myslice.get_projects();
         if(p != null){
-            drawProjects(p);
+            //drawProjects(p);
+            drawProjectsTree(p,slices);
         }
         {% endif %}
     });
@@ -90,22 +93,49 @@ $(document).ready(function() {
         var items = [];
                
         $.each( slices, function(i, val) {
-            items.push( "<li><a href=\"/resources/"+val+"\">" + val + "</a></li>" );
+            items.push( "<li><a href=\"/resources/"+val+"\" title='Add resources to slice "+val+"'><img src='/static/img/icon_slices_small.png' style='width: 12px;'>" + val + "</a></li>" );
         });
         $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
         $("ul#dropdown-slice-list").append(items.join( "" ));
     }
     
-    {% if theme == "fed4fire" %}
+    {% if theme == "fed4fire" or "onelab" in theme%}
     function drawProjects(projects){
         var items = [];
                
         $.each( projects, function(i, val) {
-            items.push( "<li><a href=\"/portal/project/"+val+"\">" + val + "</a></li>" );
+            items.push( "<li><a href=\"/portal/project/"+val+"\" title='Manage project "+val+"'>" + val + "</a></li>" );
         });
         $("div#home-project-list").html($( "<ul/>", { html: items.join( "" ) }));
         $("ul#dropdown-project-list").append(items.join( "" ));
     }
+    function drawProjectsTree(projects,slices) {
+        var items = [];
+        var items_sl = [];
+        $.each( projects, function(i, p) {
+            $.each( slices, function(y, s) {
+                if (s.match('^' + escapeRegExp(p))) {
+                     slicename = s.replace(p + '.','')
+                     items_sl.push( "<li><a href=\"/resources/" + s + "\" title='Add resources to slice "+slicename+"'><img src='/static/img/icon_slices_small.png' style='width: 12px;'>  " + slicename + "</a></li>" );
+                }
+            });
+            el = "<li><a href=\"/portal/project/" + p + "\" title='Manage project "+p+"' >" + p + "</a>";
+            if (items_sl.length > 0) {
+                el += "<ul>" + items_sl.join( "" ) + "</ul>";
+            }
+            el += "</li>";
+            items.push(el);
+            items_sl = [];
+        });
+        $("div#home-project-tree").html($( "<ul/>", { html: items.join( "" ) }));
+        if (projects.length > 0) {
+            $('.dashboard-create-slice').show();
+        }
+    }
+    
+    window.setTimeout(function() {
+        $('.projects-loading').hide();
+    },20000);
     {% endif %}
 {% endif %}
        jQuery('[title!=""]').qtip();