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(); } } ?>
This will permanently delete this playlist and all its items.
|
Plugin
|
Status
|
Actions
|
|---|---|---|
|
@if($item->isMashup())
{{ $item->getMashupName() }}
{{ $item->plugin->name }}
@endif
|
|
@if(!$loop->first)
This will remove this item from the playlist. |