diff --git a/resources/views/livewire/devices/configure.blade.php b/resources/views/livewire/devices/configure.blade.php index 7a90456..ccb0cae 100644 --- a/resources/views/livewire/devices/configure.blade.php +++ b/resources/views/livewire/devices/configure.blade.php @@ -20,6 +20,7 @@ new class extends Component { public $selected_weekdays = null; public $active_from; public $active_until; + public $refresh_time = null; public function mount(\App\Models\Device $device) { @@ -77,13 +78,23 @@ new class extends Component { '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, ]); @@ -154,29 +165,40 @@ new class extends Component { { $this->validate([ 'playlist_name' => 'required|string|max:255', - 'selected_weekdays' => 'array', + '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']); + $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 ?? []; + $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; } } ?> @@ -323,6 +345,10 @@ new class extends Component { +
+ +
+
Create Playlist @@ -392,6 +418,10 @@ new class extends Component {
+
+ +
+
Save Changes diff --git a/resources/views/livewire/plugins/receipt.blade.php b/resources/views/livewire/plugins/receipt.blade.php index f3acbda..734dd12 100644 --- a/resources/views/livewire/plugins/receipt.blade.php +++ b/resources/views/livewire/plugins/receipt.blade.php @@ -212,7 +212,7 @@ HTML; - Delete Plugin + Delete Plugin