From c0fe31da9e8921a50ff34cf817e0eb59ff94955c Mon Sep 17 00:00:00 2001 From: Benjamin Nussbaum Date: Thu, 6 Mar 2025 09:21:33 +0100 Subject: [PATCH] feat: added device edit popover wip --- .../livewire/devices/configure.blade.php | 96 ++++++++++++++----- 1 file changed, 70 insertions(+), 26 deletions(-) diff --git a/resources/views/livewire/devices/configure.blade.php b/resources/views/livewire/devices/configure.blade.php index 583b725..18ba84f 100644 --- a/resources/views/livewire/devices/configure.blade.php +++ b/resources/views/livewire/devices/configure.blade.php @@ -6,6 +6,12 @@ new class extends Component { public $device; + public $name; + public $api_key; + public $friendly_id; + public $mac_address; + public $default_refresh_interval; + public function mount(\App\Models\Device $device) { abort_unless(auth()->user()->devices->contains($device), 403); @@ -13,7 +19,13 @@ new class extends Component { $current_image_uuid = $device->current_screen_image; $current_image_path = 'images/generated/' . $current_image_uuid . '.png'; - return view('livewire.devices.configure', compact('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; + + return view('livewire.devices.configure', [ 'image' => ($current_image_uuid) ? url($current_image_path) : null, ]); } @@ -25,13 +37,34 @@ new class extends Component { 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', + ]); + + $this->device->update([ + 'name' => $this->name, + 'friendly_id' => $this->friendly_id, + 'mac_address' => $this->mac_address, + 'default_refresh_interval' => $this->default_refresh_interval, + ]); + + Flux::modal('edit-device')->close(); + } } ?>
+ class="rounded-xl border bg-white dark:bg-stone-950 dark:border-stone-800 text-stone-800 shadow-xs">
@php $current_image_uuid =$device->current_screen_image; @@ -43,14 +76,6 @@ new class extends Component {

{{ $device->name }}

-
- - - - - - -
{{$device->updated_at->diffForHumans()}} @@ -59,15 +84,29 @@ new class extends Component { {{$device->mac_address}} - - - {{$device->last_firmware_version}} - - - - - + @if($device->last_firmware_version) + + + {{$device->last_firmware_version}} + + @endif + @if($device->wifiStrengh) + + + @endif + @if($device->batteryPercent) + + + @endif +
+
+ + + + + +
@@ -75,20 +114,24 @@ new class extends Component {
- {{-- Edit TRMNL--}} - {{-- --}} + Edit TRMNL +
- - {{-- --}} + + + viewable class="max-w-xs" readonly/> + + +
- {{-- Save changes--}} + Save changes +
@@ -104,7 +147,8 @@ new class extends Component { Cancel - Delete device + Delete device +