From 44b2a292eb1e467b07b2941246ab8e0e153dffd3 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 23 Jun 2016 16:49:36 +0900 Subject: [PATCH 1/2] notify dashboard migration fail --- public/app/features/dashboard/dashboard_ctrl.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/dashboard_ctrl.ts b/public/app/features/dashboard/dashboard_ctrl.ts index 18e8893a507..a1fd877e980 100644 --- a/public/app/features/dashboard/dashboard_ctrl.ts +++ b/public/app/features/dashboard/dashboard_ctrl.ts @@ -21,6 +21,7 @@ export class DashboardCtrl { dynamicDashboardSrv, dashboardViewStateSrv, contextSrv, + alertSrv, $timeout) { $scope.editor = { index: 0 }; @@ -29,11 +30,15 @@ export class DashboardCtrl { var resizeEventTimeout; $scope.setupDashboard = function(data) { - var dashboard = dashboardSrv.create(data.dashboard, data.meta); - dashboardSrv.setCurrent(dashboard); + try { + var dashboard = dashboardSrv.create(data.dashboard, data.meta); + dashboardSrv.setCurrent(dashboard); - // init services - timeSrv.init(dashboard); + // init services + timeSrv.init(dashboard); + } catch (err) { + $scope.appEvent("alert-error", ['Dashboard init failed', err.message]); + } // template values service needs to initialize completely before // the rest of the dashboard can load From 6ef27a87e4bcbb3349e51a2c6c35f42385281e7a Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 23 Jun 2016 17:13:12 +0900 Subject: [PATCH 2/2] fix catch clause --- .../app/features/dashboard/dashboard_ctrl.ts | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/public/app/features/dashboard/dashboard_ctrl.ts b/public/app/features/dashboard/dashboard_ctrl.ts index a1fd877e980..6340c29724f 100644 --- a/public/app/features/dashboard/dashboard_ctrl.ts +++ b/public/app/features/dashboard/dashboard_ctrl.ts @@ -36,31 +36,31 @@ export class DashboardCtrl { // init services timeSrv.init(dashboard); + + // template values service needs to initialize completely before + // the rest of the dashboard can load + templateValuesSrv.init(dashboard).finally(function() { + dynamicDashboardSrv.init(dashboard); + + unsavedChangesSrv.init(dashboard, $scope); + + $scope.dashboard = dashboard; + $scope.dashboardMeta = dashboard.meta; + $scope.dashboardViewState = dashboardViewStateSrv.create($scope); + + dashboardKeybindings.shortcuts($scope); + + $scope.updateSubmenuVisibility(); + $scope.setWindowTitleAndTheme(); + + $scope.appEvent("dashboard-initialized", $scope.dashboard); + }).catch(function(err) { + if (err.data && err.data.message) { err.message = err.data.message; } + $scope.appEvent("alert-error", ['Dashboard init failed', 'Template variables could not be initialized: ' + err.message]); + }); } catch (err) { $scope.appEvent("alert-error", ['Dashboard init failed', err.message]); } - - // template values service needs to initialize completely before - // the rest of the dashboard can load - templateValuesSrv.init(dashboard).finally(function() { - dynamicDashboardSrv.init(dashboard); - - unsavedChangesSrv.init(dashboard, $scope); - - $scope.dashboard = dashboard; - $scope.dashboardMeta = dashboard.meta; - $scope.dashboardViewState = dashboardViewStateSrv.create($scope); - - dashboardKeybindings.shortcuts($scope); - - $scope.updateSubmenuVisibility(); - $scope.setWindowTitleAndTheme(); - - $scope.appEvent("dashboard-initialized", $scope.dashboard); - }).catch(function(err) { - if (err.data && err.data.message) { err.message = err.data.message; } - $scope.appEvent("alert-error", ['Dashboard init failed', 'Template variables could not be initialized: ' + err.message]); - }); }; $scope.templateVariableUpdated = function() {