Files

176 lines
12 KiB
PHP

<x-app-layout>
<x-slot name="header">
<div class="flex items-center justify-between">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200">Chronologischer IP-Verlauf</h2>
<span class="text-xs text-gray-400 dark:text-gray-500">{{ $entries->total() }} Einträge</span>
</div>
</x-slot>
<div class="py-8">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-4">
{{-- Filter --}}
<form method="GET" action="{{ route('network.history') }}"
class="bg-white dark:bg-gray-800 shadow-sm rounded-lg p-4">
<div class="grid grid-cols-2 md:grid-cols-4 gap-3 mb-3">
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">IP-Adresse</label>
<input type="text" name="ip" value="{{ request('ip') }}"
placeholder="z.B. 192.168.86"
class="block w-full 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" />
</div>
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">MAC-Adresse</label>
<input type="text" name="mac" value="{{ request('mac') }}"
placeholder="z.B. 00:50:56"
class="block w-full 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" />
</div>
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">Hostname / Bezeichnung</label>
<input type="text" name="hostname" value="{{ request('hostname') }}"
placeholder="z.B. frigo-nas"
class="block w-full 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" />
</div>
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">Segment</label>
<select name="segment"
class="block w-full 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">
<option value="">Alle Segmente</option>
@foreach($segments as $seg)
<option value="{{ $seg->id }}" {{ request('segment') == $seg->id ? 'selected' : '' }}>
{{ $seg->name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="grid grid-cols-2 md:grid-cols-4 gap-3">
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">Status</label>
<select name="status"
class="block w-full 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">
<option value="">Alle</option>
<option value="online" {{ request('status') === 'online' ? 'selected' : '' }}>Online</option>
<option value="offline" {{ request('status') === 'offline' ? 'selected' : '' }}>Offline</option>
</select>
</div>
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">Von Datum</label>
<input type="date" name="from" value="{{ request('from') }}"
class="block w-full 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" />
</div>
<div>
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">Bis Datum</label>
<input type="date" name="to" value="{{ request('to') }}"
class="block w-full 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" />
</div>
<div class="flex items-end gap-2">
<button type="submit" style="background-color: var(--color-primary)"
class="flex-1 py-2 text-white text-sm font-medium rounded-md hover:opacity-90 transition">
Filtern
</button>
@if(request()->hasAny(['ip','mac','hostname','segment','status','from','to']))
<a href="{{ route('network.history') }}"
class="py-2 px-3 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">
</a>
@endif
</div>
</div>
</form>
{{-- Tabelle --}}
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-lg overflow-hidden">
<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-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Datum / Zeit</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Status</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">IP-Adresse</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">MAC-Adresse</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Hostname / Bezeichnung</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Hersteller</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Segment</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Ping</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100 dark:divide-gray-700">
@forelse($entries as $entry)
<tr class="{{ $entry->status === 'online' ? '' : 'opacity-60' }} hover:bg-gray-50 dark:hover:bg-gray-700 transition">
<td class="px-3 py-2 text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap">
{{ \Carbon\Carbon::parse($entry->scan_time)->format('d.m.Y H:i') }}
@if($entry->scanner)
<br><span class="text-gray-400">{{ $entry->scanner }}</span>
@endif
</td>
<td class="px-3 py-2">
<span class="inline-flex items-center gap-1">
<span class="w-2 h-2 rounded-full {{ $entry->status === 'online' ? 'bg-green-500' : 'bg-gray-300' }}"></span>
<span class="text-xs {{ $entry->status === 'online' ? 'text-green-700 dark:text-green-400' : 'text-gray-400' }}">
{{ $entry->status }}
</span>
</span>
</td>
<td class="px-3 py-2 font-mono font-medium text-gray-900 dark:text-gray-100">
@if($entry->device_id)
<a href="{{ route('network.device', $entry->device_id) }}"
class="text-indigo-600 hover:underline">
{{ $entry->ip_address }}
</a>
@else
{{ $entry->ip_address }}
@endif
</td>
<td class="px-3 py-2 font-mono text-xs text-gray-600 dark:text-gray-400">
@if($entry->mac_address)
<span title="{{ $entry->mac_address }}">{{ $entry->mac_address }}</span>
@else
<span class="text-gray-300"></span>
@endif
</td>
<td class="px-3 py-2 text-gray-700 dark:text-gray-300">
@if($entry->device_label)
<span class="font-medium">{{ $entry->device_label }}</span>
@if($entry->hostname)
<span class="text-xs text-gray-400 ml-1">({{ $entry->hostname }})</span>
@endif
@else
{{ $entry->hostname ?? '—' }}
@endif
</td>
<td class="px-3 py-2 text-xs text-gray-600 dark:text-gray-400">{{ $entry->mac_vendor ?? '—' }}</td>
<td class="px-3 py-2 text-xs text-gray-500 dark:text-gray-400">
{{ $entry->segment_name ?? '—' }}
</td>
<td class="px-3 py-2 text-xs text-gray-500 dark:text-gray-400">
{{ $entry->ping_ms !== null ? $entry->ping_ms . ' ms' : '—' }}
</td>
</tr>
@empty
<tr>
<td colspan="8" class="px-4 py-10 text-center text-gray-500">
Keine Einträge gefunden.
</td>
</tr>
@endforelse
</tbody>
</table>
@if($entries->hasPages())
<div class="px-4 py-3 border-t border-gray-200 dark:border-gray-700">
{{ $entries->links() }}
</div>
@endif
</div>
</div>
</div>
{{-- Auto-Refresh alle 60 Sekunden wenn kein Filter aktiv --}}
@unless(request()->hasAny(['ip','mac','hostname','segment','status','from','to']))
<script>
setTimeout(function() { window.location.reload(); }, 60000);
</script>
@endunless
</x-app-layout>