mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-16 16:37:47 +00:00
chore: pint
This commit is contained in:
parent
a15645ad88
commit
d19a079b8a
30 changed files with 295 additions and 188 deletions
|
|
@ -4,7 +4,7 @@
|
|||
'heading' => null,
|
||||
])
|
||||
|
||||
<?php if ($expandable && $heading): ?>
|
||||
<?php if ($expandable && $heading) { ?>
|
||||
|
||||
<ui-disclosure
|
||||
{{ $attributes->class('group/disclosure') }}
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
</div>
|
||||
</ui-disclosure>
|
||||
|
||||
<?php elseif ($heading): ?>
|
||||
<?php } elseif ($heading) { ?>
|
||||
|
||||
<div {{ $attributes->class('block space-y-[2px]') }}>
|
||||
<div class="px-1 py-2">
|
||||
|
|
@ -42,10 +42,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
|
||||
<div {{ $attributes->class('block space-y-[2px]') }}>
|
||||
{{ $slot }}
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
<?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 = '';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 = '';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()],
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
<?php
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\Modelable;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component
|
||||
{
|
||||
#[Modelable]
|
||||
public $model = '';
|
||||
|
||||
public $language = 'html';
|
||||
|
||||
public $theme = 'auto';
|
||||
|
||||
public $readonly = false;
|
||||
|
||||
public $placeholder = '';
|
||||
|
||||
public $height = '200px';
|
||||
|
||||
public $id = '';
|
||||
|
||||
public function mount($language = 'html', $theme = 'auto', $readonly = false, $placeholder = '', $height = '200px', $id = '')
|
||||
|
|
@ -24,7 +30,6 @@ new class extends Component
|
|||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function toJSON()
|
||||
{
|
||||
return json_encode([
|
||||
|
|
|
|||
|
|
@ -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)]);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\DeviceLog;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public Device $device;
|
||||
|
||||
public $logs;
|
||||
|
||||
public function mount(Device $device)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use App\Models\Device;
|
|||
use App\Models\DeviceModel;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
|
||||
new class extends Component
|
||||
{
|
||||
public $devices;
|
||||
|
||||
public $showDeviceForm = false;
|
||||
|
|
@ -23,7 +23,9 @@ new class extends Component {
|
|||
public $is_mirror = false;
|
||||
|
||||
public $mirror_device_id = null;
|
||||
|
||||
public $device_model_id = null;
|
||||
|
||||
public $deviceModels;
|
||||
|
||||
public ?int $pause_duration;
|
||||
|
|
@ -42,8 +44,10 @@ 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;
|
||||
});
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +1,37 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Playlist;
|
||||
use App\Models\PlaylistItem;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public $devices;
|
||||
|
||||
public $playlists;
|
||||
|
||||
// Playlist form properties
|
||||
public $playlist_name;
|
||||
|
||||
public $selected_weekdays = null;
|
||||
|
||||
public $active_from;
|
||||
|
||||
public $active_until;
|
||||
|
||||
public $refresh_time = null;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->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)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public $token;
|
||||
|
||||
public $devices;
|
||||
|
||||
public $selected_device;
|
||||
|
||||
public function mount(): void
|
||||
|
|
|
|||
|
|
@ -1,26 +1,30 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Plugin;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Component;
|
||||
|
||||
/*
|
||||
* This component contains the configuation modal
|
||||
*/
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public Plugin $plugin;
|
||||
|
||||
public array $configuration_template = [];
|
||||
|
||||
public array $configuration = []; // holds config data
|
||||
|
||||
public array $multiValues = []; // UI boxes for multi_string
|
||||
|
||||
public array $xhrSelectOptions = [];
|
||||
|
||||
public array $searchQueries = [];
|
||||
|
||||
// ------------------------------------This section contains one-off functions for the form------------------------------------------------
|
||||
public function mount(): void
|
||||
{
|
||||
$this -> 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);
|
||||
}
|
||||
}
|
||||
};?>
|
||||
}; ?>
|
||||
|
||||
<flux:modal name="configuration-modal" @close="resetForm" class="md:w-96">
|
||||
<div wire:key="config-form-{{ $resetIndex }}" class="space-y-6">
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Plugin;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public string $name = '';
|
||||
|
||||
public array $instances = [];
|
||||
|
||||
protected $rules = [
|
||||
|
|
|
|||
|
|
@ -2,32 +2,38 @@
|
|||
|
||||
use App\Console\Commands\ExampleRecipesSeederCommand;
|
||||
use App\Services\PluginImportService;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public string $name;
|
||||
|
||||
public int $data_stale_minutes = 60;
|
||||
public string $data_strategy = "polling";
|
||||
|
||||
public string $data_strategy = 'polling';
|
||||
|
||||
public string $polling_url;
|
||||
public string $polling_verb = "get";
|
||||
|
||||
public string $polling_verb = 'get';
|
||||
|
||||
public $polling_header;
|
||||
|
||||
public $polling_body;
|
||||
|
||||
public array $plugins;
|
||||
|
||||
public $zipFile;
|
||||
|
||||
public string $sortBy = 'date_asc';
|
||||
|
||||
public array $native_plugins = [
|
||||
'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'],
|
||||
'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());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <<<HTML
|
||||
return <<<'HTML'
|
||||
<x-trmnl::screen>
|
||||
<x-trmnl::view>
|
||||
<x-trmnl::layout>
|
||||
|
|
@ -84,7 +85,7 @@ HTML;
|
|||
|
||||
public function renderQuote(): string
|
||||
{
|
||||
return <<<HTML
|
||||
return <<<'HTML'
|
||||
<x-trmnl::screen>
|
||||
<x-trmnl::view>
|
||||
<x-trmnl::layout>
|
||||
|
|
@ -102,7 +103,7 @@ HTML;
|
|||
|
||||
public function renderTrainMonitor()
|
||||
{
|
||||
return <<<HTML
|
||||
return <<<'HTML'
|
||||
<x-trmnl::screen>
|
||||
<x-trmnl::view>
|
||||
<x-trmnl::layout>
|
||||
|
|
@ -136,7 +137,7 @@ HTML;
|
|||
|
||||
public function renderHomeAssistant()
|
||||
{
|
||||
return <<<HTML
|
||||
return <<<'HTML'
|
||||
<x-trmnl::screen>
|
||||
<x-trmnl::view>
|
||||
<x-trmnl::layout class="layout--col gap--space-between">
|
||||
|
|
@ -162,8 +163,6 @@ HTML;
|
|||
HTML;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,44 +1,68 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Plugin;
|
||||
use App\Models\DeviceModel;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Keepsuit\Liquid\Exceptions\LiquidException;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use App\Models\Plugin;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Attributes\On;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Keepsuit\Liquid\Exceptions\LiquidException;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public Plugin $plugin;
|
||||
public string|null $markup_code;
|
||||
public string|null $view_content;
|
||||
public string|null $markup_language;
|
||||
|
||||
public ?string $markup_code;
|
||||
|
||||
public ?string $view_content;
|
||||
|
||||
public ?string $markup_language;
|
||||
|
||||
public string $name;
|
||||
|
||||
public bool $no_bleed = false;
|
||||
|
||||
public bool $dark_mode = false;
|
||||
|
||||
public int $data_stale_minutes;
|
||||
|
||||
public string $data_strategy;
|
||||
public string|null $polling_url;
|
||||
|
||||
public ?string $polling_url;
|
||||
|
||||
public string $polling_verb;
|
||||
public string|null $polling_header;
|
||||
public string|null $polling_body;
|
||||
|
||||
public ?string $polling_header;
|
||||
|
||||
public ?string $polling_body;
|
||||
|
||||
public $data_payload;
|
||||
|
||||
public ?Carbon $data_payload_updated_at;
|
||||
|
||||
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 string $mashup_layout = 'full';
|
||||
|
||||
public array $mashup_plugins = [];
|
||||
|
||||
public array $configuration_template = [];
|
||||
|
||||
public ?int $preview_device_model_id = null;
|
||||
|
||||
public string $preview_size = 'full';
|
||||
|
||||
public function mount(): void
|
||||
|
|
@ -50,10 +74,10 @@ new class extends Component {
|
|||
|
||||
if ($this->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 <<<HTML
|
||||
return <<<'HTML'
|
||||
<div class="view view--{{ size }}">
|
||||
<div class="layout">
|
||||
<!-- ADD YOUR CONTENT HERE-->
|
||||
|
|
@ -327,9 +354,9 @@ new class extends Component {
|
|||
HTML;
|
||||
}
|
||||
|
||||
return <<<HTML
|
||||
return <<<'HTML'
|
||||
@props(['size' => 'full'])
|
||||
<x-trmnl::view size="{{\$size}}">
|
||||
<x-trmnl::view size="{{$size}}">
|
||||
<x-trmnl::layout>
|
||||
<!-- ADD YOUR CONTENT HERE-->
|
||||
</x-trmnl::layout>
|
||||
|
|
@ -341,7 +368,7 @@ HTML;
|
|||
public function renderLayoutBlank(): string
|
||||
{
|
||||
if ($this->markup_language === 'liquid') {
|
||||
return <<<HTML
|
||||
return <<<'HTML'
|
||||
<div class="view view--{{ size }}">
|
||||
<div class="layout">
|
||||
<!-- ADD YOUR CONTENT HERE-->
|
||||
|
|
@ -350,9 +377,9 @@ HTML;
|
|||
HTML;
|
||||
}
|
||||
|
||||
return <<<HTML
|
||||
return <<<'HTML'
|
||||
@props(['size' => 'full'])
|
||||
<x-trmnl::view size="{{\$size}}">
|
||||
<x-trmnl::view size="{{$size}}">
|
||||
<x-trmnl::layout>
|
||||
<!-- ADD YOUR CONTENT HERE-->
|
||||
</x-trmnl::layout>
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
};?>
|
||||
}; ?>
|
||||
|
||||
<flux:modal name="trmnlp-settings" class="min-w-[400px] space-y-6">
|
||||
<div wire:key="trmnlp-settings-form-{{ $resetIndex }}" class="space-y-6">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
//
|
||||
}; ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = '';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 = '';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Device;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public ?int $assign_new_device_id = null;
|
||||
|
||||
public ?string $timezone = null;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ use Illuminate\Support\Facades\Session;
|
|||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
new class extends Component
|
||||
{
|
||||
public string $name = '';
|
||||
|
||||
public string $email = '';
|
||||
|
||||
/**
|
||||
|
|
@ -35,7 +37,7 @@ new class extends Component {
|
|||
'lowercase',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique(User::class)->ignore($user->id)
|
||||
Rule::unique(User::class)->ignore($user->id),
|
||||
],
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
use Livewire\Component;
|
||||
new class extends Component {}
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {}
|
||||
?>
|
||||
|
||||
<section class="w-full">
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue