From d19a079b8a2593cd5630826ca63570a18e17468e Mon Sep 17 00:00:00 2001 From: Benjamin Nussbaum Date: Thu, 15 Jan 2026 09:01:59 +0100 Subject: [PATCH] chore: pint --- resources/views/flux/navlist/group.blade.php | 8 +- .../livewire/auth/confirm-password.blade.php | 3 +- .../livewire/auth/forgot-password.blade.php | 3 +- resources/views/livewire/auth/login.blade.php | 9 +- .../views/livewire/auth/register.blade.php | 8 +- .../livewire/auth/reset-password.blade.php | 8 +- .../livewire/auth/verify-email.blade.php | 3 +- .../views/livewire/catalog/trmnl.blade.php | 2 +- resources/views/livewire/codemirror.blade.php | 9 +- .../views/livewire/device-dashboard.blade.php | 3 +- .../livewire/devices/configure.blade.php | 50 +++++-- .../views/livewire/devices/logs.blade.php | 5 +- .../views/livewire/devices/manage.blade.php | 18 ++- .../views/livewire/playlists/index.blade.php | 22 +-- .../views/livewire/plugins/api.blade.php | 7 +- .../livewire/plugins/config-modal.blade.php | 25 ++-- .../plugins/image-webhook-instance.blade.php | 36 +++-- .../livewire/plugins/image-webhook.blade.php | 6 +- .../views/livewire/plugins/index.blade.php | 44 +++--- .../views/livewire/plugins/markup.blade.php | 23 ++-- .../views/livewire/plugins/recipe.blade.php | 128 +++++++++++------- .../plugins/recipes/settings.blade.php | 12 +- .../livewire/settings/appearance.blade.php | 3 +- .../settings/delete-user-form.blade.php | 3 +- .../livewire/settings/password.blade.php | 5 +- .../livewire/settings/preferences.blade.php | 7 +- .../views/livewire/settings/profile.blade.php | 6 +- .../views/livewire/settings/support.blade.php | 5 +- tests/Feature/Api/ImageWebhookTest.php | 6 +- .../Livewire/Plugins/ConfigModalTest.php | 16 +-- 30 files changed, 295 insertions(+), 188 deletions(-) diff --git a/resources/views/flux/navlist/group.blade.php b/resources/views/flux/navlist/group.blade.php index cecbabe..844171f 100644 --- a/resources/views/flux/navlist/group.blade.php +++ b/resources/views/flux/navlist/group.blade.php @@ -4,7 +4,7 @@ 'heading' => null, ]) - + class('group/disclosure') }} @@ -30,7 +30,7 @@ - +
class('block space-y-[2px]') }}>
@@ -42,10 +42,10 @@
- +
class('block space-y-[2px]') }}> {{ $slot }}
- + diff --git a/resources/views/livewire/auth/confirm-password.blade.php b/resources/views/livewire/auth/confirm-password.blade.php index faa24e5..e1b7aea 100644 --- a/resources/views/livewire/auth/confirm-password.blade.php +++ b/resources/views/livewire/auth/confirm-password.blade.php @@ -5,7 +5,8 @@ use Illuminate\Validation\ValidationException; use Livewire\Attributes\Layout; use Livewire\Component; -new #[Layout('layouts.auth')] class extends Component { +new #[Layout('layouts.auth')] class extends Component +{ public string $password = ''; /** diff --git a/resources/views/livewire/auth/forgot-password.blade.php b/resources/views/livewire/auth/forgot-password.blade.php index 158c3fc..a47f879 100644 --- a/resources/views/livewire/auth/forgot-password.blade.php +++ b/resources/views/livewire/auth/forgot-password.blade.php @@ -4,7 +4,8 @@ use Illuminate\Support\Facades\Password; use Livewire\Attributes\Layout; use Livewire\Component; -new #[Layout('layouts.auth')] class extends Component { +new #[Layout('layouts.auth')] class extends Component +{ public string $email = ''; /** diff --git a/resources/views/livewire/auth/login.blade.php b/resources/views/livewire/auth/login.blade.php index 645b866..65396d4 100644 --- a/resources/views/livewire/auth/login.blade.php +++ b/resources/views/livewire/auth/login.blade.php @@ -10,7 +10,8 @@ use Livewire\Attributes\Layout; use Livewire\Attributes\Validate; use Livewire\Component; -new #[Layout('layouts.auth')] class extends Component { +new #[Layout('layouts.auth')] class extends Component +{ #[Validate('required|string|email')] public string $email = ''; @@ -28,7 +29,7 @@ new #[Layout('layouts.auth')] class extends Component { $this->ensureIsNotRateLimited(); - if (!Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) { + if (! Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ @@ -47,7 +48,7 @@ new #[Layout('layouts.auth')] class extends Component { */ protected function ensureIsNotRateLimited(): void { - if (!RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { + if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } @@ -68,7 +69,7 @@ new #[Layout('layouts.auth')] class extends Component { */ protected function throttleKey(): string { - return Str::transliterate(Str::lower($this->email) . '|' . request()->ip()); + return Str::transliterate(Str::lower($this->email).'|'.request()->ip()); } public function mount(): void diff --git a/resources/views/livewire/auth/register.blade.php b/resources/views/livewire/auth/register.blade.php index e98a4e1..8149fab 100644 --- a/resources/views/livewire/auth/register.blade.php +++ b/resources/views/livewire/auth/register.blade.php @@ -8,10 +8,14 @@ use Illuminate\Validation\Rules; use Livewire\Attributes\Layout; use Livewire\Component; -new #[Layout('layouts.auth')] class extends Component { +new #[Layout('layouts.auth')] class extends Component +{ public string $name = ''; + public string $email = ''; + public string $password = ''; + public string $password_confirmation = ''; /** @@ -21,7 +25,7 @@ new #[Layout('layouts.auth')] class extends Component { { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class], + 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class], 'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()], ]); diff --git a/resources/views/livewire/auth/reset-password.blade.php b/resources/views/livewire/auth/reset-password.blade.php index a58fd31..0fd18d7 100644 --- a/resources/views/livewire/auth/reset-password.blade.php +++ b/resources/views/livewire/auth/reset-password.blade.php @@ -10,11 +10,15 @@ use Livewire\Attributes\Layout; use Livewire\Attributes\Locked; use Livewire\Component; -new #[Layout('layouts.auth')] class extends Component { +new #[Layout('layouts.auth')] class extends Component +{ #[Locked] public string $token = ''; + public string $email = ''; + public string $password = ''; + public string $password_confirmation = ''; /** @@ -56,7 +60,7 @@ new #[Layout('layouts.auth')] class extends Component { // If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. - if ($status != Password::PasswordReset) { + if ($status !== Password::PasswordReset) { $this->addError('email', __($status)); return; diff --git a/resources/views/livewire/auth/verify-email.blade.php b/resources/views/livewire/auth/verify-email.blade.php index c05e3c4..c52e38c 100644 --- a/resources/views/livewire/auth/verify-email.blade.php +++ b/resources/views/livewire/auth/verify-email.blade.php @@ -6,7 +6,8 @@ use Illuminate\Support\Facades\Session; use Livewire\Attributes\Layout; use Livewire\Component; -new #[Layout('layouts.auth')] class extends Component { +new #[Layout('layouts.auth')] class extends Component +{ /** * Send an email verification notification to the user. */ diff --git a/resources/views/livewire/catalog/trmnl.blade.php b/resources/views/livewire/catalog/trmnl.blade.php index 5ab5224..0285669 100644 --- a/resources/views/livewire/catalog/trmnl.blade.php +++ b/resources/views/livewire/catalog/trmnl.blade.php @@ -122,7 +122,7 @@ class extends Component public function loadMore(): void { - $this->page++; + ++$this->page; $term = mb_trim($this->search); if ($term === '' || mb_strlen($term) < 2) { diff --git a/resources/views/livewire/codemirror.blade.php b/resources/views/livewire/codemirror.blade.php index acd8e2b..5b18d2a 100644 --- a/resources/views/livewire/codemirror.blade.php +++ b/resources/views/livewire/codemirror.blade.php @@ -1,17 +1,23 @@ id = $id; } - public function toJSON() { return json_encode([ diff --git a/resources/views/livewire/device-dashboard.blade.php b/resources/views/livewire/device-dashboard.blade.php index 703920c..1c9149f 100644 --- a/resources/views/livewire/device-dashboard.blade.php +++ b/resources/views/livewire/device-dashboard.blade.php @@ -2,7 +2,8 @@ use Livewire\Component; -new class extends Component { +new class extends Component +{ public function mount() { return view('livewire.device-dashboard', ['devices' => auth()->user()->devices()->paginate(10)]); diff --git a/resources/views/livewire/devices/configure.blade.php b/resources/views/livewire/devices/configure.blade.php index ffd315c..ce3e821 100644 --- a/resources/views/livewire/devices/configure.blade.php +++ b/resources/views/livewire/devices/configure.blade.php @@ -7,33 +7,50 @@ use App\Models\Playlist; use App\Models\PlaylistItem; use Livewire\Component; -new class extends Component { - +new class extends Component +{ public $device; public $name; + public $api_key; + public $friendly_id; + public $mac_address; + public $default_refresh_interval; + public $width; + public $height; + public $rotate; + public $image_format; + public $device_model_id; // Sleep mode and special function public $sleep_mode_enabled = false; + public $sleep_mode_from; + public $sleep_mode_to; + public $special_function; // Playlist properties public $playlists; + public $playlist_name; + public $selected_weekdays = null; + public $active_from; + public $active_until; + public $refresh_time = null; // Device model properties @@ -41,15 +58,17 @@ new class extends Component { // Firmware properties public $firmwares; + public $selected_firmware_id; + public $download_firmware; - public function mount(\App\Models\Device $device) + public function mount(App\Models\Device $device) { abort_unless(auth()->user()->devices->contains($device), 403); $current_image_uuid = $device->current_screen_image; - $current_image_path = 'images/generated/' . $current_image_uuid . '.png'; + $current_image_path = 'images/generated/'.$current_image_uuid.'.png'; $this->device = $device; $this->name = $device->name; @@ -65,10 +84,11 @@ new class extends Component { $this->deviceModels = DeviceModel::orderBy('label')->get()->sortBy(function ($deviceModel) { // Put TRMNL models at the top, then sort alphabetically within each group $isTrmnl = str_starts_with($deviceModel->label, 'TRMNL'); - return $isTrmnl ? '0' . $deviceModel->label : '1' . $deviceModel->label; + + return $isTrmnl ? '0'.$deviceModel->label : '1'.$deviceModel->label; }); $this->playlists = $device->playlists()->with('items.plugin')->orderBy('created_at')->get(); - $this->firmwares = \App\Models\Firmware::orderBy('latest', 'desc')->orderBy('created_at', 'desc')->get(); + $this->firmwares = Firmware::orderBy('latest', 'desc')->orderBy('created_at', 'desc')->get(); $this->selected_firmware_id = $this->firmwares->where('latest', true)->first()?->id; $this->sleep_mode_enabled = $device->sleep_mode_enabled ?? false; $this->sleep_mode_from = optional($device->sleep_mode_from)->format('H:i'); @@ -80,7 +100,7 @@ new class extends Component { ]); } - public function deleteDevice(\App\Models\Device $device) + public function deleteDevice(App\Models\Device $device) { abort_unless(auth()->user()->devices->contains($device), 403); $device->delete(); @@ -93,6 +113,7 @@ new class extends Component { // Convert empty string to null for custom selection if (empty($this->device_model_id)) { $this->device_model_id = null; + return; } @@ -162,7 +183,7 @@ new class extends Component { $this->refresh_time = null; } - if (empty($this->selected_weekdays)){ + if (empty($this->selected_weekdays)) { $this->selected_weekdays = null; } @@ -182,7 +203,7 @@ new class extends Component { public function togglePlaylistActive(Playlist $playlist) { - $playlist->update(['is_active' => !$playlist->is_active]); + $playlist->update(['is_active' => ! $playlist->is_active]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); } @@ -218,7 +239,7 @@ new class extends Component { public function togglePlaylistItemActive(PlaylistItem $item) { - $item->update(['is_active' => !$item->is_active]); + $item->update(['is_active' => ! $item->is_active]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); } @@ -227,7 +248,7 @@ new class extends Component { abort_unless(auth()->user()->devices->contains($playlist->device), 403); $playlist->delete(); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); - Flux::modal('delete-playlist-' . $playlist->id)->close(); + Flux::modal('delete-playlist-'.$playlist->id)->close(); } public function deletePlaylistItem(PlaylistItem $item) @@ -235,7 +256,7 @@ new class extends Component { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); $item->delete(); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); - Flux::modal('delete-playlist-item-' . $item->id)->close(); + Flux::modal('delete-playlist-item-'.$item->id)->close(); } public function editPlaylist(Playlist $playlist) @@ -258,7 +279,7 @@ new class extends Component { $this->refresh_time = null; } - if (empty($this->selected_weekdays)){ + if (empty($this->selected_weekdays)) { $this->selected_weekdays = null; } @@ -272,7 +293,7 @@ new class extends Component { $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); $this->reset(['playlist_name', 'selected_weekdays', 'active_from', 'active_until', 'refresh_time']); - Flux::modal('edit-playlist-' . $playlist->id)->close(); + Flux::modal('edit-playlist-'.$playlist->id)->close(); } public function preparePlaylistEdit(Playlist $playlist) @@ -292,7 +313,6 @@ new class extends Component { 'selected_firmware_id' => 'required|exists:firmware,id', ]); - if ($this->download_firmware) { FirmwareDownloadJob::dispatchSync(Firmware::find($this->selected_firmware_id)); } diff --git a/resources/views/livewire/devices/logs.blade.php b/resources/views/livewire/devices/logs.blade.php index 85f8653..6a8733c 100644 --- a/resources/views/livewire/devices/logs.blade.php +++ b/resources/views/livewire/devices/logs.blade.php @@ -1,11 +1,12 @@ deviceModels = DeviceModel::orderBy('label')->get()->sortBy(function ($deviceModel) { // Put TRMNL models at the top, then sort alphabetically within each group $isTrmnl = str_starts_with($deviceModel->label, 'TRMNL'); - return $isTrmnl ? '0' . $deviceModel->label : '1' . $deviceModel->label; + + return $isTrmnl ? '0'.$deviceModel->label : '1'.$deviceModel->label; }); + return view('livewire.devices.manage'); } @@ -81,7 +85,7 @@ new class extends Component { ]); $this->reset(); - \Flux::modal('create-device')->close(); + Flux::modal('create-device')->close(); $this->devices = auth()->user()->devices; session()->flash('message', 'Device created successfully.'); @@ -91,7 +95,7 @@ new class extends Component { { abort_unless(auth()->user()->devices->contains($device), 403); $device->update([ - 'proxy_cloud' => !$device->proxy_cloud, + 'proxy_cloud' => ! $device->proxy_cloud, ]); // if ($device->proxy_cloud) { @@ -108,9 +112,9 @@ new class extends Component { $pauseUntil = now()->addMinutes($this->pause_duration); $device->update(['pause_until' => $pauseUntil]); $this->reset('pause_duration'); - \Flux::modal('pause-device-' . $deviceId)->close(); + Flux::modal('pause-device-'.$deviceId)->close(); $this->devices = auth()->user()->devices; - session()->flash('message', 'Device paused until ' . $pauseUntil->format('H:i')); + session()->flash('message', 'Device paused until '.$pauseUntil->format('H:i')); } } diff --git a/resources/views/livewire/playlists/index.blade.php b/resources/views/livewire/playlists/index.blade.php index 5218b85..e6c6719 100644 --- a/resources/views/livewire/playlists/index.blade.php +++ b/resources/views/livewire/playlists/index.blade.php @@ -1,31 +1,37 @@ devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); + return view('livewire.playlists.index'); } public function togglePlaylistActive(Playlist $playlist) { abort_unless(auth()->user()->devices->contains($playlist->device), 403); - $playlist->update(['is_active' => !$playlist->is_active]); + $playlist->update(['is_active' => ! $playlist->is_active]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); } @@ -64,7 +70,7 @@ new class extends Component { public function togglePlaylistItemActive(PlaylistItem $item) { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); - $item->update(['is_active' => !$item->is_active]); + $item->update(['is_active' => ! $item->is_active]); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); } @@ -73,7 +79,7 @@ new class extends Component { abort_unless(auth()->user()->devices->contains($playlist->device), 403); $playlist->delete(); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); - Flux::modal('delete-playlist-' . $playlist->id)->close(); + Flux::modal('delete-playlist-'.$playlist->id)->close(); } public function deletePlaylistItem(PlaylistItem $item) @@ -81,7 +87,7 @@ new class extends Component { abort_unless(auth()->user()->devices->contains($item->playlist->device), 403); $item->delete(); $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); - Flux::modal('delete-playlist-item-' . $item->id)->close(); + Flux::modal('delete-playlist-item-'.$item->id)->close(); } public function editPlaylist(Playlist $playlist) @@ -106,7 +112,7 @@ new class extends Component { $this->refresh_time = null; } - if (empty($this->selected_weekdays)){ + if (empty($this->selected_weekdays)) { $this->selected_weekdays = null; } @@ -120,7 +126,7 @@ new class extends Component { $this->devices = auth()->user()->devices()->with(['playlists.items.plugin'])->get(); $this->reset(['playlist_name', 'selected_weekdays', 'active_from', 'active_until', 'refresh_time']); - Flux::modal('edit-playlist-' . $playlist->id)->close(); + Flux::modal('edit-playlist-'.$playlist->id)->close(); } public function preparePlaylistEdit(Playlist $playlist) diff --git a/resources/views/livewire/plugins/api.blade.php b/resources/views/livewire/plugins/api.blade.php index 9b95490..56ac708 100644 --- a/resources/views/livewire/plugins/api.blade.php +++ b/resources/views/livewire/plugins/api.blade.php @@ -1,12 +1,13 @@ loadData(); + $this->loadData(); } public function loadData(): void @@ -38,7 +42,7 @@ new class extends Component { $fieldKey = $field['keyname']; $rawValue = $this->configuration[$fieldKey] ?? ($field['default'] ?? ''); - $currentValue = is_array($rawValue) ? '' : (string)$rawValue; + $currentValue = is_array($rawValue) ? '' : (string) $rawValue; $this->multiValues[$fieldKey] = $currentValue !== '' ? array_values(array_filter(explode(',', $currentValue))) @@ -51,10 +55,11 @@ new class extends Component { * Triggered by @close on the modal to discard any typed but unsaved changes */ public int $resetIndex = 0; // Add this property + public function resetForm(): void { $this->loadData(); - $this->resetIndex++; // Increment to force DOM refresh + ++$this->resetIndex; // Increment to force DOM refresh } public function saveConfiguration() @@ -131,7 +136,7 @@ new class extends Component { if ($query !== null) { $requestData = [ 'function' => $fieldKey, - 'query' => $query + 'query' => $query, ]; } @@ -144,7 +149,7 @@ new class extends Component { } else { $this->xhrSelectOptions[$fieldKey] = []; } - } catch (\Exception $e) { + } catch (Exception $e) { $this->xhrSelectOptions[$fieldKey] = []; } } @@ -152,11 +157,11 @@ new class extends Component { public function searchXhrSelect(string $fieldKey, string $endpoint): void { $query = $this->searchQueries[$fieldKey] ?? ''; - if (!empty($query)) { + if (! empty($query)) { $this->loadXhrSelectOptions($fieldKey, $endpoint, $query); } } -};?> +}; ?>
diff --git a/resources/views/livewire/plugins/image-webhook-instance.blade.php b/resources/views/livewire/plugins/image-webhook-instance.blade.php index e73b1ac..7822a2b 100644 --- a/resources/views/livewire/plugins/image-webhook-instance.blade.php +++ b/resources/views/livewire/plugins/image-webhook-instance.blade.php @@ -3,14 +3,22 @@ use App\Models\Plugin; use Livewire\Component; -new class extends Component { +new class extends Component +{ public Plugin $plugin; + public string $name; + public array $checked_devices = []; + public array $device_playlists = []; + public array $device_playlist_names = []; + public array $device_weekdays = []; + public array $device_active_from = []; + public array $device_active_until = []; public function mount(): void @@ -38,7 +46,6 @@ new class extends Component { $this->plugin->update(['name' => $this->name]); } - public function addToPlaylist() { $this->validate([ @@ -46,14 +53,16 @@ new class extends Component { ]); foreach ($this->checked_devices as $deviceId) { - if (!isset($this->device_playlists[$deviceId]) || empty($this->device_playlists[$deviceId])) { - $this->addError('device_playlists.' . $deviceId, 'Please select a playlist for each device.'); + if (! isset($this->device_playlists[$deviceId]) || empty($this->device_playlists[$deviceId])) { + $this->addError('device_playlists.'.$deviceId, 'Please select a playlist for each device.'); + return; } if ($this->device_playlists[$deviceId] === 'new') { - if (!isset($this->device_playlist_names[$deviceId]) || empty($this->device_playlist_names[$deviceId])) { - $this->addError('device_playlist_names.' . $deviceId, 'Playlist name is required when creating a new playlist.'); + if (! isset($this->device_playlist_names[$deviceId]) || empty($this->device_playlist_names[$deviceId])) { + $this->addError('device_playlist_names.'.$deviceId, 'Playlist name is required when creating a new playlist.'); + return; } } @@ -63,15 +72,15 @@ new class extends Component { $playlist = null; if ($this->device_playlists[$deviceId] === 'new') { - $playlist = \App\Models\Playlist::create([ + $playlist = App\Models\Playlist::create([ 'device_id' => $deviceId, 'name' => $this->device_playlist_names[$deviceId], - 'weekdays' => !empty($this->device_weekdays[$deviceId] ?? null) ? $this->device_weekdays[$deviceId] : null, + 'weekdays' => ! empty($this->device_weekdays[$deviceId] ?? null) ? $this->device_weekdays[$deviceId] : null, 'active_from' => $this->device_active_from[$deviceId] ?? null, 'active_until' => $this->device_active_until[$deviceId] ?? null, ]); } else { - $playlist = \App\Models\Playlist::findOrFail($this->device_playlists[$deviceId]); + $playlist = App\Models\Playlist::findOrFail($this->device_playlists[$deviceId]); } $maxOrder = $playlist->items()->max('order') ?? 0; @@ -96,16 +105,17 @@ new class extends Component { public function getDevicePlaylists($deviceId) { - return \App\Models\Playlist::where('device_id', $deviceId)->get(); + return App\Models\Playlist::where('device_id', $deviceId)->get(); } public function hasAnyPlaylistSelected(): bool { foreach ($this->checked_devices as $deviceId) { - if (isset($this->device_playlists[$deviceId]) && !empty($this->device_playlists[$deviceId])) { + if (isset($this->device_playlists[$deviceId]) && ! empty($this->device_playlists[$deviceId])) { return true; } } + return false; } @@ -118,14 +128,14 @@ new class extends Component { public function getImagePath(): ?string { - if (!$this->plugin->current_image) { + if (! $this->plugin->current_image) { return null; } $extensions = ['png', 'bmp']; foreach ($extensions as $ext) { $path = 'images/generated/'.$this->plugin->current_image.'.'.$ext; - if (\Illuminate\Support\Facades\Storage::disk('public')->exists($path)) { + if (Illuminate\Support\Facades\Storage::disk('public')->exists($path)) { return $path; } } diff --git a/resources/views/livewire/plugins/image-webhook.blade.php b/resources/views/livewire/plugins/image-webhook.blade.php index 788cbdb..c2db714 100644 --- a/resources/views/livewire/plugins/image-webhook.blade.php +++ b/resources/views/livewire/plugins/image-webhook.blade.php @@ -1,11 +1,13 @@ - ['name' => 'Markup', 'flux_icon_name' => 'code-bracket', 'detail_view_route' => 'plugins.markup'], - 'api' => - ['name' => 'API', 'flux_icon_name' => 'braces', 'detail_view_route' => 'plugins.api'], - 'image-webhook' => - ['name' => 'Image Webhook', 'flux_icon_name' => 'photo', 'detail_view_route' => 'plugins.image-webhook'], + 'markup' => ['name' => 'Markup', 'flux_icon_name' => 'code-bracket', 'detail_view_route' => 'plugins.markup'], + 'api' => ['name' => 'API', 'flux_icon_name' => 'braces', 'detail_view_route' => 'plugins.api'], + 'image-webhook' => ['name' => 'Image Webhook', 'flux_icon_name' => 'photo', 'detail_view_route' => 'plugins.image-webhook'], ]; protected $rules = [ @@ -60,29 +66,31 @@ new class extends Component { switch ($this->sortBy) { case 'name_asc': - usort($pluginsToSort, function($a, $b) { + usort($pluginsToSort, function ($a, $b) { return strcasecmp($a['name'] ?? '', $b['name'] ?? ''); }); break; case 'name_desc': - usort($pluginsToSort, function($a, $b) { + usort($pluginsToSort, function ($a, $b) { return strcasecmp($b['name'] ?? '', $a['name'] ?? ''); }); break; case 'date_desc': - usort($pluginsToSort, function($a, $b) { + usort($pluginsToSort, function ($a, $b) { $aDate = $a['created_at'] ?? '1970-01-01'; $bDate = $b['created_at'] ?? '1970-01-01'; + return strcmp($bDate, $aDate); }); break; case 'date_asc': - usort($pluginsToSort, function($a, $b) { + usort($pluginsToSort, function ($a, $b) { $aDate = $a['created_at'] ?? '1970-01-01'; $bDate = $b['created_at'] ?? '1970-01-01'; + return strcmp($aDate, $bDate); }); break; @@ -113,7 +121,7 @@ new class extends Component { abort_unless(auth()->user() !== null, 403); $this->validate(); - \App\Models\Plugin::create([ + App\Models\Plugin::create([ 'uuid' => Str::uuid(), 'user_id' => auth()->id(), 'name' => $this->name, @@ -137,7 +145,6 @@ new class extends Component { $this->refreshPlugins(); } - public function importZip(PluginImportService $pluginImportService): void { abort_unless(auth()->user() !== null, 403); @@ -153,11 +160,10 @@ new class extends Component { $this->reset(['zipFile']); Flux::modal('import-zip')->close(); - } catch (\Exception $e) { - $this->addError('zipFile', 'Error installing plugin: ' . $e->getMessage()); + } catch (Exception $e) { + $this->addError('zipFile', 'Error installing plugin: '.$e->getMessage()); } } - }; ?> diff --git a/resources/views/livewire/plugins/markup.blade.php b/resources/views/livewire/plugins/markup.blade.php index e78f137..150e626 100644 --- a/resources/views/livewire/plugins/markup.blade.php +++ b/resources/views/livewire/plugins/markup.blade.php @@ -4,12 +4,14 @@ use App\Jobs\GenerateScreenJob; use Illuminate\Support\Collection; use Livewire\Component; -new class extends Component { - +new class extends Component +{ public string $blade_code = ''; + public bool $isLoading = false; public Collection $devices; + public array $checked_devices; public function mount() @@ -17,17 +19,16 @@ new class extends Component { $this->devices = auth()->user()->devices->pluck('id', 'name'); } - public function submit() { $this->isLoading = true; $this->validate([ 'checked_devices' => 'required|array', - 'blade_code' => 'required|string' + 'blade_code' => 'required|string', ]); - //only devices that are owned by the user + // only devices that are owned by the user $this->checked_devices = array_intersect($this->checked_devices, auth()->user()->devices->pluck('id')->toArray()); try { @@ -35,7 +36,7 @@ new class extends Component { foreach ($this->checked_devices as $device) { GenerateScreenJob::dispatchSync($device, null, $rendered); } - } catch (\Exception $e) { + } catch (Exception $e) { $this->addError('generate_screen', $e->getMessage()); } @@ -66,7 +67,7 @@ new class extends Component { public function renderHelloWorld(): string { - return << @@ -84,7 +85,7 @@ HTML; public function renderQuote(): string { - return << @@ -102,7 +103,7 @@ HTML; public function renderTrainMonitor() { - return << @@ -136,7 +137,7 @@ HTML; public function renderHomeAssistant() { - return << @@ -162,8 +163,6 @@ HTML; HTML; } - - }; ?> diff --git a/resources/views/livewire/plugins/recipe.blade.php b/resources/views/livewire/plugins/recipe.blade.php index 6e13dfb..cda019e 100644 --- a/resources/views/livewire/plugins/recipe.blade.php +++ b/resources/views/livewire/plugins/recipe.blade.php @@ -1,44 +1,68 @@ plugin->render_markup_view) { try { - $basePath = resource_path('views/' . str_replace('.', '/', $this->plugin->render_markup_view)); + $basePath = resource_path('views/'.str_replace('.', '/', $this->plugin->render_markup_view)); $paths = [ - $basePath . '.blade.php', - $basePath . '.liquid', + $basePath.'.blade.php', + $basePath.'.liquid', ]; $this->view_content = null; @@ -63,7 +87,7 @@ new class extends Component { break; } } - } catch (\Exception $e) { + } catch (Exception $e) { $this->view_content = null; } } else { @@ -103,7 +127,7 @@ new class extends Component { $this->validate(); $this->plugin->update([ 'render_markup' => $this->markup_code ?? null, - 'markup_language' => $this->markup_language ?? null + 'markup_language' => $this->markup_language ?? null, ]); } @@ -136,7 +160,7 @@ new class extends Component { $this->validatePollingUrl(); $validated = $this->validate(); - $validated['data_payload'] = json_decode(Arr::get($validated,'data_payload'), true); + $validated['data_payload'] = json_decode(Arr::get($validated, 'data_payload'), true); $this->plugin->update($validated); foreach ($this->configuration_template as $fieldKey => $field) { @@ -144,7 +168,7 @@ new class extends Component { continue; } - if (!isset($this->multiValues[$fieldKey])) { + if (! isset($this->multiValues[$fieldKey])) { continue; } @@ -155,15 +179,15 @@ new class extends Component { protected function validatePollingUrl(): void { - if ($this->data_strategy === 'polling' && !empty($this->polling_url)) { + if ($this->data_strategy === 'polling' && ! empty($this->polling_url)) { try { $resolvedUrl = $this->plugin->resolveLiquidVariables($this->polling_url); - if (!filter_var($resolvedUrl, FILTER_VALIDATE_URL)) { + if (! filter_var($resolvedUrl, FILTER_VALIDATE_URL)) { $this->addError('polling_url', 'The polling URL must be a valid URL after resolving configuration variables.'); } - } catch (\Exception $e) { - $this->addError('polling_url', 'Error resolving Liquid variables: ' . $e->getMessage() . $e->getPrevious()?->getMessage()); + } catch (Exception $e) { + $this->addError('polling_url', 'Error resolving Liquid variables: '.$e->getMessage().$e->getPrevious()?->getMessage()); } } } @@ -177,8 +201,8 @@ new class extends Component { $this->data_payload = json_encode($this->plugin->data_payload, JSON_PRETTY_PRINT); $this->data_payload_updated_at = $this->plugin->data_payload_updated_at; - } catch (\Exception $e) { - $this->dispatch('data-update-error', message: $e->getMessage() . $e->getPrevious()?->getMessage()); + } catch (Exception $e) { + $this->dispatch('data-update-error', message: $e->getMessage().$e->getPrevious()?->getMessage()); } } } @@ -212,15 +236,17 @@ new class extends Component { // Validate that each checked device has a playlist selected foreach ($this->checked_devices as $deviceId) { - if (!isset($this->device_playlists[$deviceId]) || empty($this->device_playlists[$deviceId])) { - $this->addError('device_playlists.' . $deviceId, 'Please select a playlist for each device.'); + if (! isset($this->device_playlists[$deviceId]) || empty($this->device_playlists[$deviceId])) { + $this->addError('device_playlists.'.$deviceId, 'Please select a playlist for each device.'); + return; } // If creating new playlist, validate required fields if ($this->device_playlists[$deviceId] === 'new') { - if (!isset($this->device_playlist_names[$deviceId]) || empty($this->device_playlist_names[$deviceId])) { - $this->addError('device_playlist_names.' . $deviceId, 'Playlist name is required when creating a new playlist.'); + if (! isset($this->device_playlist_names[$deviceId]) || empty($this->device_playlist_names[$deviceId])) { + $this->addError('device_playlist_names.'.$deviceId, 'Playlist name is required when creating a new playlist.'); + return; } } @@ -231,15 +257,15 @@ new class extends Component { if ($this->device_playlists[$deviceId] === 'new') { // Create new playlist - $playlist = \App\Models\Playlist::create([ + $playlist = App\Models\Playlist::create([ 'device_id' => $deviceId, 'name' => $this->device_playlist_names[$deviceId], - 'weekdays' => !empty($this->device_weekdays[$deviceId] ?? null) ? $this->device_weekdays[$deviceId] : null, + 'weekdays' => ! empty($this->device_weekdays[$deviceId] ?? null) ? $this->device_weekdays[$deviceId] : null, 'active_from' => $this->device_active_from[$deviceId] ?? null, 'active_until' => $this->device_active_until[$deviceId] ?? null, ]); } else { - $playlist = \App\Models\Playlist::findOrFail($this->device_playlists[$deviceId]); + $playlist = App\Models\Playlist::findOrFail($this->device_playlists[$deviceId]); } // Add plugin to playlist @@ -253,11 +279,11 @@ new class extends Component { } else { // Create mashup $pluginIds = array_merge([$this->plugin->id], array_map('intval', $this->mashup_plugins)); - \App\Models\PlaylistItem::createMashup( + App\Models\PlaylistItem::createMashup( $playlist, $this->mashup_layout, $pluginIds, - $this->plugin->name . ' Mashup', + $this->plugin->name.' Mashup', $maxOrder + 1 ); } @@ -271,23 +297,24 @@ new class extends Component { 'device_active_from', 'device_active_until', 'mashup_layout', - 'mashup_plugins' + 'mashup_plugins', ]); Flux::modal('add-to-playlist')->close(); } public function getDevicePlaylists($deviceId) { - return \App\Models\Playlist::where('device_id', $deviceId)->get(); + return App\Models\Playlist::where('device_id', $deviceId)->get(); } public function hasAnyPlaylistSelected(): bool { foreach ($this->checked_devices as $deviceId) { - if (isset($this->device_playlists[$deviceId]) && !empty($this->device_playlists[$deviceId])) { + if (isset($this->device_playlists[$deviceId]) && ! empty($this->device_playlists[$deviceId])) { return true; } } + return false; } @@ -315,7 +342,7 @@ new class extends Component { public function renderLayoutWithTitleBar(): string { if ($this->markup_language === 'liquid') { - return <<
@@ -327,9 +354,9 @@ new class extends Component { HTML; } - return << 'full']) - + @@ -341,7 +368,7 @@ HTML; public function renderLayoutBlank(): string { if ($this->markup_language === 'liquid') { - return <<
@@ -350,9 +377,9 @@ HTML; HTML; } - return << 'full']) - + @@ -378,12 +405,12 @@ HTML; $this->dispatch('preview-updated', preview: $previewMarkup); } catch (LiquidException $e) { $this->dispatch('preview-error', message: $e->toLiquidErrorMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->dispatch('preview-error', message: $e->getMessage()); } } - private function createPreviewDevice(): \App\Models\Device + private function createPreviewDevice(): Device { $deviceModel = DeviceModel::with(['palette'])->find($this->preview_device_model_id) ?? DeviceModel::with(['palette'])->first(); @@ -434,18 +461,17 @@ HTML; #[Computed] private function parsedUrls() { - if (!isset($this->polling_url)) { + if (! isset($this->polling_url)) { return null; } try { return $this->plugin->resolveLiquidVariables($this->polling_url); - } catch (\Exception $e) { - return 'PARSE_ERROR: ' . $e->getMessage(); + } catch (Exception $e) { + return 'PARSE_ERROR: '.$e->getMessage(); } } - } ?> diff --git a/resources/views/livewire/plugins/recipes/settings.blade.php b/resources/views/livewire/plugins/recipes/settings.blade.php index e87ad78..c83f52c 100644 --- a/resources/views/livewire/plugins/recipes/settings.blade.php +++ b/resources/views/livewire/plugins/recipes/settings.blade.php @@ -7,10 +7,14 @@ use Livewire\Component; /* * This component contains the TRMNL Plugin Settings modal */ -new class extends Component { +new class extends Component +{ public Plugin $plugin; - public string|null $trmnlp_id = null; - public string|null $uuid = null; + + public ?string $trmnlp_id = null; + + public ?string $uuid = null; + public bool $alias = false; public int $resetIndex = 0; @@ -53,7 +57,7 @@ new class extends Component { { return url("/api/display/{$this->uuid}/alias"); } -};?> +}; ?>
diff --git a/resources/views/livewire/settings/appearance.blade.php b/resources/views/livewire/settings/appearance.blade.php index af056b0..145319d 100644 --- a/resources/views/livewire/settings/appearance.blade.php +++ b/resources/views/livewire/settings/appearance.blade.php @@ -2,7 +2,8 @@ use Livewire\Component; -new class extends Component { +new class extends Component +{ // }; ?> diff --git a/resources/views/livewire/settings/delete-user-form.blade.php b/resources/views/livewire/settings/delete-user-form.blade.php index 634f65b..8eed52b 100644 --- a/resources/views/livewire/settings/delete-user-form.blade.php +++ b/resources/views/livewire/settings/delete-user-form.blade.php @@ -4,7 +4,8 @@ use App\Livewire\Actions\Logout; use Illuminate\Support\Facades\Auth; use Livewire\Component; -new class extends Component { +new class extends Component +{ public string $password = ''; /** diff --git a/resources/views/livewire/settings/password.blade.php b/resources/views/livewire/settings/password.blade.php index 99b255f..fe0ef0b 100644 --- a/resources/views/livewire/settings/password.blade.php +++ b/resources/views/livewire/settings/password.blade.php @@ -6,9 +6,12 @@ use Illuminate\Validation\Rules\Password; use Illuminate\Validation\ValidationException; use Livewire\Component; -new class extends Component { +new class extends Component +{ public string $current_password = ''; + public string $password = ''; + public string $password_confirmation = ''; /** diff --git a/resources/views/livewire/settings/preferences.blade.php b/resources/views/livewire/settings/preferences.blade.php index 4d9f221..83b62a2 100644 --- a/resources/views/livewire/settings/preferences.blade.php +++ b/resources/views/livewire/settings/preferences.blade.php @@ -1,14 +1,11 @@ ignore($user->id) + Rule::unique(User::class)->ignore($user->id), ], ]); diff --git a/resources/views/livewire/settings/support.blade.php b/resources/views/livewire/settings/support.blade.php index 5c54e22..63d6a42 100644 --- a/resources/views/livewire/settings/support.blade.php +++ b/resources/views/livewire/settings/support.blade.php @@ -1,6 +1,7 @@
diff --git a/tests/Feature/Api/ImageWebhookTest.php b/tests/Feature/Api/ImageWebhookTest.php index 121f90a..545dae8 100644 --- a/tests/Feature/Api/ImageWebhookTest.php +++ b/tests/Feature/Api/ImageWebhookTest.php @@ -38,7 +38,7 @@ test('can upload image to image webhook plugin via multipart form', function (): // File should exist with the new UUID Storage::disk('public')->assertExists("images/generated/{$plugin->current_image}.png"); - + // Image URL should contain the new UUID expect($response->json('image_url')) ->toContain($plugin->current_image); @@ -70,7 +70,7 @@ test('can upload image to image webhook plugin via raw binary', function (): voi // File should exist with the new UUID Storage::disk('public')->assertExists("images/generated/{$plugin->current_image}.png"); - + // Image URL should contain the new UUID expect($response->json('image_url')) ->toContain($plugin->current_image); @@ -102,7 +102,7 @@ test('can upload image to image webhook plugin via base64 data URI', function () // File should exist with the new UUID Storage::disk('public')->assertExists("images/generated/{$plugin->current_image}.png"); - + // Image URL should contain the new UUID expect($response->json('image_url')) ->toContain($plugin->current_image); diff --git a/tests/Feature/Livewire/Plugins/ConfigModalTest.php b/tests/Feature/Livewire/Plugins/ConfigModalTest.php index 0807d8e..517d130 100644 --- a/tests/Feature/Livewire/Plugins/ConfigModalTest.php +++ b/tests/Feature/Livewire/Plugins/ConfigModalTest.php @@ -22,9 +22,9 @@ test('config modal correctly loads multi_string defaults into UI boxes', functio 'field_type' => 'multi_string', 'name' => 'Reading Days', 'default' => 'alpha,beta', - ]] + ]], ], - 'configuration' => ['tags' => 'alpha,beta'] + 'configuration' => ['tags' => 'alpha,beta'], ]); Livewire::test('plugins.config-modal', ['plugin' => $plugin]) @@ -45,8 +45,8 @@ test('config modal validates against commas in multi_string boxes', function (): 'keyname' => 'tags', 'field_type' => 'multi_string', 'name' => 'Reading Days', - ]] - ] + ]], + ], ]); Livewire::test('plugins.config-modal', ['plugin' => $plugin]) @@ -72,9 +72,9 @@ test('config modal merges multi_string boxes into a single CSV string on save', 'keyname' => 'items', 'field_type' => 'multi_string', 'name' => 'Reading Days', - ]] + ]], ], - 'configuration' => [] + 'configuration' => [], ]); Livewire::test('plugins.config-modal', ['plugin' => $plugin]) @@ -96,7 +96,7 @@ test('config modal resetForm clears dirty state and increments resetIndex', func 'user_id' => $user->id, 'name' => 'Test Plugin', 'data_strategy' => 'static', - 'configuration' => ['simple_key' => 'original_value'] + 'configuration' => ['simple_key' => 'original_value'], ]); Livewire::test('plugins.config-modal', ['plugin' => $plugin]) @@ -114,7 +114,7 @@ test('config modal dispatches update event for parent warning refresh', function 'uuid' => Str::uuid(), 'user_id' => $user->id, 'name' => 'Test Plugin', - 'data_strategy' => 'static' + 'data_strategy' => 'static', ]); Livewire::test('plugins.config-modal', ['plugin' => $plugin])