diff --git a/app/Livewire/Windows.php b/app/Livewire/Windows.php new file mode 100644 index 0000000..c815601 --- /dev/null +++ b/app/Livewire/Windows.php @@ -0,0 +1,33 @@ +whereIn('type', ['contact', 'motion']) + ->with(['device.room', 'device.entities.state', 'state']) + ->get() + ->sortBy(fn ($e) => ($e->device->room?->name ?? 'zzz').$e->device->name) + ->values(); + + $open = $sensors->filter(fn ($e) => $e->type === 'contact' && data_get($e->state, 'state.open') === true)->count(); + + return view('livewire.windows', [ + 'groups' => $sensors->groupBy(fn ($e) => $e->device->room?->name ?? __('devices.no_room')), + 'open' => $open, + 'total' => $sensors->count(), + ]); + } +} diff --git a/lang/de/windows.php b/lang/de/windows.php new file mode 100644 index 0000000..ae58f17 --- /dev/null +++ b/lang/de/windows.php @@ -0,0 +1,9 @@ + 'Kontakte an Fenstern und Türen.', + 'empty' => 'Keine Kontaktsensoren.', + 'all_closed' => 'Alles geschlossen', + 'open_count' => '{1}1 offen|[2,*]:count offen', + 'sensor_count' => '{0}Keine Sensoren|{1}1 Sensor|[2,*]:count Sensoren', +]; diff --git a/lang/en/windows.php b/lang/en/windows.php new file mode 100644 index 0000000..1b6110a --- /dev/null +++ b/lang/en/windows.php @@ -0,0 +1,9 @@ + 'Contacts on windows and doors.', + 'empty' => 'No contact sensors.', + 'all_closed' => 'All closed', + 'open_count' => '{1}1 open|[2,*]:count open', + 'sensor_count' => '{0}No sensors|{1}1 sensor|[2,*]:count sensors', +]; diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index fa6b724..88a37d1 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -9,7 +9,7 @@ ['key' => 'persons', 'icon' => 'persons', 'route' => null, 'lock' => false], ], 'nav.section_security' => [ - ['key' => 'windows', 'icon' => 'window', 'route' => null, 'lock' => false], + ['key' => 'windows', 'icon' => 'window', 'route' => 'windows', 'lock' => false], ['key' => 'access', 'icon' => 'shield', 'route' => null, 'lock' => true], ], 'nav.section_system' => [ diff --git a/resources/views/livewire/windows.blade.php b/resources/views/livewire/windows.blade.php new file mode 100644 index 0000000..74557e6 --- /dev/null +++ b/resources/views/livewire/windows.blade.php @@ -0,0 +1,50 @@ +
{{ __('windows.empty') }}
{{ trans_choice('windows.sensor_count', $total, ['count' => $total]) }}
+