|
@@ -56,10 +56,6 @@ export function initDashboard({
|
|
|
try {
|
|
try {
|
|
|
switch (routeInfo) {
|
|
switch (routeInfo) {
|
|
|
// handle old urls with no uid
|
|
// handle old urls with no uid
|
|
|
- case DashboardRouteInfo.Old: {
|
|
|
|
|
- redirectToNewUrl(urlSlug, dispatch);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
case DashboardRouteInfo.Home: {
|
|
case DashboardRouteInfo.Home: {
|
|
|
// load home dash
|
|
// load home dash
|
|
|
dashDTO = await getBackendSrv().get('/api/dashboards/home');
|
|
dashDTO = await getBackendSrv().get('/api/dashboards/home');
|
|
@@ -78,20 +74,27 @@ export function initDashboard({
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
case DashboardRouteInfo.Normal: {
|
|
case DashboardRouteInfo.Normal: {
|
|
|
|
|
+ // for old db routes we redirect
|
|
|
|
|
+ if (urlType === 'db') {
|
|
|
|
|
+ redirectToNewUrl(urlSlug, dispatch);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const loaderSrv = $injector.get('dashboardLoaderSrv');
|
|
const loaderSrv = $injector.get('dashboardLoaderSrv');
|
|
|
dashDTO = await loaderSrv.loadDashboard(urlType, urlSlug, urlUid);
|
|
dashDTO = await loaderSrv.loadDashboard(urlType, urlSlug, urlUid);
|
|
|
|
|
|
|
|
- // check if the current url is correct (might be old slug)
|
|
|
|
|
- const dashboardUrl = locationUtil.stripBaseFromUrl(dashDTO.meta.url);
|
|
|
|
|
- const currentPath = getState().location.path;
|
|
|
|
|
- console.log('loading dashboard: currentPath', currentPath);
|
|
|
|
|
- console.log('loading dashboard: dashboardUrl', dashboardUrl);
|
|
|
|
|
|
|
+ if (dashDTO.meta.url) {
|
|
|
|
|
+ // check if the current url is correct (might be old slug)
|
|
|
|
|
+ const dashboardUrl = locationUtil.stripBaseFromUrl(dashDTO.meta.url);
|
|
|
|
|
+ const currentPath = getState().location.path;
|
|
|
|
|
|
|
|
- if (dashboardUrl !== currentPath) {
|
|
|
|
|
- // replace url to not create additional history items and then return so that initDashboard below isn't executed multiple times.
|
|
|
|
|
- dispatch(updateLocation({ path: dashboardUrl, partial: true, replace: true }));
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ if (dashboardUrl !== currentPath) {
|
|
|
|
|
+ // replace url to not create additional history items and then return so that initDashboard below isn't executed multiple times.
|
|
|
|
|
+ dispatch(updateLocation({ path: dashboardUrl, partial: true, replace: true }));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
case DashboardRouteInfo.New: {
|
|
case DashboardRouteInfo.New: {
|
|
@@ -129,7 +132,6 @@ export function initDashboard({
|
|
|
const variableSrv: VariableSrv = $injector.get('variableSrv');
|
|
const variableSrv: VariableSrv = $injector.get('variableSrv');
|
|
|
const keybindingSrv: KeybindingSrv = $injector.get('keybindingSrv');
|
|
const keybindingSrv: KeybindingSrv = $injector.get('keybindingSrv');
|
|
|
const unsavedChangesSrv = $injector.get('unsavedChangesSrv');
|
|
const unsavedChangesSrv = $injector.get('unsavedChangesSrv');
|
|
|
- const viewStateSrv = $injector.get('dashboardViewStateSrv');
|
|
|
|
|
const dashboardSrv: DashboardSrv = $injector.get('dashboardSrv');
|
|
const dashboardSrv: DashboardSrv = $injector.get('dashboardSrv');
|
|
|
|
|
|
|
|
timeSrv.init(dashboard);
|
|
timeSrv.init(dashboard);
|
|
@@ -147,14 +149,16 @@ export function initDashboard({
|
|
|
try {
|
|
try {
|
|
|
dashboard.processRepeats();
|
|
dashboard.processRepeats();
|
|
|
dashboard.updateSubmenuVisibility();
|
|
dashboard.updateSubmenuVisibility();
|
|
|
- dashboard.autoFitPanels(window.innerHeight);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // handle auto fix experimental feature
|
|
|
|
|
+ const queryParams = getState().location.query;
|
|
|
|
|
+ if (queryParams.autofitpanels) {
|
|
|
|
|
+ dashboard.autoFitPanels(window.innerHeight, queryParams.kiosk);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// init unsaved changes tracking
|
|
// init unsaved changes tracking
|
|
|
unsavedChangesSrv.init(dashboard, $scope);
|
|
unsavedChangesSrv.init(dashboard, $scope);
|
|
|
|
|
|
|
|
- $scope.dashboard = dashboard;
|
|
|
|
|
- viewStateSrv.create($scope);
|
|
|
|
|
-
|
|
|
|
|
// dashboard keybindings should not live in core, this needs a bigger refactoring
|
|
// dashboard keybindings should not live in core, this needs a bigger refactoring
|
|
|
// So declaring this here so it can depend on the removePanel util function
|
|
// So declaring this here so it can depend on the removePanel util function
|
|
|
// Long term onRemovePanel should be handled via react prop callback
|
|
// Long term onRemovePanel should be handled via react prop callback
|