clusev/resources/views/livewire/servers/show.blade.php

184 lines
9.9 KiB
PHP

@php
// Threshold tone for gauges/bars: >=90 offline, >=75 warning, else online.
$tone = fn (int $v): string => $v >= 90 ? 'offline' : ($v >= 75 ? 'warning' : 'online');
$barColor = ['online' => 'bg-online', 'warning' => 'bg-warning', 'offline' => 'bg-offline'];
$statusLabel = ['online' => 'Online', 'warning' => 'Warnung', 'offline' => 'Offline'][$server->status] ?? ucfirst($server->status);
$specs = $server->specs ?? [];
$specRows = [
['Kerne', $specs['cores'] ?? '—'],
['RAM', isset($specs['ram_gb']) ? $specs['ram_gb'].' GB' : '—'],
['Disk', isset($specs['disk_gb']) ? $specs['disk_gb'].' GB' : '—'],
['Architektur', $specs['arch'] ?? '—'],
['Kernel', $specs['kernel'] ?? '—'],
['Virtualisierung', $specs['virt'] ?? '—'],
];
@endphp
<div class="space-y-4">
{{-- Header --}}
<div class="space-y-3">
<a href="{{ route('servers.index') }}"
class="inline-flex min-h-11 items-center gap-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-ink-3 hover:text-ink-2">
<x-icon name="switcher" class="h-3.5 w-3.5 rotate-90" />
Zurück zur Flotte
</a>
<div class="flex flex-wrap items-end justify-between gap-3">
<div class="min-w-0">
<p class="font-mono text-[11px] uppercase tracking-[0.2em] text-accent-text">Server</p>
<h2 class="mt-0.5 truncate font-display text-xl font-semibold text-ink sm:text-2xl">{{ $server->name }}</h2>
<p class="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px] text-ink-3">
<span class="text-ink-2">{{ $server->hostname }}</span>
<span class="text-ink-4">·</span>
<span>{{ $server->ip }}</span>
<span class="text-ink-4">·</span>
<span>{{ $server->os }}</span>
<span class="text-ink-4">·</span>
<span>Uptime {{ $server->uptime }}</span>
<span class="text-ink-4">·</span>
<span>zuletzt gesehen {{ optional($server->last_seen_at)->diffForHumans() ?? '—' }}</span>
</p>
</div>
<x-status-pill :status="$server->status" class="shrink-0">{{ $statusLabel }}</x-status-pill>
</div>
</div>
@unless ($connected)
<div class="flex items-center gap-2.5 rounded-md border border-warning/25 bg-warning/10 px-4 py-3">
<x-icon name="alert" class="h-4 w-4 shrink-0 text-warning" />
<p class="text-sm text-ink-2">Keine Live-Verbindung gezeigt werden die zuletzt gespeicherten Werte. Credential/Erreichbarkeit prüfen.</p>
</div>
@endunless
{{-- Auslastung + Spezifikationen --}}
<div class="grid grid-cols-1 gap-3 lg:grid-cols-2">
<x-panel title="Auslastung" subtitle="Echtzeit-Gauges">
<div class="grid grid-cols-3 gap-2">
<x-ring :value="$server->cpu" label="CPU" :tone="$tone($server->cpu)" />
<x-ring :value="$server->mem" label="RAM" :tone="$tone($server->mem)" />
<x-ring :value="$server->disk" label="Disk" :tone="$tone($server->disk)" />
</div>
</x-panel>
<x-panel title="Spezifikationen" subtitle="Hardware-Profil" :padded="false">
<dl class="divide-y divide-line">
@foreach ($specRows as [$key, $val])
<div class="flex items-center justify-between gap-3 px-4 py-2.5 sm:px-5">
<dt class="text-sm text-ink-2">{{ $key }}</dt>
<dd class="truncate font-mono text-sm text-ink">{{ $val }}</dd>
</div>
@endforeach
</dl>
</x-panel>
</div>
{{-- Volumes + Netzwerk-Interfaces --}}
<div class="grid grid-cols-1 gap-3 lg:grid-cols-2">
<x-panel title="Volumes" :subtitle="count($volumes) . ' Mountpoints'" :padded="false">
<div class="divide-y divide-line">
@foreach ($volumes as $vol)
@php $vt = $tone((int) $vol['used']); @endphp
<div class="px-4 py-3 sm:px-5">
<div class="flex items-center justify-between gap-3">
<p class="truncate font-mono text-sm text-ink">{{ $vol['mount'] }}</p>
<p class="shrink-0 font-mono text-[11px] text-ink-3">
<span class="text-ink-2">{{ $vol['fs'] }}</span> · {{ $vol['size'] }}
</p>
</div>
<div class="mt-2 flex items-center gap-3">
<div class="h-1.5 flex-1 overflow-hidden rounded-full bg-inset">
<div class="h-full rounded-full {{ $barColor[$vt] }}" style="width: {{ $vol['used'] }}%"></div>
</div>
<span class="tabular w-10 shrink-0 text-right font-mono text-[11px] text-ink-2">{{ $vol['used'] }}%</span>
</div>
</div>
@endforeach
</div>
</x-panel>
<x-panel title="Netzwerk-Interfaces" :subtitle="count($interfaces) . ' Schnittstellen'" :padded="false">
{{-- Dense table on desktop; horizontal scroll keeps columns aligned on small screens (R7) --}}
<div class="overflow-x-auto">
<table class="w-full min-w-[34rem] text-left">
<thead>
<tr class="border-b border-line font-mono text-[10px] uppercase tracking-wider text-ink-4">
<th class="px-4 py-2 font-medium sm:px-5">Name</th>
<th class="px-4 py-2 font-medium">IP</th>
<th class="px-4 py-2 font-medium">MAC</th>
<th class="px-4 py-2 text-right font-medium">RX</th>
<th class="px-4 py-2 pr-4 text-right font-medium sm:pr-5">TX</th>
</tr>
</thead>
<tbody class="divide-y divide-line">
@foreach ($interfaces as $if)
<tr class="font-mono text-[11px] text-ink-2">
<td class="px-4 py-2.5 text-ink sm:px-5">{{ $if['name'] }}</td>
<td class="px-4 py-2.5">{{ $if['ip'] }}</td>
<td class="px-4 py-2.5">{{ $if['mac'] }}</td>
<td class="tabular px-4 py-2.5 text-right">{{ $if['rx'] }}</td>
<td class="tabular px-4 py-2.5 pr-4 text-right sm:pr-5">{{ $if['tx'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</x-panel>
</div>
{{-- Sicherheit (Hardening) + SSH-Schlüssel --}}
<div class="grid grid-cols-1 gap-3 lg:grid-cols-2">
<x-panel title="Sicherheit (Hardening)" subtitle="Checkliste" :padded="false">
<div class="divide-y divide-line">
@foreach ($hardening as $check)
<div class="flex items-center gap-3 px-4 py-3 sm:px-5">
<div class="min-w-0 flex-1">
<p class="truncate text-sm text-ink">{{ $check['label'] }}</p>
<p class="truncate font-mono text-[11px] text-ink-3">{{ $check['detail'] }}</p>
</div>
<x-status-pill :status="$check['status']" class="shrink-0">
{{ $check['status'] === 'online' ? 'OK' : 'Fehlt' }}
</x-status-pill>
</div>
@endforeach
</div>
</x-panel>
<x-panel title="SSH-Schlüssel" :subtitle="count($sshKeys) . ' autorisiert'" :padded="false">
<x-slot:actions>
{{-- R5: wire to wire-elements/modal --}}
<button type="button"
class="inline-flex min-h-11 items-center gap-1.5 rounded-md border border-accent/25 bg-accent/10 px-3 py-1.5 text-xs text-accent-text hover:bg-accent/15">
<x-icon name="plus" class="h-3.5 w-3.5" />
Schlüssel hinzufügen
</button>
</x-slot:actions>
<div class="divide-y divide-line">
@foreach ($sshKeys as $key)
<div class="flex items-center gap-3 px-4 py-3 sm:px-5">
<span class="grid h-7 w-7 shrink-0 place-items-center rounded-sm bg-raised text-ink-3">
<x-icon name="shield" class="h-3.5 w-3.5" />
</span>
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2">
<p class="truncate font-mono text-sm text-ink">{{ $key['comment'] }}</p>
<x-badge tone="neutral" class="shrink-0">{{ $key['type'] }}</x-badge>
</div>
<p class="truncate font-mono text-[11px] text-ink-3">{{ $key['fingerprint'] }}</p>
</div>
{{-- R5: destructive wire-elements/modal confirm + audit --}}
<button type="button"
wire:click="confirmKeyRemoval('{{ $key['fingerprint'] }}', '{{ $key['comment'] }}')"
class="inline-flex min-h-11 shrink-0 items-center rounded-sm px-2 text-ink-3 transition-colors hover:bg-offline/10 hover:text-offline"
title="Schlüssel entfernen">
<x-icon name="trash" class="h-3.5 w-3.5" />
</button>
</div>
@endforeach
</div>
</x-panel>
</div>
</div>