Commit 4fbe954a by utkarshcmu

Home dashboard per user per org works

parent 66621d76
...@@ -162,7 +162,7 @@ func Register(r *macaron.Macaron) { ...@@ -162,7 +162,7 @@ func Register(r *macaron.Macaron) {
// Preferences // Preferences
r.Group("/preferences", func() { r.Group("/preferences", func() {
r.Get("/", wrap(GetPreferences)) r.Get("/", GetPreferences)
r.Put("/", bind(m.SavePreferencesCommand{}), wrap(SavePreferences)) r.Put("/", bind(m.SavePreferencesCommand{}), wrap(SavePreferences))
r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard)) r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard))
}) })
......
...@@ -7,11 +7,25 @@ function (coreModule) { ...@@ -7,11 +7,25 @@ function (coreModule) {
coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv) { coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv) {
if (!$routeParams.slug) { if (!$routeParams.slug) {
backendSrv.get('/api/dashboards/home').then(function(result) {
var meta = result.meta; backendSrv.get('/api/preferences').then(function(preferences) {
meta.canSave = meta.canShare = meta.canStar = false; if (preferences !== null && preferences.homeDashboardId !== 0) {
$scope.initDashboard(result, $scope); backendSrv.get('/api/dashboards/id/' + preferences.homeDashboardId).then(function(dashSlug) {
$routeParams.type = 'db';
$routeParams.slug = dashSlug.slug;
dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
$scope.initDashboard(result, $scope);
});
});
} else {
backendSrv.get('/api/dashboards/home').then(function(result) {
var meta = result.meta;
meta.canSave = meta.canShare = meta.canStar = false;
$scope.initDashboard(result, $scope);
});
}
}); });
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment