Add IP Addresses display for Proxmox server in service view

This commit is contained in:
2025-12-06 12:40:22 -05:00
parent a9f4981a83
commit 27243101e7
2 changed files with 65 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ class Show extends Component
public function mount() public function mount()
{ {
// Attach Proxmox server (if any) so we can show hostname on the service page // Attach Proxmox server (if any) so we can show hostname on the service page
$this->proxmoxServer = ProxmoxServer::with(['os', 'node'])->where('service_id', $this->service->id)->first(); $this->proxmoxServer = ProxmoxServer::with(['os', 'node', 'ipAddresses'])->where('service_id', $this->service->id)->first();
// Fetch actual VM status from Proxmox API if server exists // Fetch actual VM status from Proxmox API if server exists
if ($this->proxmoxServer) { if ($this->proxmoxServer) {

View File

@@ -216,6 +216,70 @@
</div> </div>
@endif @endif
<!-- IP Addresses Card (Proxmox) -->
@if($proxmoxServer && $proxmoxServer->ipAddresses->count() > 0)
<div class="bg-gradient-to-br from-background/50 to-background/20 border border-neutral/20 rounded-2xl p-6 backdrop-blur-sm hover:shadow-lg transition-all duration-300">
<div class="flex items-center gap-3 mb-6">
<x-ri-global-line class="size-6 text-primary" />
<h3 class="uppercase font-black text-color-base text-sm tracking-wider">IP Addresses</h3>
</div>
<div class="space-y-3">
@foreach($proxmoxServer->ipAddresses as $ipAddress)
@php
// Determine if IP is private (NAT) or public
$ip = $ipAddress->ip;
$isPrivate = false;
// Check for IPv4 private ranges (RFC 1918)
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$isPrivate = (
str_starts_with($ip, '10.') ||
str_starts_with($ip, '192.168.') ||
preg_match('/^172\.(1[6-9]|2[0-9]|3[0-1])\./', $ip) ||
str_starts_with($ip, '100.64.') || // CGNAT
str_starts_with($ip, '169.254.') // Link-local
);
$ipType = 'IPv4';
} else {
// IPv6 private ranges
$isPrivate = (
str_starts_with(strtolower($ip), 'fc') ||
str_starts_with(strtolower($ip), 'fd') ||
str_starts_with(strtolower($ip), 'fe80')
);
$ipType = 'IPv6';
}
$networkType = $isPrivate ? 'NAT' : 'Public';
@endphp
<div class="flex items-center justify-between py-3 px-4 bg-background/50 rounded-xl">
<div class="flex items-center gap-3">
@if($ipType === 'IPv4')
<x-ri-router-line class="size-4 text-color-muted" />
@else
<x-ri-share-line class="size-4 text-color-muted" />
@endif
<div class="flex flex-col">
<span class="font-bold text-color-base font-mono text-sm">{{ $ip }}</span>
@if($ipAddress->gateway)
<span class="text-xs text-color-muted">Gateway: {{ $ipAddress->gateway }}</span>
@endif
</div>
</div>
<div class="flex items-center gap-2">
<span class="text-xs px-2 py-1 rounded-lg {{ $isPrivate ? 'bg-warning/20 text-warning' : 'bg-success/20 text-success' }}">
{{ $networkType }}
</span>
<span class="text-xs px-2 py-1 rounded-lg bg-primary/20 text-primary">
{{ $ipType }}
</span>
</div>
</div>
@endforeach
</div>
</div>
@endif
<!-- Actions Card --> <!-- Actions Card -->
@if($service->cancellable || $service->upgradable || count($buttons) > 0) @if($service->cancellable || $service->upgradable || count($buttons) > 0)
<div class="bg-gradient-to-br from-background/50 to-background/20 border border-neutral/20 rounded-2xl p-6 backdrop-blur-sm hover:shadow-lg transition-all duration-300"> <div class="bg-gradient-to-br from-background/50 to-background/20 border border-neutral/20 rounded-2xl p-6 backdrop-blur-sm hover:shadow-lg transition-all duration-300">