app.blade.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!doctype html>
  2. <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <!-- CSRF Token -->
  7. <meta name="csrf-token" content="{{ csrf_token() }}">
  8. <title>{{ config('app.name', 'Laravel') }}</title>
  9. <!-- Fonts -->
  10. <link rel="dns-prefetch" href="//fonts.bunny.net">
  11. <link href="https://fonts.bunny.net/css?family=Nunito" rel="stylesheet">
  12. <!-- favicon -->
  13. <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
  14. <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  15. <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  16. <link rel="manifest" href="/site.webmanifest">
  17. <!-- Scripts -->
  18. @vite(['resources/sass/app.scss', 'resources/js/app.js'])
  19. </head>
  20. <body>
  21. <div class="alerts">
  22. @if($message = session('success'))
  23. @php
  24. if(!is_array($message)) $message = [$message];
  25. @endphp
  26. @foreach($message as $m)
  27. <div class="main-alert alert alert-success" role="alert">
  28. {{ $m }}
  29. </div>
  30. @endforeach
  31. @endif
  32. @if($message = session('danger'))
  33. @php
  34. if(!is_array($message)) $message = [$message];
  35. @endphp
  36. @foreach($message as $m)
  37. <div class="main-alert alert alert-danger" role="alert">
  38. {{ $m }}
  39. </div>
  40. @endforeach
  41. @endif
  42. </div>
  43. <div id="app">
  44. <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
  45. <div class="container-fluid">
  46. <a class="navbar-brand" href="{{ url('/') }}">
  47. {{ config('app.name', 'Laravel') }}
  48. </a>
  49. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Открыть меню">
  50. <span class="navbar-toggler-icon"></span>
  51. </button>
  52. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  53. <!-- Left Side Of Navbar -->
  54. <ul class="navbar-nav me-auto">
  55. @include('layouts.menu')
  56. </ul>
  57. <!-- Right Side Of Navbar -->
  58. <ul class="navbar-nav ms-auto">
  59. <!-- Authentication Links -->
  60. @guest
  61. @if (Route::has('login'))
  62. <li class="nav-item">
  63. <a class="nav-link" href="{{ route('login') }}">Вход</a>
  64. </li>
  65. @endif
  66. @if (Route::has('register'))
  67. <li class="nav-item">
  68. <a class="nav-link" href="{{ route('register') }}">Регистрация</a>
  69. </li>
  70. @endif
  71. @else
  72. <li class="nav-item dropdown">
  73. <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  74. {{ year() }}
  75. </a>
  76. <div class="dropdown-menu">
  77. @for($year = (int)date('Y') + 1; $year >= 2020; $year--)
  78. <a class="dropdown-item" href="{{ route('set-year', ['year' => $year]) }}">{{ $year }}</a>
  79. @endfor
  80. </div>
  81. </li>
  82. <li class="nav-item dropdown">
  83. <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  84. {{ Auth::user()->name }}
  85. </a>
  86. <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
  87. <a class="dropdown-item" href="{{ route('user.profile') }}">Профиль</a>
  88. <a class="dropdown-item" href="{{ route('logout') }}"
  89. onclick="event.preventDefault();
  90. document.getElementById('logout-form').submit();">
  91. Выход
  92. </a>
  93. <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
  94. @csrf
  95. </form>
  96. </div>
  97. </li>
  98. @endguest
  99. </ul>
  100. </div>
  101. </div>
  102. </nav>
  103. <main class="py-4">
  104. <div class="container-fluid">
  105. @yield('content')
  106. </div>
  107. </main>
  108. </div>
  109. @include('partials.customAlert')
  110. <script>
  111. // Функция для замены стандартного alert
  112. function customAlert(message) {
  113. $('#customAlertModalBody').text(message); // Устанавливаем текст сообщения
  114. let myModal = new bootstrap.Modal(document.getElementById('customAlertModal'), {});
  115. myModal.show();
  116. }
  117. </script>
  118. @stack('scripts')
  119. <script type="module">
  120. let user = {{ auth()->user()?->id ?? 0}};
  121. let socketAddress = '{{ config('app.ws_addr') }}';
  122. localStorage.setItem('user', user);
  123. localStorage.setItem('socketAddress', socketAddress);
  124. let selectMaf = $('#select_maf');
  125. $('#search_maf').on('keyup', function () {
  126. // search products on backend
  127. $.get('{{ route('product.search') }}?s=' + $(this).val(),
  128. function (data) {
  129. selectMaf.children().remove()
  130. $.each(data, function (id, name) {
  131. selectMaf.append('<option value=\'' + id + '\'>' + name + '</option>');
  132. });
  133. }
  134. );
  135. });
  136. $(document).ready(function () {
  137. setInterval(keepTokenAlive, 1000 * 60 * 15); // every 15 mins
  138. function keepTokenAlive() {
  139. $.ajax({
  140. url: '/keep-token-alive',
  141. method: 'post',
  142. headers: {
  143. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  144. }
  145. }).then(function () {
  146. console.log('Updated csrf token');
  147. });
  148. }
  149. });
  150. </script>
  151. </body>
  152. </html>