From: Scott Baker <smbaker@gmail.com> Date: Sat, 20 Dec 2014 01:15:59 +0000 (-0800) Subject: per-controller view display X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=17ea69b28c8263ec174cbb8b9adbab57d17742b2;p=plstackapi.git per-controller view display --- diff --git a/planetstack/core/dashboard/views/home.py b/planetstack/core/dashboard/views/home.py index 974e3af..c0acfdf 100644 --- a/planetstack/core/dashboard/views/home.py +++ b/planetstack/core/dashboard/views/home.py @@ -82,7 +82,29 @@ class DashboardDynamicView(TemplateView): for i,view in enumerate(dashboards): url = view.url body = body + '<div id="dashtab-%d">\n' % i - body = body + self.embedDashboard(url) + if (view.controllers.all().count()>0): + body = body + '<select id="dashselect-%d">' % i; + for j,controllerdashboard in enumerate(view.controllerdashboards.all()): + body = body + '<option value="%d">%s</option>' % (j, controllerdashboard.controller.name) + body = body + '</select>' + + for j,controllerdashboard in enumerate(view.controllerdashboards.all()): + body = body + '<div id="dashcontent-%d-%d" class="dashcontent-%d">\n' % (i,j,i) + body = body + self.embedDashboard(controllerdashboard.url); + body = body + '</div>\n'; + + body = body + """<script> + $("#dashselect-%d").change(function() { console.log("change!"); + v=$("#dashselect-%d").val(); + $(".dashcontent-%d").hide(); + $("#dashcontent-%d-" + v).show(); + }); + $(".dashcontent-%d").hide(); + $("#dashcontent-%d-0").show(); + </script> + """ % (i,i,i,i,i,i); + else: + body = body + self.embedDashboard(url) body = body + '</div>\n' body=body+"</div>\n"