Files
Toiminnanohjaus/resources/views/components/profile-menu.blade.php
T
petriandClaude Sonnet 5.5 32c33e2a64 Give the machine console its own session with PIN sign-in, make counters cumulative
The console under console/ has its own session cookie and console guard
(UseConsoleSession), so signing out or changing user there leaves the
normal interface alone. Links open it in a new window through a one-time
handoff key; a signed-out console asks for a PIN code or password on its
own login page. Users set their 4-6 digit PIN on the profile's PIN page,
and the console's change user dialog takes it on a keypad; five wrong
PINs lock PIN sign-in for 15 minutes.

Machine counters are cumulative: users record how much a job used and it
is added to the latest reading. A maintenance record restarts the whole
counter interval from the reading at the record.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-29 09:58:11 +02:00

110 lines
5.5 KiB
PHP

@php
$user = auth()->user();
$currentLocale = app()->getLocale();
@endphp
{{--
The signed-in user's profile menu: a disclosure button (WAI-ARIA disclosure, not role="menu") that opens a panel
with the language (kept on the account), the theme (kept on this device by tallstackui_darkTheme() on <html>,
whose "mode" the radios bind to) and logging out. Escape and a click outside close it, and so does moving focus
out of it to another element (a click on a radio's label text moves focus nowhere, so it must not close the
panel). The button's name stays the same; aria-expanded tells whether the panel is open.
--}}
<div
class="relative"
x-data="{ open: false }"
x-on:keydown.escape="if (open) { open = false; $refs.trigger.focus() }"
x-on:click.outside="open = false"
x-on:focusout="if (open && $event.relatedTarget && ! $el.contains($event.relatedTarget)) open = false"
>
<button
type="button"
x-ref="trigger"
x-on:click="open = ! open"
x-bind:aria-expanded="open.toString()"
aria-expanded="false"
aria-controls="profile-menu-panel"
aria-label="{{ __('layout.profile.menu', ['name' => $user->name]) }}"
data-profile-menu
class="flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium text-zinc-200 hover:bg-zinc-700 hover:text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-400"
>
<x-icon name="user-circle" class="size-5" aria-hidden="true" />
<span>{{ $user->name }}</span>
<x-icon name="chevron-down" class="size-4 transition-transform" x-bind:class="{ 'rotate-180': open }" aria-hidden="true" />
</button>
<div
id="profile-menu-panel"
x-show="open"
x-cloak
class="z-40 mt-1 w-72 max-w-[calc(100vw-2rem)] space-y-4 rounded-md border border-zinc-600 bg-zinc-800 p-4 text-sm text-zinc-100 shadow-lg sm:absolute sm:end-0"
>
<p>
<span class="block font-semibold">{{ $user->name }}</span>
<span class="block text-zinc-300">{{ __('users.roles.'.$user->role->value) }}</span>
</p>
<form method="POST" action="{{ route('locale.update') }}">
@csrf
<fieldset>
<legend class="mb-2 font-semibold">{{ __('layout.profile.language') }}</legend>
<div class="flex flex-wrap gap-2">
@foreach (\App\Modules\Users\Domain\Enums\Locale::cases() as $locale)
@php($isCurrent = $locale->value === $currentLocale)
<button
type="submit"
name="locale"
value="{{ $locale->value }}"
lang="{{ $locale->value }}"
aria-pressed="{{ $isCurrent ? 'true' : 'false' }}"
@class([
'flex min-h-6 items-center gap-1 rounded-md border px-3 py-1.5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-400',
'border-zinc-200 bg-zinc-700 font-semibold text-white' => $isCurrent,
'border-zinc-500 text-zinc-200 hover:bg-zinc-700 hover:text-white' => ! $isCurrent,
])
>
@if ($isCurrent)
<x-icon name="check" class="size-4" aria-hidden="true" />
@endif
{{ __('layout.languages.'.$locale->value) }}
</button>
@endforeach
</div>
</fieldset>
</form>
<fieldset>
<legend class="mb-2 font-semibold">{{ __('layout.profile.theme') }}</legend>
<div class="space-y-1">
@foreach (['light' => 'theme_light', 'dark' => 'theme_dark', 'system' => 'theme_system'] as $mode => $label)
<label class="flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-zinc-700 has-checked:bg-zinc-700 has-checked:font-semibold">
<input
type="radio"
name="profile-theme"
value="{{ $mode }}"
x-model="mode"
data-theme-option="{{ $mode }}"
class="size-4 border-zinc-400 bg-zinc-900 text-primary-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-400 focus:ring-0 focus:ring-offset-0"
>
{{ __('layout.profile.'.$label) }}
</label>
@endforeach
</div>
</fieldset>
@can('machines.use')
<p>
<a href="{{ route('profile.pin') }}" wire:navigate class="flex min-h-6 items-center gap-2 rounded-md px-2 py-1 text-zinc-100 underline hover:bg-zinc-700 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-400">
<x-icon name="key" class="size-4" aria-hidden="true" />
{{ __('users.pin.title') }}
</a>
</p>
@endcan
<form method="POST" action="{{ route('logout') }}" class="border-t border-zinc-600 pt-3">
@csrf
<x-button submit subtle color="black" sm icon="arrow-right-start-on-rectangle" :text="__('layout.logout')" />
</form>
</div>
</div>