user()->devices->contains($device), 403); $current_image_uuid = $device->current_screen_image; $current_image_path = 'images/generated/' . $current_image_uuid . '.png'; $this->device = $device; $this->name = $device->name; $this->api_key = $device->api_key; $this->friendly_id = $device->friendly_id; $this->mac_address = $device->mac_address; $this->default_refresh_interval = $device->default_refresh_interval; $this->width = $device->width; $this->height = $device->height; $this->rotate = $device->rotate; $this->image_format = $device->image_format; $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->selected_firmware_id = $this->firmwares->where('latest', true)->first()?->id; return view('livewire.devices.configure', [ 'image' => ($current_image_uuid) ? url($current_image_path) : null, ]); } public function deleteDevice(\App\Models\Device $device) { abort_unless(auth()->user()->devices->contains($device), 403); $device->delete(); redirect()->route('devices'); } public function updateDevice() { abort_unless(auth()->user()->devices->contains($this->device), 403); $this->validate([ 'name' => 'required|string|max:255', 'friendly_id' => 'required|string|max:255', 'mac_address' => 'required|string|max:255', 'default_refresh_interval' => 'required|integer|min:1', 'width' => 'required|integer|min:1', 'height' => 'required|integer|min:1', 'rotate' => 'required|integer|min:0|max:359', 'image_format' => 'required|string', ]); $this->device->update([ 'name' => $this->name, 'friendly_id' => $this->friendly_id, 'mac_address' => $this->mac_address, 'default_refresh_interval' => $this->default_refresh_interval, 'width' => $this->width, 'height' => $this->height, 'rotate' => $this->rotate, 'image_format' => $this->image_format, ]); Flux::modal('edit-device')->close(); } public function createPlaylist() { $this->validate([ 'playlist_name' => 'required|string|max:255', 'selected_weekdays' => 'nullable|array', 'active_from' => 'nullable|date_format:H:i', 'active_until' => 'nullable|date_format:H:i', 'refresh_time' => 'nullable|integer|min:60', ]); if ($this->refresh_time < 60) { $this->refresh_time = null; } if (empty($this->selected_weekdays)){ $this->selected_weekdays = null; } $this->device->playlists()->create([ 'name' => $this->playlist_name, 'weekdays' => $this->selected_weekdays, 'active_from' => $this->active_from, 'active_until' => $this->active_until, 'refresh_time' => $this->refresh_time, 'is_active' => true, ]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); $this->reset(['playlist_name', 'selected_weekdays', 'active_from', 'active_until']); Flux::modal('create-playlist')->close(); } public function togglePlaylistActive(Playlist $playlist) { $playlist->update(['is_active' => !$playlist->is_active]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); } public function movePlaylistItemUp(PlaylistItem $item) { $previousItem = $item->playlist->items() ->where('order', '<', $item->order) ->orderBy('order', 'desc') ->first(); if ($previousItem) { $tempOrder = $previousItem->order; $previousItem->update(['order' => $item->order]); $item->update(['order' => $tempOrder]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); } } public function movePlaylistItemDown(PlaylistItem $item) { $nextItem = $item->playlist->items() ->where('order', '>', $item->order) ->orderBy('order') ->first(); if ($nextItem) { $tempOrder = $nextItem->order; $nextItem->update(['order' => $item->order]); $item->update(['order' => $tempOrder]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); } } public function togglePlaylistItemActive(PlaylistItem $item) { $item->update(['is_active' => !$item->is_active]); $this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get(); } public function deletePlaylist(Playlist $playlist) { 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(); } public function deletePlaylistItem(PlaylistItem $item) { 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(); } public function editPlaylist(Playlist $playlist) { $this->validate([ 'playlist_name' => 'required|string|max:255', 'selected_weekdays' => 'nullable|array', 'active_from' => 'nullable|date_format:H:i', 'active_until' => 'nullable|date_format:H:i', 'refresh_time' => 'nullable|integer|min:60', ]); if ($this->refresh_time < 60) { $this->refresh_time = null; } if (empty($this->selected_weekdays)){ $this->selected_weekdays = null; } $playlist->update([ 'name' => $this->playlist_name, 'weekdays' => $this->selected_weekdays, 'active_from' => $this->active_from, 'active_until' => $this->active_until, 'refresh_time' => $this->refresh_time, ]); $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(); } public function preparePlaylistEdit(Playlist $playlist) { $this->playlist_name = $playlist->name; $this->selected_weekdays = $playlist->weekdays ?? null; $this->active_from = optional($playlist->active_from)->format('H:i'); $this->active_until = optional($playlist->active_until)->format('H:i'); $this->refresh_time = $playlist->refresh_time; } public function updateFirmware() { abort_unless(auth()->user()->devices->contains($this->device), 403); $this->validate([ 'selected_firmware_id' => 'required|exists:firmware,id', ]); if ($this->download_firmware) { FirmwareDownloadJob::dispatchSync(Firmware::find($this->selected_firmware_id)); } $this->device->update([ 'update_firmware_id' => $this->selected_firmware_id, ]); Flux::modal('update-firmware')->close(); } } ?>
@php $current_image_uuid =$device->current_screen_image; if($current_image_uuid) { $file_extension = file_exists(storage_path('app/public/images/generated/' . $current_image_uuid . '.png')) ? 'png' : 'bmp'; $current_image_path = 'storage/images/generated/' . $current_image_uuid . '.' . $file_extension; } else { $current_image_path = 'storage/images/setup-logo.bmp'; } @endphp

{{ $device->name }}

{{$device->updated_at->diffForHumans()}} {{$device->mac_address}} @if($device->last_firmware_version) {{$device->last_firmware_version}} @endif @if($device->wifiStrength) @endif @if($device->batteryPercent) @endif
Update Firmware Show Logs Delete Device
Edit TRMNL
@foreach(\App\Enums\ImageFormat::cases() as $format) {{$format->label()}} @endforeach
Save changes
Update Firmware Select a firmware version to update to
@foreach($firmwares as $firmware) {{ $firmware->version_tag }} {{ $firmware->latest ? '(Latest)' : '' }} @endforeach
Check if the Device has no internet connection.
Update Firmware
Delete {{$device->name}}?
Cancel Delete device
@if(!$device->mirror_device_id) @if($current_image_path) Next Image @endif

Device Playlists

Create Playlist
@else
This device is mirrored from {{ $device->mirrorDevice->name }}
@endif
Create Playlist
Create Playlist
@foreach($playlists as $playlist)

{{ $playlist->name }}

@if($playlist->weekdays) {{ implode(', ', collect($playlist->weekdays)->map(fn($day) => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][$day])->toArray()) }} @endif @if($playlist->active_from && $playlist->active_until) {{ $playlist->active_from->format('H:i') }} - {{ $playlist->active_until->format('H:i') }} @endif
Edit Playlist
Save Changes
Delete {{ $playlist->name }}?

This will permanently delete this playlist and all its items.

Cancel Delete playlist
@foreach($playlist->items->sortBy('order') as $item) @endforeach
Plugin
Status
Actions
{{ $item->plugin->name }}
@if(!$loop->first) @endif @if(!$loop->last) @endif
Delete {{ $item->plugin->name }}?

This will remove this item from the playlist.

Cancel Delete item
@endforeach