diff --git a/resources/frontend_client/app/controllers.js b/resources/frontend_client/app/controllers.js index de54b375c7d9ae50518fe7cff789a98234ad8576..7c60ce9d8f676311fb5040cc97ee56e1e3a3edde 100644 --- a/resources/frontend_client/app/controllers.js +++ b/resources/frontend_client/app/controllers.js @@ -54,13 +54,15 @@ MetabaseControllers.controller('Nav', ['$scope', '$routeParams', '$location', '$ function($scope, $routeParams, $location, $rootScope, AppState, Dashboard) { function refreshDashboards() { - Dashboard.list({ - 'filterMode': 'all' - }, function (dashes) { - $scope.dashboards = dashes; - }, function (error) { - console.log('error getting dahsboards list', error); - }); + if (AppState.model.currentUser) { + Dashboard.list({ + 'filterMode': 'all' + }, function (dashes) { + $scope.dashboards = dashes; + }, function (error) { + console.log('error getting dahsboards list', error); + }); + } } function setNavContext(context) { @@ -111,6 +113,18 @@ MetabaseControllers.controller('Nav', ['$scope', '$routeParams', '$location', '$ refreshDashboards(); }); + $scope.$on("appstate:user", function(event, dashboardId) { + refreshDashboards(); + }); + + $scope.$on("appstate:login", function(event, dashboardId) { + refreshDashboards(); + }); + + $scope.$on("appstate:logout", function(event, dashboardId) { + $scope.dashboards = []; + }); + // always initialize with a fresh listing refreshDashboards();