diff --git a/public/app/core/components/grafana_app.ts b/public/app/core/components/grafana_app.ts index b5ba0e5e4a5..48b1ff60be2 100644 --- a/public/app/core/components/grafana_app.ts +++ b/public/app/core/components/grafana_app.ts @@ -109,6 +109,48 @@ export function grafanaAppDirective(playlistSrv, contextSrv) { $("#tooltip, .tooltip").remove(); }); + // handle kiosk mode + appEvents.on('toggle-kiosk-mode', () => { + body.toggleClass('page-kiosk-mode'); + }); + + // handle in active view state class + var lastActivity = new Date().getTime(); + var activeUser = true; + var inActiveTimeLimit = 2 * 60 * 1000; + + function checkForInActiveUser() { + if (!activeUser) { + return; + } + // only go to activity low mode on dashboard page + if (!body.hasClass('page-dashboard')) { + return; + } + + if ((new Date().getTime() - lastActivity) > inActiveTimeLimit) { + activeUser = false; + body.addClass('user-activity-low'); + } + } + + function userActivityDetected() { + lastActivity = new Date().getTime(); + if (!activeUser) { + activeUser = true; + body.removeClass('user-activity-low'); + } + } + + body.mousemove(userActivityDetected); + body.keydown(userActivityDetected); + setInterval(checkForInActiveUser, 1000); + + appEvents.on('toggle-view-mode', () => { + lastActivity = 0; + checkForInActiveUser(); + }); + // handle document clicks that should hide things body.click(function(evt) { var target = $(evt.target); diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index d96b38dee19..880315ed498 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -190,6 +190,14 @@ export class KeybindingSrv { this.showDashEditView('settings'); }); + this.bind('d k', () => { + appEvents.emit('toggle-kiosk-mode'); + }); + + this.bind('d v', () => { + appEvents.emit('toggle-view-mode'); + }); + this.bind('esc', () => { var popups = $('.popover.in'); if (popups.length > 0) { diff --git a/public/app/partials/dashboard.html b/public/app/partials/dashboard.html index cedaf7ed7b0..96e06edc8b6 100644 --- a/public/app/partials/dashboard.html +++ b/public/app/partials/dashboard.html @@ -1,4 +1,4 @@ -