refactor: optimize IP visibility handling in Proxmox firewall view by integrating conditional checks for public IPs, enhancing user interaction

This commit is contained in:
2025-12-04 14:11:07 -05:00
parent 69a57459d8
commit 3b474fc4a0

View File

@@ -573,9 +573,9 @@
<td class="py-3 px-4 text-sm">
<div class="flex items-center gap-1">
<span class="font-mono text-xs">{{ $rule['source'] ?? '-' }}</span>
@if($rule['source'] && $rule['source'] !== '-' && window.isPublicIP($rule['source']))
<div class="relative" x-data="{ open: false, loading: false, ipData: null }" x-cloak>
<div class="relative" x-data="{ open: false, loading: false, ipData: null }" x-cloak x-show="{{ $rule['source'] && $rule['source'] !== '-' }}">
<button type="button" @click.stop="
if (!window.isPublicIP('{{ $rule['source'] }}')) return;
if (!ipData && !loading) {
loading = true;
open = true;
@@ -589,7 +589,7 @@
} else {
open = true;
}
" class="text-base/50 hover:text-base/70 transition-colors" title="View IP Location">
" class="text-base/50 hover:text-base/70 transition-colors" title="View IP Location" x-show="window.isPublicIP('{{ $rule['source'] }}')">
<x-ri-map-pin-line class="size-3" />
</button>
<!-- Modal -->
@@ -666,18 +666,17 @@
</div>
</template>
</div>
@endif
</td>
<td class="py-3 px-4 text-sm">
<div class="flex items-center gap-1">
<span class="font-mono text-xs">{{ $rule['dest'] ?? '-' }}</span>
@if($rule['dest'] && $rule['dest'] !== '-' && window.isPublicIP($rule['dest']))
<div class="relative" x-data="{ open: false, loading: false, ipData: null }" x-cloak>
<div class="relative" x-data="{ open: false, loading: false, ipData: null }" x-cloak x-show="{{ $rule['dest'] && $rule['dest'] !== '-' }}">
<button type="button" @click.stop="
if (!window.isPublicIP('{{ $rule['dest'] }}')) return;
if (!ipData && !loading) {
loading = true;
open = true;
window.fetchIPLocation(rule.dest).then(data => {
window.fetchIPLocation('{{ $rule['dest'] }}').then(data => {
ipData = data;
loading = false;
}).catch(err => {
@@ -687,7 +686,7 @@
} else {
open = true;
}
" class="text-base/50 hover:text-base/70 transition-colors" title="View IP Location">
" class="text-base/50 hover:text-base/70 transition-colors" title="View IP Location" x-show="window.isPublicIP('{{ $rule['dest'] }}')">
<x-ri-map-pin-line class="size-3" />
</button>
<!-- Modal -->
@@ -764,7 +763,6 @@
</div>
</template>
</div>
@endif
</td>
<td class="py-3 px-4 text-sm">{{ strtoupper($rule['proto'] ?? 'any') }}</td>
<td class="py-3 px-4 text-sm">{{ $rule['dport'] ?? $rule['sport'] ?? '-' }}</td>