kiosk.ts 929 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { AppEvents } from '@grafana/data';
  2. import { locationService } from '@grafana/runtime';
  3. import { KioskMode } from '../../types';
  4. import appEvents from '../app_events';
  5. export function toggleKioskMode() {
  6. let kiosk = locationService.getSearchObject().kiosk;
  7. switch (kiosk) {
  8. case 'tv':
  9. kiosk = true;
  10. appEvents.emit(AppEvents.alertSuccess, ['Press ESC to exit Kiosk mode']);
  11. break;
  12. case '1':
  13. case true:
  14. kiosk = null;
  15. break;
  16. default:
  17. kiosk = 'tv';
  18. }
  19. locationService.partial({ kiosk });
  20. }
  21. export function getKioskMode(): KioskMode {
  22. const kiosk = locationService.getSearchObject().kiosk;
  23. switch (kiosk) {
  24. case 'tv':
  25. return KioskMode.TV;
  26. // legacy support
  27. case '1':
  28. case true:
  29. return KioskMode.Full;
  30. default:
  31. return KioskMode.Off;
  32. }
  33. }
  34. export function exitKioskMode() {
  35. locationService.partial({ kiosk: null });
  36. }