chore: pint

This commit is contained in:
Benjamin Nussbaum 2026-01-15 09:01:59 +01:00
parent a15645ad88
commit d19a079b8a
30 changed files with 295 additions and 188 deletions

View file

@ -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));
}

View file

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

View file

@ -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'));
}
}