mirror of
https://github.com/usetrmnl/larapaper.git
synced 2026-08-13 14:28:54 -07:00
chore: pint
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
?>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user