fix: set default log level to 'nolog' in Proxmox Firewall component and update log level options in the UI for improved clarity and consistency

This commit is contained in:
2025-12-01 14:43:48 -05:00
parent 878d6c7769
commit ab626ed9a6
2 changed files with 68 additions and 32 deletions

View File

@@ -37,7 +37,7 @@ class Firewall extends Component
public bool $ruleEnable = true;
public string $ruleMacro = '';
public string $ruleIface = '';
public string $ruleLog = '';
public string $ruleLog = 'nolog';
// Alias management
public string $aliasName = '';
@@ -243,7 +243,7 @@ class Firewall extends Component
$this->ruleEnable = !isset($rule['enable']) || $rule['enable'] == 1;
$this->ruleMacro = $rule['macro'] ?? '';
$this->ruleIface = $rule['iface'] ?? '';
$this->ruleLog = $rule['log'] ?? '';
$this->ruleLog = $rule['log'] ?? 'nolog';
}
}
@@ -259,7 +259,7 @@ class Firewall extends Component
$this->ruleEnable = true;
$this->ruleMacro = '';
$this->ruleIface = '';
$this->ruleLog = '';
$this->ruleLog = 'nolog';
}
public function saveRule(): void

View File

@@ -445,14 +445,15 @@
<div>
<label class="block text-sm font-medium mb-2">Log Level</label>
<select wire:model="ruleLog" class="w-full px-3 py-2 border border-neutral rounded-lg bg-background">
<option value="">No Logging</option>
<option value="nolog">No Log</option>
<option value="info">Info</option>
<option value="warning">Warning</option>
<option value="err">Error</option>
<option value="crit">Critical</option>
<option value="alert">Alert</option>
<option value="emerg">Emergency</option>
<option value="nolog">nolog</option>
<option value="emerg">emerg</option>
<option value="alert">alert</option>
<option value="crit">crit</option>
<option value="err">err</option>
<option value="warning">warning</option>
<option value="notice">notice</option>
<option value="info">info</option>
<option value="debug">debug</option>
</select>
</div>
<div class="md:col-span-2">
@@ -487,54 +488,89 @@
@php
$ruleToDelete = collect($rules)->firstWhere('pos', $deletingRulePos);
@endphp
<div class="fixed inset-0 flex items-center justify-center z-50 bg-black/50 backdrop-blur-sm"
<div class="fixed inset-0 flex items-center justify-center z-50 bg-black/60 backdrop-blur-sm transition-opacity"
wire:click="cancelDeleteRule">
<div class="bg-background border border-neutral rounded-lg p-6 shadow-lg max-w-md w-full mx-4" wire:click.stop>
<div class="flex items-start gap-3 mb-4">
<div class="flex items-center justify-center w-10 h-10 rounded-lg bg-error/10 flex-shrink-0">
<x-ri-error-warning-fill class="size-5 text-error" />
<div class="bg-background border border-neutral/30 rounded-xl p-6 shadow-2xl max-w-lg w-full mx-4 transform transition-all" wire:click.stop>
<div class="flex items-start gap-4 mb-6">
<div class="flex items-center justify-center w-12 h-12 rounded-full bg-error/10 flex-shrink-0">
<x-ri-delete-bin-fill class="size-6 text-error" />
</div>
<div class="flex-1">
<h3 class="text-lg font-semibold mb-2">Delete Firewall Rule</h3>
<p class="text-sm text-base/60 mb-4">
Are you sure you want to delete this firewall rule? This action cannot be undone.
<h3 class="text-xl font-bold mb-2">Delete Firewall Rule</h3>
<p class="text-sm text-base/70 mb-4 leading-relaxed">
Are you sure you want to delete this firewall rule? This action cannot be undone and may affect your network security.
</p>
@if($ruleToDelete)
<div class="bg-background-secondary border border-neutral/20 rounded-lg p-3 mb-4">
<div class="text-sm space-y-1">
<div><span class="font-medium">Action:</span> {{ $ruleToDelete['action'] ?? '-' }}</div>
<div class="bg-background-secondary/50 border border-neutral/20 rounded-lg p-4 mb-4">
<div class="text-sm space-y-2">
<div class="flex items-center gap-2">
<span class="font-semibold text-base/80 min-w-[80px]">Action:</span>
<span class="px-2 py-1 rounded text-xs font-medium
{{ ($ruleToDelete['action'] ?? '') === 'ACCEPT' ? 'bg-success/20 text-success' : '' }}
{{ ($ruleToDelete['action'] ?? '') === 'REJECT' ? 'bg-warning/20 text-warning' : '' }}
{{ ($ruleToDelete['action'] ?? '') === 'DROP' ? 'bg-error/20 text-error' : '' }}">
{{ $ruleToDelete['action'] ?? '-' }}
</span>
</div>
@if(!empty($ruleToDelete['source']))
<div><span class="font-medium">Source:</span> {{ $ruleToDelete['source'] }}</div>
<div class="flex items-center gap-2">
<span class="font-semibold text-base/80 min-w-[80px]">Source:</span>
<code class="text-xs bg-background px-2 py-1 rounded">{{ $ruleToDelete['source'] }}</code>
</div>
@endif
@if(!empty($ruleToDelete['dest']))
<div><span class="font-medium">Destination:</span> {{ $ruleToDelete['dest'] }}</div>
<div class="flex items-center gap-2">
<span class="font-semibold text-base/80 min-w-[80px]">Destination:</span>
<code class="text-xs bg-background px-2 py-1 rounded">{{ $ruleToDelete['dest'] }}</code>
</div>
@endif
@if(!empty($ruleToDelete['proto']))
<div><span class="font-medium">Protocol:</span> {{ strtoupper($ruleToDelete['proto']) }}</div>
<div class="flex items-center gap-2">
<span class="font-semibold text-base/80 min-w-[80px]">Protocol:</span>
<span class="text-base/90">{{ strtoupper($ruleToDelete['proto']) }}</span>
</div>
@endif
@if(!empty($ruleToDelete['dport']))
<div><span class="font-medium">Port:</span> {{ $ruleToDelete['dport'] }}</div>
<div class="flex items-center gap-2">
<span class="font-semibold text-base/80 min-w-[80px]">Port:</span>
<span class="text-base/90">{{ $ruleToDelete['dport'] }}</span>
</div>
@endif
@if(!empty($ruleToDelete['comment']))
<div><span class="font-medium">Comment:</span> {{ $ruleToDelete['comment'] }}</div>
<div class="flex items-start gap-2 pt-1 border-t border-neutral/20">
<span class="font-semibold text-base/80 min-w-[80px]">Comment:</span>
<span class="text-base/90 flex-1">{{ $ruleToDelete['comment'] }}</span>
</div>
@endif
</div>
</div>
@endif
</div>
</div>
<div class="flex gap-3 justify-end">
<button
wire:click="cancelDeleteRule"
class="px-4 py-2 bg-background-secondary border border-neutral rounded-lg hover:bg-background transition-colors text-sm font-medium">
class="text-base/40 hover:text-base transition-colors flex-shrink-0">
<x-ri-close-line class="size-5" />
</button>
</div>
<div class="flex gap-3 justify-end pt-4 border-t border-neutral/20">
<button
wire:click="cancelDeleteRule"
class="px-5 py-2.5 bg-background-secondary border border-neutral/30 rounded-lg hover:bg-background hover:border-neutral/50 transition-all text-sm font-medium text-base/80">
Cancel
</button>
<button
wire:click="deleteRule"
wire:loading.attr="disabled"
class="px-4 py-2 bg-error text-white rounded-lg hover:bg-error/90 transition-colors text-sm font-medium">
class="px-5 py-2.5 bg-error text-white rounded-lg hover:bg-error/90 active:scale-95 transition-all text-sm font-semibold shadow-lg shadow-error/20 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2">
<x-ri-delete-bin-line class="size-4" wire:loading.remove wire:target="deleteRule" />
<span wire:loading.remove wire:target="deleteRule">Delete Rule</span>
<span wire:loading wire:target="deleteRule">Deleting...</span>
<span wire:loading wire:target="deleteRule" class="flex items-center gap-2">
<svg class="animate-spin size-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Deleting...
</span>
</button>
</div>
</div>