Files

150 lines
10 KiB
PHP

<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200">Globale Suche</h2>
</x-slot>
<div class="py-8">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-4">
<form method="GET" action="{{ route('network.search') }}" class="flex gap-3">
<input type="text" name="q" value="{{ $q }}"
placeholder="IP-Adresse, MAC, Hostname, Bezeichnung..."
autofocus
class="flex-1 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md shadow-sm text-sm focus:ring-indigo-500 focus:border-indigo-500" />
<button type="submit" style="background-color: var(--color-primary)"
class="px-5 py-2 text-white text-sm font-medium rounded-md hover:opacity-90 transition">
🔍 Suchen
</button>
@if($q)
<a href="{{ route('network.search') }}"
class="px-4 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition">
Zurücksetzen
</a>
@endif
</form>
@if($q && strlen($q) < 2)
<p class="text-sm text-gray-500">Mindestens 2 Zeichen eingeben.</p>
@elseif($q)
@php $totalFound = $devices->total() + $hostResults->count(); @endphp
<p class="text-sm text-gray-500 dark:text-gray-400">
{{ $totalFound }} Ergebnis(se) für {{ $q }}" über alle Segmente
</p>
{{-- Ergebnisse aus network_devices (getracked) --}}
@if($devices->count() > 0)
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-lg overflow-hidden">
<div class="px-4 py-2 bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600">
<span class="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Geräte (bekannt)</span>
</div>
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700 text-sm">
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Status</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">IP-Adresse</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">MAC-Adresse</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Hostname / Bezeichnung</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Hersteller</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Zuletzt gesehen</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100 dark:divide-gray-700">
@foreach($devices as $device)
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700 transition">
<td class="px-4 py-3">
<span class="w-2 h-2 rounded-full inline-block
{{ $device->status === 'online' ? 'bg-green-500' : 'bg-red-400' }}"></span>
</td>
<td class="px-4 py-3 font-mono text-gray-900 dark:text-gray-100 font-medium">{{ $device->current_ip }}</td>
<td class="px-4 py-3 font-mono text-xs text-gray-600 dark:text-gray-400">{{ $device->mac_address ?? '—' }}</td>
<td class="px-4 py-3 text-gray-900 dark:text-gray-100">
@if($device->label)
<span class="font-medium">{{ $device->label }}</span>
<span class="text-gray-400 text-xs ml-1">({{ $device->hostname }})</span>
@else
{{ $device->hostname ?? $device->netbios_name ?? '—' }}
@endif
@if($device->netbios_name && $device->netbios_name !== $device->hostname)
<span class="block text-xs text-gray-400">NetBIOS: {{ $device->netbios_name }}</span>
@endif
</td>
<td class="px-4 py-3 text-xs text-gray-600 dark:text-gray-400">{{ $device->mac_vendor ?? '—' }}</td>
<td class="px-4 py-3 text-xs text-gray-500 dark:text-gray-400">
{{ $device->last_seen_at?->format('d.m.Y H:i') ?? '—' }}
</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('network.device', $device) }}"
class="text-xs text-indigo-600 hover:underline">Detail →</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@if($devices->hasPages())
<div class="px-4 py-3 border-t border-gray-200 dark:border-gray-700">
{{ $devices->links() }}
</div>
@endif
</div>
@endif
{{-- Ergebnisse aus network_hosts (Scan-Treffer ohne Device-Eintrag) --}}
@if($hostResults->count() > 0)
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-lg overflow-hidden">
<div class="px-4 py-2 bg-blue-50 dark:bg-blue-900/20 border-b border-blue-100 dark:border-blue-800 flex items-center justify-between">
<span class="text-xs font-semibold text-blue-600 dark:text-blue-400 uppercase tracking-wider">
In Scan-Verlauf gefunden
</span>
<span class="text-xs text-blue-400">Noch kein Geräteeintrag — wird beim nächsten Scan angelegt</span>
</div>
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700 text-sm">
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Status</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">IP-Adresse</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">MAC-Adresse</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Hostname</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Hersteller</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Segment</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Letzter Scan</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100 dark:divide-gray-700">
@foreach($hostResults as $host)
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700 transition">
<td class="px-4 py-3">
<span class="w-2 h-2 rounded-full inline-block
{{ $host->status === 'online' ? 'bg-green-500' : 'bg-gray-300' }}"></span>
</td>
<td class="px-4 py-3 font-mono font-medium text-gray-900 dark:text-gray-100">{{ $host->ip_address }}</td>
<td class="px-4 py-3 font-mono text-xs text-gray-500 dark:text-gray-400">{{ $host->mac_address ?? '—' }}</td>
<td class="px-4 py-3 text-gray-700 dark:text-gray-300">{{ $host->hostname ?? '—' }}</td>
<td class="px-4 py-3 text-xs text-gray-500 dark:text-gray-400">{{ $host->mac_vendor ?? '—' }}</td>
<td class="px-4 py-3 text-xs text-gray-500 dark:text-gray-400">{{ $host->segment_name ?? '—' }}</td>
<td class="px-4 py-3 text-xs text-gray-400">
{{ \Carbon\Carbon::parse($host->scan_time)->format('d.m.Y H:i') }}
</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('network.scan', $host->scan_id) }}"
class="text-xs text-indigo-600 hover:underline">Scan →</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
@if($totalFound === 0)
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-lg px-4 py-10 text-center text-gray-500">
Keine Ergebnisse für „{{ $q }}" gefunden.
</div>
@endif
@endif
</div>
</div>
</x-app-layout>