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])