templates/base_layout.html.twig line 1

Open in your IDE?
  1. <!DOCTYPE html>
  2. <html lang="cs">
  3. <head>
  4. <!-- Meta Tags -->
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="Aplikace, která umí usnadnit život všem energetikům">
  8. <meta name="author" content="FINFORCE s.r.o.">
  9. <!-- Favicon -->
  10. <link rel="apple-touch-icon" sizes="180x180" href="{{ asset('apple-touch-icon.png') }}">
  11. <link rel="icon" type="image/png" sizes="32x32" href="{{ asset('favicon-32x32.png') }}">
  12. <link rel="icon" type="image/png" sizes="16x16" href="{{ asset('favicon-16x16.png') }}">
  13. <link rel="manifest" href="{{ asset('site.webmanifest') }}" crossorigin="use-credentials">
  14. <!-- App css -->
  15. {{ encore_entry_link_tags('app-styles-icons') }}
  16. <title>{% block title %}E-Manažer{% endblock %}</title>
  17. {% block stylesheets %}{% endblock %}
  18. <script>
  19. window.locale = '{{ app.request.locale }}';
  20. </script>
  21. {% block chatcode %}{% endblock %}
  22. {# Unified idle logout script for both app and admin, only for authenticated users #}
  23. {% if app.user is not null %}
  24. {% set __route = app.request.attributes.get('_route') ?? '' %}
  25. {% set __path = app.request.getPathInfo() %}
  26. {% set __is_admin = (__route starts with 'admin_') or (__path starts with '/admin') %}
  27. <script>
  28. (function () {
  29. var TIMEOUT_MS = 24 * 60 * 1000; // 24 minutes
  30. var BROADCAST_THROTTLE_MS = 2000;
  31. var STORAGE_KEY = 'em_idle:lastActivity';
  32. var LOGOUT_URL = '{{ __is_admin ? path('admin_logout', {'timeout': 1}) : path('logout', {'timeout': 1}) }}';
  33. var lastActivity = Date.now();
  34. var lastBroadcast = 0;
  35. var timerId = null;
  36. var storageAvailable = false;
  37. try {
  38. storageAvailable = typeof window.localStorage !== 'undefined' && window.localStorage !== null;
  39. } catch (e) {
  40. storageAvailable = false;
  41. }
  42. function triggerLogout() {
  43. try {
  44. var current = window.location.href;
  45. var sep = LOGOUT_URL.indexOf('?') === -1 ? '?' : '&';
  46. window.location.href = LOGOUT_URL + sep + 'rt=' + encodeURIComponent(current);
  47. } catch (e) {
  48. window.location.href = LOGOUT_URL;
  49. }
  50. }
  51. function scheduleCheck() {
  52. if (timerId) {
  53. clearTimeout(timerId);
  54. }
  55. var remaining = (lastActivity + TIMEOUT_MS) - Date.now();
  56. if (remaining <= 0) {
  57. triggerLogout();
  58. return;
  59. }
  60. timerId = setTimeout(onDeadline, remaining);
  61. }
  62. function onDeadline() {
  63. timerId = null;
  64. if (Date.now() - lastActivity >= TIMEOUT_MS) {
  65. triggerLogout();
  66. } else {
  67. scheduleCheck();
  68. }
  69. }
  70. function broadcastActivity(now) {
  71. if (!storageAvailable) {
  72. return;
  73. }
  74. if (now - lastBroadcast < BROADCAST_THROTTLE_MS) {
  75. return;
  76. }
  77. lastBroadcast = now;
  78. try {
  79. window.localStorage.setItem(STORAGE_KEY, String(now));
  80. } catch (e) {
  81. // storage may be full or disabled in private mode
  82. }
  83. }
  84. function recordLocalActivity() {
  85. var now = Date.now();
  86. lastActivity = now;
  87. broadcastActivity(now);
  88. scheduleCheck();
  89. }
  90. function recordRemoteActivity(timestamp) {
  91. if (timestamp > lastActivity) {
  92. lastActivity = timestamp;
  93. scheduleCheck();
  94. }
  95. }
  96. var events = ['click', 'mousemove', 'keydown', 'scroll', 'touchstart', 'wheel'];
  97. events.forEach(function (evt) {
  98. window.addEventListener(evt, recordLocalActivity, { passive: true });
  99. });
  100. document.addEventListener('visibilitychange', function () {
  101. if (document.hidden) {
  102. return;
  103. }
  104. if (storageAvailable) {
  105. try {
  106. var stored = parseInt(window.localStorage.getItem(STORAGE_KEY), 10);
  107. if (!isNaN(stored) && stored > lastActivity) {
  108. lastActivity = stored;
  109. }
  110. } catch (e) {
  111. // ignore
  112. }
  113. }
  114. recordLocalActivity();
  115. });
  116. if (storageAvailable) {
  117. window.addEventListener('storage', function (event) {
  118. if (event.key !== STORAGE_KEY || event.newValue === null) {
  119. return;
  120. }
  121. var remote = parseInt(event.newValue, 10);
  122. if (!isNaN(remote)) {
  123. recordRemoteActivity(remote);
  124. }
  125. });
  126. try {
  127. var initial = parseInt(window.localStorage.getItem(STORAGE_KEY), 10);
  128. if (!isNaN(initial) && initial > lastActivity) {
  129. lastActivity = initial;
  130. }
  131. } catch (e) {
  132. // ignore
  133. }
  134. }
  135. recordLocalActivity();
  136. })();
  137. </script>
  138. {% endif %}
  139. </head>
  140. {% block body %}
  141. <body>
  142. </body>
  143. {% endblock %}
  144. </html>