175 lines
10 KiB
PHP
175 lines
10 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center space-x-2">
|
|
<a href="{{ route('network.segments.index') }}" class="text-gray-500 hover:text-gray-700">Segmente</a>
|
|
<span class="text-gray-400">/</span>
|
|
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200">{{ $segment->name }}</h2>
|
|
</div>
|
|
<div class="flex gap-2 items-center">
|
|
{{-- Auto-Refresh Indikator --}}
|
|
<span id="refresh-indicator" class="text-xs text-gray-400 dark:text-gray-500 hidden">
|
|
↻ wird aktualisiert...
|
|
</span>
|
|
|
|
{{-- Jetzt scannen --}}
|
|
@if($segment->active)
|
|
<form method="POST" action="{{ route('network.segments.scan', $segment) }}">
|
|
@csrf
|
|
<button type="submit" style="background-color: var(--color-primary)"
|
|
class="px-4 py-2 text-white text-sm font-medium rounded-md hover:opacity-90 transition">
|
|
▶ Jetzt scannen
|
|
</button>
|
|
</form>
|
|
@endif
|
|
|
|
<a href="{{ route('network.import') }}?segment={{ $segment->id }}"
|
|
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">
|
|
⬆ Import
|
|
</a>
|
|
<a href="{{ route('network.segments.export.xlsx', $segment) }}"
|
|
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">
|
|
📊 Excel
|
|
</a>
|
|
<a href="{{ route('network.segments.export.pdf', $segment) }}"
|
|
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">
|
|
📄 PDF
|
|
</a>
|
|
<a href="{{ route('network.segments.edit', $segment) }}"
|
|
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">
|
|
Bearbeiten
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</x-slot>
|
|
|
|
<div class="py-8">
|
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
|
|
|
|
{{-- Segment-Info --}}
|
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Subnetz</p>
|
|
<p class="mt-1 font-mono font-bold text-gray-900 dark:text-gray-100">{{ $segment->subnet }}</p>
|
|
</div>
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">VLAN</p>
|
|
<p class="mt-1 font-bold text-gray-900 dark:text-gray-100">{{ $segment->vlan_id ? 'VLAN ' . $segment->vlan_id : '—' }}</p>
|
|
</div>
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Status</p>
|
|
<p class="mt-1 font-bold {{ $segment->active ? 'text-green-600' : 'text-gray-400' }}">
|
|
{{ $segment->active ? 'Aktiv' : 'Inaktiv' }}
|
|
</p>
|
|
</div>
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Auto-Scan</p>
|
|
<p class="mt-1 font-bold text-gray-900 dark:text-gray-100 text-sm">
|
|
{{ $segment->scan_interval_label }}
|
|
</p>
|
|
</div>
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Scans gesamt</p>
|
|
<p class="mt-1 font-bold text-gray-900 dark:text-gray-100">{{ $scans->total() }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
@if($latestScan)
|
|
<div class="grid grid-cols-2 md:grid-cols-3 gap-4">
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Letzter Scan</p>
|
|
<p class="mt-1 font-bold text-gray-900 dark:text-gray-100">{{ $latestScan->created_at->format('d.m.Y H:i') }}</p>
|
|
</div>
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Online / Gesamt</p>
|
|
<p class="mt-1 font-bold">
|
|
<span class="text-green-600">{{ $latestScan->online_hosts }}</span>
|
|
<span class="text-gray-400"> / {{ $latestScan->total_hosts }}</span>
|
|
</p>
|
|
</div>
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wider">Neue Geräte</p>
|
|
<p class="mt-1 font-bold text-gray-900 dark:text-gray-100">{{ $latestScan->new_devices }}</p>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
{{-- Scan-Historie --}}
|
|
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-lg overflow-hidden">
|
|
<div class="px-5 py-4 border-b border-gray-200 dark:border-gray-700">
|
|
<h3 class="font-semibold text-gray-900 dark:text-gray-100">Scan-Historie</h3>
|
|
</div>
|
|
<div data-scan-count="{{ $scans->total() }}"></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">Datum</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Scanner</th>
|
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Gesamt</th>
|
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Online</th>
|
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Neu</th>
|
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Geändert</th>
|
|
<th class="px-4 py-3"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100 dark:divide-gray-700">
|
|
@forelse($scans as $scan)
|
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700 transition">
|
|
<td class="px-4 py-3 text-gray-700 dark:text-gray-300">{{ $scan->created_at->format('d.m.Y H:i') }}</td>
|
|
<td class="px-4 py-3 text-xs text-gray-500 dark:text-gray-400">{{ $scan->scanner ?? '—' }}</td>
|
|
<td class="px-4 py-3 text-right text-gray-700 dark:text-gray-300">{{ $scan->total_hosts }}</td>
|
|
<td class="px-4 py-3 text-right text-green-600 font-medium">{{ $scan->online_hosts }}</td>
|
|
<td class="px-4 py-3 text-right text-blue-600">{{ $scan->new_devices }}</td>
|
|
<td class="px-4 py-3 text-right text-yellow-600">{{ $scan->changed_devices }}</td>
|
|
<td class="px-4 py-3 text-right">
|
|
<a href="{{ route('network.scan', $scan) }}"
|
|
class="text-xs text-indigo-600 hover:underline">Details →</a>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="7" class="px-4 py-10 text-center text-gray-500">Noch keine Scans für dieses Segment.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
@if($scans->hasPages())
|
|
<div class="px-4 py-3 border-t border-gray-200 dark:border-gray-700">
|
|
{{ $scans->links() }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
@if(session('success') && str_contains(session('success'), 'gestartet'))
|
|
{{-- Auto-Refresh nach "Jetzt scannen": alle 10s prüfen ob neuer Scan vorliegt --}}
|
|
<script>
|
|
(function() {
|
|
const currentScanCount = {{ $scans->total() }};
|
|
const indicator = document.getElementById('refresh-indicator');
|
|
let checks = 0;
|
|
|
|
const interval = setInterval(function() {
|
|
if (++checks > 18) { clearInterval(interval); return; } // max 3 Min
|
|
if (indicator) indicator.classList.remove('hidden');
|
|
|
|
fetch(window.location.href, { headers: { 'X-Requested-With': 'XMLHttpRequest' } })
|
|
.then(r => r.text())
|
|
.then(html => {
|
|
const parser = new DOMParser();
|
|
const doc = parser.parseFromString(html, 'text/html');
|
|
const newCount = parseInt(doc.querySelector('[data-scan-count]')?.dataset?.scanCount || '0');
|
|
if (newCount > currentScanCount) {
|
|
clearInterval(interval);
|
|
window.location.reload();
|
|
}
|
|
})
|
|
.catch(() => {});
|
|
}, 10000);
|
|
})();
|
|
</script>
|
|
@endif
|
|
</x-app-layout>
|