fix: replace notify calls with dispatch for consistent notification handling

This commit is contained in:
2025-12-18 08:49:24 -05:00
parent 85311f35e4
commit 6f5a66bea6

View File

@@ -554,7 +554,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('Firewall policies updated successfully', 'success'); $this->dispatch('notify', 'Firewall policies updated successfully', 'success');
$this->loadFirewallOptions(); $this->loadFirewallOptions();
} else { } else {
$this->error = 'Failed to update firewall policies'; $this->error = 'Failed to update firewall policies';
@@ -717,7 +717,7 @@ class Firewall extends Component
} }
if ($response->successful()) { if ($response->successful()) {
$this->notify('Rule ' . ($this->editingRuleIndex !== null ? 'updated' : 'created') . ' successfully', 'success'); $this->dispatch('notify', 'Rule ' . ($this->editingRuleIndex !== null ? 'updated' : 'created') . ' successfully', 'success');
$this->resetRuleForm(); $this->resetRuleForm();
$this->editingRuleIndex = null; $this->editingRuleIndex = null;
$this->showRuleForm = false; $this->showRuleForm = false;
@@ -754,7 +754,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('Rule ' . ($newEnable == 1 ? 'enabled' : 'disabled'), 'success'); $this->dispatch('notify', 'Rule ' . ($newEnable == 1 ? 'enabled' : 'disabled'), 'success');
$this->loadFirewallRules(); $this->loadFirewallRules();
} else { } else {
$this->error = 'Failed to toggle rule'; $this->error = 'Failed to toggle rule';
@@ -794,7 +794,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('Rule deleted successfully', 'success'); $this->dispatch('notify', 'Rule deleted successfully', 'success');
$this->loadFirewallRules(); $this->loadFirewallRules();
} else { } else {
$this->error = 'Failed to delete rule'; $this->error = 'Failed to delete rule';
@@ -825,7 +825,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('Rules reordered successfully', 'success'); $this->dispatch('notify', 'Rules reordered successfully', 'success');
$this->loadFirewallRules(); $this->loadFirewallRules();
} else { } else {
$this->error = 'Failed to reorder rules'; $this->error = 'Failed to reorder rules';
@@ -931,7 +931,7 @@ class Firewall extends Component
} }
if ($response->successful()) { if ($response->successful()) {
$this->notify('Alias ' . ($this->editingAliasName ? 'updated' : 'created') . ' successfully', 'success'); $this->dispatch('notify', 'Alias ' . ($this->editingAliasName ? 'updated' : 'created') . ' successfully', 'success');
$this->resetAliasForm(); $this->resetAliasForm();
$this->editingAliasName = null; $this->editingAliasName = null;
$this->showAliasForm = false; $this->showAliasForm = false;
@@ -971,7 +971,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('Alias deleted successfully', 'success'); $this->dispatch('notify', 'Alias deleted successfully', 'success');
$this->loadAliases(); $this->loadAliases();
} else { } else {
$this->error = 'Failed to delete alias'; $this->error = 'Failed to delete alias';
@@ -1054,7 +1054,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('IPSet created successfully', 'success'); $this->dispatch('notify', 'IPSet created successfully', 'success');
$this->resetIPSetForm(); $this->resetIPSetForm();
$this->showIPSetForm = false; $this->showIPSetForm = false;
$this->loadIPSets(); $this->loadIPSets();
@@ -1093,7 +1093,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('IPSet deleted successfully', 'success'); $this->dispatch('notify', 'IPSet deleted successfully', 'success');
$this->loadIPSets(); $this->loadIPSets();
// Clear selected IPSet if it was deleted // Clear selected IPSet if it was deleted
@@ -1196,7 +1196,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('IP/CIDR added to IPSet successfully', 'success'); $this->dispatch('notify', 'IP/CIDR added to IPSet successfully', 'success');
$this->memberCidr = ''; $this->memberCidr = '';
$this->memberComment = ''; $this->memberComment = '';
$this->memberNomatch = false; $this->memberNomatch = false;
@@ -1240,7 +1240,7 @@ class Firewall extends Component
); );
if ($response->successful()) { if ($response->successful()) {
$this->notify('IP/CIDR removed from IPSet successfully', 'success'); $this->dispatch('notify', 'IP/CIDR removed from IPSet successfully', 'success');
$this->loadIPSetMembers($this->selectedIPSetName); $this->loadIPSetMembers($this->selectedIPSetName);
} else { } else {
$this->error = 'Failed to remove member'; $this->error = 'Failed to remove member';
@@ -1368,7 +1368,7 @@ class Firewall extends Component
$this->lastLogRefresh = now()->format('Y-m-d H:i:s'); $this->lastLogRefresh = now()->format('Y-m-d H:i:s');
// Notify user of successful refresh // Notify user of successful refresh
$this->notify('Loaded ' . count($this->firewallLogs) . ' firewall log entries', 'success'); $this->dispatch('notify', 'Loaded ' . count($this->firewallLogs) . ' firewall log entries', 'success');
Log::info('Firewall log parsing summary', [ Log::info('Firewall log parsing summary', [
'total_raw_logs' => count($allRawLogs), 'total_raw_logs' => count($allRawLogs),
@@ -1933,7 +1933,7 @@ class Firewall extends Component
'outgoing_policy' => $configData['policyOut'], 'outgoing_policy' => $configData['policyOut'],
]); ]);
$this->notify('Configuration saved successfully', 'success'); $this->dispatch('notify', 'Configuration saved successfully', 'success');
$this->closeSaveConfigModal(); $this->closeSaveConfigModal();
$this->loadSavedConfigurations(); $this->loadSavedConfigurations();
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -2214,9 +2214,9 @@ class Firewall extends Component
$message = 'Configuration applied successfully'; $message = 'Configuration applied successfully';
if ($incompatibleRulesDisabled > 0) { if ($incompatibleRulesDisabled > 0) {
$message .= ". {$incompatibleRulesDisabled} rule(s) were disabled due to incompatibility with this VPS."; $message .= ". {$incompatibleRulesDisabled} rule(s) were disabled due to incompatibility with this VPS.";
$this->notify($message, 'warning'); $this->dispatch('notify', $message, 'warning');
} else { } else {
$this->notify($message, 'success'); $this->dispatch('notify', $message, 'success');
} }
$this->closeApplyConfigModal(); $this->closeApplyConfigModal();
@@ -2276,7 +2276,7 @@ class Firewall extends Component
$config->delete(); $config->delete();
$this->notify('Configuration deleted successfully', 'success'); $this->dispatch('notify', 'Configuration deleted successfully', 'success');
$this->cancelDeleteConfiguration(); $this->cancelDeleteConfiguration();
$this->loadSavedConfigurations(); $this->loadSavedConfigurations();
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -2355,7 +2355,7 @@ class Firewall extends Component
'configuration_name' => trim($this->renameConfigName), 'configuration_name' => trim($this->renameConfigName),
]); ]);
$this->notify('Configuration renamed successfully', 'success'); $this->dispatch('notify', 'Configuration renamed successfully', 'success');
$this->closeRenameConfigModal(); $this->closeRenameConfigModal();
$this->loadSavedConfigurations(); $this->loadSavedConfigurations();
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -2604,9 +2604,9 @@ class Firewall extends Component
$totalCount = count($results); $totalCount = count($results);
if ($successCount === $totalCount) { if ($successCount === $totalCount) {
$this->notify("Configuration applied to all {$successCount} servers successfully", 'success'); $this->dispatch('notify', "Configuration applied to all {$successCount} servers successfully", 'success');
} elseif ($successCount > 0) { } elseif ($successCount > 0) {
$this->notify("Configuration applied to {$successCount} of {$totalCount} servers", 'warning'); $this->dispatch('notify', "Configuration applied to {$successCount} of {$totalCount} servers", 'warning');
} else { } else {
$this->error = 'Failed to apply configuration to any servers'; $this->error = 'Failed to apply configuration to any servers';
$this->showErrorModal = true; $this->showErrorModal = true;
@@ -2696,4 +2696,4 @@ class Firewall extends Component
'sidebar' => true, 'sidebar' => true,
]); ]);
} }
} }