make nagios default to (select a controller)
[plstackapi.git] / planetstack / core / dashboard / views / home.py
index ac52b0b..3084c0e 100644 (file)
@@ -27,7 +27,7 @@ class DashboardDynamicView(TemplateView):
 
         if name=="root":
             return self.multiDashboardView(request, context)
-        elif request.GET.get("wholePage",None):
+        elif kwargs.get("wholePage",None):
             return self.singleFullView(request, name, context)
         else:
             return self.singleDashboardView(request, name, context)
@@ -75,14 +75,46 @@ class DashboardDynamicView(TemplateView):
             dashboards.append(customize[0])
 
         for i,view in enumerate(dashboards):
+            # don't display disabled dashboards
+            if (not view.enabled):
+                continue
             body = body + '<li><a href="#dashtab-%d">%s</a></li>\n' % (i, view.name)
 
         body = body + "</ul>\n"
 
         for i,view in enumerate(dashboards):
+            # don't display disabled dashboards
+            if (not view.enabled):
+                continue
+
             url = view.url
             body = body + '<div id="dashtab-%d">\n' % i
-            body = body + self.embedDashboard(url)
+            if (view.controllers.all().count()>0):
+                body = body + 'Controller: <select id="dashselect-%d">' % i;
+                body = body + '<option value="None">(select a controller)</option>';
+                for j,controllerdashboard in enumerate(view.controllerdashboardviews.all()):
+                    body = body + '<option value="%d">%s</option>' % (j, controllerdashboard.controller.name)
+                body = body + '</select><hr>'
+
+                for j,controllerdashboard in enumerate(view.controllerdashboardviews.all()):
+                    body = body + '<script type="text/template" id="dashtemplate-%d-%d">\n%s\n</script>\n' % (i,j, self.embedDashboard(controllerdashboard.url));
+
+                body = body + '<div id="dashcontent-%d" class="dashcontent"></div>\n' % i
+
+                body = body + """<script>
+                                 $("#dashselect-%d").change(function() {
+                                     v=$("#dashselect-%d").val();
+                                     if (v=="None") {
+                                         $("#dashcontent-%d").html("");
+                                         return;
+                                     }
+                                     $("#dashcontent-%d").html( $("#dashtemplate-%d-" + v).html() );
+                                 });
+                                 //$("#dashcontent-%d").html( $("#dashtemplate-%d-0").html() );
+                                 </script>
+                              """ % (i,i,i,i,i,i,i);
+            else:
+                body = body + self.embedDashboard(url)
             body = body + '</div>\n'
 
         body=body+"</div>\n"