Merge branch 'master' of git://git.planet-lab.org/plstackapi
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index be75f75..f2679ff 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -1260,14 +1260,22 @@
     def queryset(self, request):
         return User.select_by_user(request.user)
 
+class ControllerDashboardInline(PlStackTabularInline):
+    model = ControllerDashboard
+    extra = 0
+    fields = ["controller", "url"]
+    suit_classes = 'suit-tab suit-tab-controllers'
+
 class DashboardViewAdmin(PlanetStackBaseAdmin):
     fieldsets = [('Dashboard View Details',
                    {'fields': ['backend_status_text', 'name', 'url'],
                     'classes': ['suit-tab suit-tab-general']})
                ]
     readonly_fields = ('backend_status_text', )
+    inlines = [ControllerDashboardInline]
 
-    suit_form_tabs =(('general','Dashboard View Details'),)
+    suit_form_tabs =(('general','Dashboard View Details'),
+                     ('controllers', 'Per-controller Dashboard Details'))
 
 class ServiceResourceInline(PlStackTabularInline):
     model = ServiceResource
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 @@
         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"
diff --git a/planetstack/core/models/__init__.py b/planetstack/core/models/__init__.py
index aa64676..532398d 100644
--- a/planetstack/core/models/__init__.py
+++ b/planetstack/core/models/__init__.py
@@ -6,7 +6,7 @@
 from .tag import Tag
 from .role import Role
 from .site import Site, Deployment, DeploymentRole, DeploymentPrivilege, Controller, ControllerRole, ControllerPrivilege, SiteDeployments, ControllerSiteDeployments
-from .dashboard import DashboardView
+from .dashboard import DashboardView, ControllerDashboard
 from .user import User, UserDashboardView
 from .serviceclass import ServiceClass
 from .site import ControllerManager, ControllerDeletionManager, ControllerLinkManager,ControllerLinkDeletionManager
diff --git a/planetstack/core/models/dashboard.py b/planetstack/core/models/dashboard.py
index aa79f84..f4e9fb1 100644
--- a/planetstack/core/models/dashboard.py
+++ b/planetstack/core/models/dashboard.py
@@ -1,11 +1,23 @@
 import os
 from django.db import models
-from core.models import PlCoreBase
+from core.models import PlCoreBase, Controller
+from core.models.site import ControllerLinkManager, ControllerLinkDeletionManager
 from django.contrib.contenttypes import generic
 
 class DashboardView(PlCoreBase):
     name = models.CharField(max_length=200, unique=True, help_text="Name of the View")
     url = models.CharField(max_length=1024, help_text="URL of Dashboard")
+    controllers = models.ManyToManyField(Controller, blank=True, related_name="dashboards", through='ControllerDashboard')
 
     def __unicode__(self):  return u'%s' % (self.name)
 
+class ControllerDashboard(PlCoreBase):
+    objects = ControllerLinkManager()
+    deleted_objects = ControllerLinkDeletionManager()
+    controller = models.ForeignKey(Controller, related_name='controllerdashboards')
+    dashboardView = models.ForeignKey(DashboardView, related_name='controllerdashboards')
+
+    url = models.CharField(max_length=1024, help_text="URL of Dashboard")
+
+
+