mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added handling of kiosk mode
This commit is contained in:
parent
fdeea9144c
commit
3baaf2c3e4
@ -15,6 +15,7 @@ import sortByKeys from 'app/core/utils/sort_by_keys';
|
||||
import { PanelModel } from './PanelModel';
|
||||
import { DashboardMigrator } from './DashboardMigrator';
|
||||
import { TimeRange } from '@grafana/ui/src';
|
||||
import { UrlQueryValue } from 'app/types';
|
||||
|
||||
export class DashboardModel {
|
||||
id: any;
|
||||
@ -867,11 +868,7 @@ export class DashboardModel {
|
||||
return !_.isEqual(updated, this.originalTemplating);
|
||||
}
|
||||
|
||||
autoFitPanels(viewHeight: number) {
|
||||
if (!this.meta.autofitpanels) {
|
||||
return;
|
||||
}
|
||||
|
||||
autoFitPanels(viewHeight: number, kioskMode?: UrlQueryValue) {
|
||||
const currentGridHeight = Math.max(
|
||||
...this.panels.map(panel => {
|
||||
return panel.gridPos.h + panel.gridPos.y;
|
||||
@ -885,12 +882,12 @@ export class DashboardModel {
|
||||
let visibleHeight = viewHeight - navbarHeight - margin;
|
||||
|
||||
// Remove submenu height if visible
|
||||
if (this.meta.submenuEnabled && !this.meta.kiosk) {
|
||||
if (this.meta.submenuEnabled && !kioskMode) {
|
||||
visibleHeight -= submenuHeight;
|
||||
}
|
||||
|
||||
// add back navbar height
|
||||
if (this.meta.kiosk === 'b') {
|
||||
if (kioskMode === 'tv') {
|
||||
visibleHeight += 55;
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,6 @@ export function initDashboard({
|
||||
try {
|
||||
switch (routeInfo) {
|
||||
// handle old urls with no uid
|
||||
case DashboardRouteInfo.Old: {
|
||||
redirectToNewUrl(urlSlug, dispatch);
|
||||
return;
|
||||
}
|
||||
case DashboardRouteInfo.Home: {
|
||||
// load home dash
|
||||
dashDTO = await getBackendSrv().get('/api/dashboards/home');
|
||||
@ -78,20 +74,27 @@ export function initDashboard({
|
||||
break;
|
||||
}
|
||||
case DashboardRouteInfo.Normal: {
|
||||
// for old db routes we redirect
|
||||
if (urlType === 'db') {
|
||||
redirectToNewUrl(urlSlug, dispatch);
|
||||
return;
|
||||
}
|
||||
|
||||
const loaderSrv = $injector.get('dashboardLoaderSrv');
|
||||
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;
|
||||
}
|
||||
case DashboardRouteInfo.New: {
|
||||
@ -129,7 +132,6 @@ export function initDashboard({
|
||||
const variableSrv: VariableSrv = $injector.get('variableSrv');
|
||||
const keybindingSrv: KeybindingSrv = $injector.get('keybindingSrv');
|
||||
const unsavedChangesSrv = $injector.get('unsavedChangesSrv');
|
||||
const viewStateSrv = $injector.get('dashboardViewStateSrv');
|
||||
const dashboardSrv: DashboardSrv = $injector.get('dashboardSrv');
|
||||
|
||||
timeSrv.init(dashboard);
|
||||
@ -147,14 +149,16 @@ export function initDashboard({
|
||||
try {
|
||||
dashboard.processRepeats();
|
||||
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
|
||||
unsavedChangesSrv.init(dashboard, $scope);
|
||||
|
||||
$scope.dashboard = dashboard;
|
||||
viewStateSrv.create($scope);
|
||||
|
||||
// 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
|
||||
// Long term onRemovePanel should be handled via react prop callback
|
||||
|
@ -62,7 +62,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
|
||||
.when('/dashboard/:type/:slug', {
|
||||
template: '<react-container />',
|
||||
pageClass: 'page-dashboard',
|
||||
routeInfo: DashboardRouteInfo.Old,
|
||||
routeInfo: DashboardRouteInfo.Normal,
|
||||
reloadOnSearch: false,
|
||||
resolve: {
|
||||
component: () => DashboardPage,
|
||||
@ -88,7 +88,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
|
||||
.when('/dashboard-solo/:type/:slug', {
|
||||
template: '<react-container />',
|
||||
pageClass: 'dashboard-solo',
|
||||
routeInfo: DashboardRouteInfo.Old,
|
||||
routeInfo: DashboardRouteInfo.Normal,
|
||||
resolve: {
|
||||
component: () => SoloPanelPage,
|
||||
},
|
||||
|
@ -8,10 +8,10 @@ export interface MutableDashboard {
|
||||
}
|
||||
|
||||
export enum DashboardRouteInfo {
|
||||
Old = 'old-dashboard',
|
||||
Home = 'home-dashboard',
|
||||
New = 'new-dashboard',
|
||||
Normal = 'normal-dashboard',
|
||||
Scripted = 'scripted-dashboard',
|
||||
}
|
||||
|
||||
export enum DashboardLoadingState {
|
||||
|
Loading…
Reference in New Issue
Block a user