Skip to content

Commit

Permalink
Kiosk mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dhodgsonintergral committed Jan 2, 2024
1 parent 1e84fed commit d1fdd81
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 23 deletions.
6 changes: 5 additions & 1 deletion conf/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

# possible values : production, development
app_mode = production
app_mode = FusionReactor

# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
instance_name = ${HOSTNAME}
Expand Down Expand Up @@ -1357,6 +1357,10 @@ news_feed_enabled = true
# Set the number of data source queries that can be executed concurrently in mixed queries. Default is the number of CPUs.
concurrent_query_limit =

[kiosk]
# Enable the kiosk section
mode = off

#################################### Query History #############################
[query_history]
# Enable the Query history
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-data/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface GrafanaConfig {
alertingMinInterval: number;
authProxyEnabled: boolean;
exploreEnabled: boolean;
kioskMode: string;
queryHistoryEnabled: boolean;
helpEnabled: boolean;
profileEnabled: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-runtime/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
angularSupportEnabled = false;
authProxyEnabled = false;
exploreEnabled = false;
kioskMode = 'off';
queryHistoryEnabled = false;
helpEnabled = false;
profileEnabled = false;
Expand Down
19 changes: 10 additions & 9 deletions pkg/api/dtos/frontend_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,16 @@ type FrontendSettingsDTO struct {
LiveEnabled bool `json:"liveEnabled"`
AutoAssignOrg bool `json:"autoAssignOrg"`

VerifyEmailEnabled bool `json:"verifyEmailEnabled"`
SigV4AuthEnabled bool `json:"sigV4AuthEnabled"`
AzureAuthEnabled bool `json:"azureAuthEnabled"`
RbacEnabled bool `json:"rbacEnabled"`
ExploreEnabled bool `json:"exploreEnabled"`
HelpEnabled bool `json:"helpEnabled"`
ProfileEnabled bool `json:"profileEnabled"`
NewsFeedEnabled bool `json:"newsFeedEnabled"`
QueryHistoryEnabled bool `json:"queryHistoryEnabled"`
VerifyEmailEnabled bool `json:"verifyEmailEnabled"`
SigV4AuthEnabled bool `json:"sigV4AuthEnabled"`
AzureAuthEnabled bool `json:"azureAuthEnabled"`
RbacEnabled bool `json:"rbacEnabled"`
ExploreEnabled bool `json:"exploreEnabled"`
KioskMode string `json:"kioskMode"`
HelpEnabled bool `json:"helpEnabled"`
ProfileEnabled bool `json:"profileEnabled"`
NewsFeedEnabled bool `json:"newsFeedEnabled"`
QueryHistoryEnabled bool `json:"queryHistoryEnabled"`

GoogleAnalyticsId string `json:"googleAnalyticsId"`
GoogleAnalytics4Id string `json:"googleAnalytics4Id"`
Expand Down
1 change: 1 addition & 0 deletions pkg/api/frontendsettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
ProfileEnabled: setting.ProfileEnabled,
NewsFeedEnabled: setting.NewsFeedEnabled,
QueryHistoryEnabled: hs.Cfg.QueryHistoryEnabled,
KioskMode: setting.KioskMode,
GoogleAnalyticsId: hs.Cfg.GoogleAnalyticsID,
GoogleAnalytics4Id: hs.Cfg.GoogleAnalytics4ID,
GoogleAnalytics4SendManualPageViews: hs.Cfg.GoogleAnalytics4SendManualPageViews,
Expand Down
6 changes: 6 additions & 0 deletions pkg/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ var (
// Explore UI
ExploreEnabled bool

//kiosk mode
KioskMode string

// Help UI
HelpEnabled bool

Expand Down Expand Up @@ -1156,6 +1159,9 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
explore := iniFile.Section("explore")
ExploreEnabled = explore.Key("enabled").MustBool(true)

kiosk := iniFile.Section("kiosk")
KioskMode = valueAsString(kiosk, "mode", "off")

help := iniFile.Section("help")
HelpEnabled = help.Key("enabled").MustBool(true)

Expand Down
2 changes: 1 addition & 1 deletion public/app/core/components/AppChrome/AppChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Props extends PropsWithChildren<{}> {}
export function AppChrome({ children }: Props) {
const { chrome } = useGrafana();
const state = chrome.useState();
const searchBarHidden = state.searchBarHidden || state.kioskMode === KioskMode.TV;
const searchBarHidden = state.searchBarHidden || state.kioskMode === KioskMode.TV || true;
const theme = useTheme2();
const styles = useStyles2(getStyles);

Expand Down
4 changes: 4 additions & 0 deletions public/app/core/components/AppChrome/AppChromeService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export class AppChromeService {
this.update({ kioskMode: KioskMode.TV });
break;
case '1':
case 'embed':
this.update({kioskMode: KioskMode.Embed });
case true:
this.update({ kioskMode: KioskMode.Full });
}
Expand All @@ -150,6 +152,8 @@ export class AppChromeService {
switch (mode) {
case KioskMode.TV:
return 'tv';
case KioskMode.Embed:
return 'embed';
case KioskMode.Full:
return true;
default:
Expand Down
34 changes: 25 additions & 9 deletions public/app/core/navigation/kiosk.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
import { UrlQueryMap } from '@grafana/data';

import { KioskMode } from '../../types';
import config from '../config';

// TODO Remove after topnav feature toggle is permanent and old NavBar is removed
export function getKioskMode(queryParams: UrlQueryMap): KioskMode | null {
switch (queryParams.kiosk) {
case 'tv':
return KioskMode.TV;
// legacy support
case '1':
case true:
return KioskMode.Full;
default:
return null;
if (config.KioskMode === 'off') {
switch (queryParams.kiosk) {
case 'tv':
return KioskMode.TV;
// legacy support
case '1':
case 'full':
case true:
return KioskMode.Full;
case 'embed':
return KioskMode.Embed;
default:
return null;
}
} else {
switch (config.KioskMode) {
// legacy support
case 'full':
return KioskMode.Full;
case 'embed':
return KioskMode.Embed;
default:
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const DashNav = React.memo<Props>((props) => {
const { canStar, canShare, isStarred } = dashboard.meta;
const buttons: ReactNode[] = [];

if (kioskMode || isPlaylistRunning()) {
if ((kioskMode && kioskMode !== KioskMode.Embed) || isPlaylistRunning()) {
return [];
}

Expand Down
4 changes: 2 additions & 2 deletions public/app/features/dashboard/containers/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
}

const inspectPanel = this.getInspectPanel();
const showSubMenu = !editPanel && !kioskMode && !this.props.queryParams.editview;
const showSubMenu = !editPanel && (!kioskMode || kioskMode === KioskMode.Embed) && !this.props.queryParams.editview;

const showToolbar = kioskMode !== KioskMode.Full && !queryParams.editview;
const showToolbar = kioskMode !== KioskMode.Full && !queryParams.editview;

const pageClassName = cx({
'panel-in-fullscreen': Boolean(viewPanel),
Expand Down
1 change: 1 addition & 0 deletions public/app/types/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface DashboardInitError {
export enum KioskMode {
TV = 'tv',
Full = 'full',
Embed = 'embed',
}

export type GetMutableDashboardModelFn = () => DashboardModel | null;
Expand Down

0 comments on commit d1fdd81

Please sign in to comment.