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

98 lines
5.0 KiB
PHP

@php
$label = ['online' => 'Online', 'warning' => 'Warnung', 'offline' => 'Offline'];
@endphp
<div class="space-y-4">
{{-- Header --}}
<div class="flex flex-wrap items-end justify-between gap-3">
<div>
<p class="font-mono text-[11px] uppercase tracking-[0.2em] text-accent-text">Flotte</p>
<h2 class="mt-0.5 font-display text-xl font-semibold text-ink sm:text-2xl">Server</h2>
</div>
<div class="flex items-center gap-2">
<x-btn variant="accent" wire:click="$dispatch('openModal', { component: 'modals.create-server' })">
<x-icon name="plus" class="h-3.5 w-3.5" />
Server hinzufügen
</x-btn>
<x-status-pill status="online">{{ $online }} / {{ $total }} online</x-status-pill>
</div>
</div>
{{-- KPI grid: 1 2 4 --}}
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4">
<x-kpi label="Gesamt" :value="$total" icon="server" />
<x-kpi label="Online" :value="$online" tone="online" icon="activity" />
<x-kpi label="Warnung" :value="$warning" tone="warning" />
<x-kpi label="Offline" :value="$offline" tone="offline" />
</div>
{{-- Fleet --}}
<x-panel title="Flotte" :subtitle="$total . ' im Cluster'" :padded="false">
<x-slot:actions>
<label class="relative block">
<span class="sr-only">Server suchen</span>
<x-icon name="search" class="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-4" />
<input
type="search"
wire:model.live.debounce.300ms="search"
placeholder="Name oder IP…"
class="min-h-11 w-full rounded-md border border-line bg-inset py-1.5 pl-8 pr-3 font-mono text-xs text-ink placeholder:text-ink-4 focus:border-accent/40 focus:outline-none sm:w-56"
/>
</label>
</x-slot:actions>
@if ($servers->isEmpty())
<div class="px-4 py-10 text-center sm:px-5">
<p class="text-sm text-ink-2">Keine Server gefunden.</p>
<p class="mt-1 font-mono text-[11px] text-ink-4">Suchbegriff anpassen oder Filter zurücksetzen.</p>
</div>
@else
<div class="divide-y divide-line">
@foreach ($servers as $server)
<a
href="{{ route('servers.show', $server) }}"
wire:key="server-{{ $server->uuid }}"
wire:navigate
class="flex min-h-11 items-center gap-3 px-4 py-3 transition-colors hover:bg-raised sm:px-5"
>
<x-status-dot :status="$server->status" :ping="$server->status === 'online'" />
<div class="min-w-0 flex-1">
<p class="truncate text-sm text-ink">{{ $server->name }}</p>
<p class="truncate font-mono text-[11px] text-ink-3">
{{ $server->ip }}@if ($server->os) · {{ $server->os }}@endif
</p>
</div>
{{-- CPU / RAM mini bars hidden on mobile to keep the row legible --}}
<div class="hidden shrink-0 items-center gap-4 md:flex">
<div class="w-20">
<div class="flex items-center justify-between">
<span class="font-mono text-[10px] uppercase text-ink-4">CPU</span>
<span class="tabular font-mono text-[10px] text-ink-3">{{ $server->cpu }}%</span>
</div>
<div class="mt-1 h-1 w-full overflow-hidden rounded-full bg-line">
<div class="h-full rounded-full bg-accent" style="width: {{ $server->cpu }}%"></div>
</div>
</div>
<div class="w-20">
<div class="flex items-center justify-between">
<span class="font-mono text-[10px] uppercase text-ink-4">RAM</span>
<span class="tabular font-mono text-[10px] text-ink-3">{{ $server->mem }}%</span>
</div>
<div class="mt-1 h-1 w-full overflow-hidden rounded-full bg-line">
<div class="h-full rounded-full bg-cyan" style="width: {{ $server->mem }}%"></div>
</div>
</div>
</div>
<x-status-pill :status="$server->status" class="shrink-0">
{{ $label[$server->status] ?? ucfirst($server->status) }}
</x-status-pill>
</a>
@endforeach
</div>
@endif
</x-panel>
</div>