refactor: update Proxmox Firewall component to use a page reload for refreshing logs, simplifying the log management process and enhancing user experience

This commit is contained in:
2025-12-02 15:50:47 -05:00
parent 39f06a6293
commit 8382e7f7da

View File

@@ -302,8 +302,7 @@
</div> </div>
</div> </div>
<button <button
wire:click="loadFirewallLogs" @click="window.location.reload()"
wire:loading.attr="disabled"
class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors text-sm font-medium"> class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors text-sm font-medium">
<x-ri-refresh-line class="size-4 inline mr-1" /> <x-ri-refresh-line class="size-4 inline mr-1" />
Refresh Refresh
@@ -323,23 +322,12 @@
@if(count($firewallLogs) > 0) @if(count($firewallLogs) > 0)
<div <div
wire:ignore
x-data="{ x-data="{
logs: [], logs: @js($firewallLogs),
searchTerm: '', searchTerm: '',
sortField: 'timestamp_iso', sortField: 'timestamp_iso',
sortDirection: 'desc', sortDirection: 'desc',
init() {
// Use window storage to persist logs across Livewire updates
if (!window.firewallLogsCache) {
window.firewallLogsCache = @js($firewallLogs);
}
this.logs = window.firewallLogsCache;
},
refreshLogs() {
// Update cache when refresh button is clicked
window.firewallLogsCache = @js($firewallLogs);
this.logs = window.firewallLogsCache;
},
sort(field) { sort(field) {
if (this.sortField === field) { if (this.sortField === field) {
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc'; this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
@@ -384,7 +372,6 @@
}); });
}, },
}" }"
@logs-refreshed.window="refreshLogs()"
class="space-y-4" class="space-y-4"
> >
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3"> <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">