mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
fix: reload alert and notification configs after import
- Import was saving configs to disk but not updating in-memory state - Added explicit reloading of alert thresholds after import - Added explicit reloading of webhooks after import - Added explicit reloading of email config after import - Settings now show immediately in UI without requiring restart Fixes #291 where imported alert thresholds and webhooks weren't visible until after service restart
This commit is contained in:
@@ -1394,6 +1394,43 @@ func (h *ConfigHandlers) HandleImportConfig(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
}
|
||||
|
||||
// Also reload alert and notification configs explicitly
|
||||
// (the monitor reload only reloads nodes unless it's a full reload)
|
||||
if h.monitor != nil {
|
||||
// Reload alert configuration
|
||||
if alertConfig, err := h.persistence.LoadAlertConfig(); err == nil {
|
||||
h.monitor.GetAlertManager().UpdateConfig(*alertConfig)
|
||||
log.Info().Msg("Reloaded alert configuration after import")
|
||||
} else {
|
||||
log.Warn().Err(err).Msg("Failed to reload alert configuration after import")
|
||||
}
|
||||
|
||||
// Reload webhook configuration
|
||||
if webhooks, err := h.persistence.LoadWebhooks(); err == nil {
|
||||
// Clear existing webhooks and add new ones
|
||||
notificationMgr := h.monitor.GetNotificationManager()
|
||||
// Get current webhooks to clear them
|
||||
for _, webhook := range notificationMgr.GetWebhooks() {
|
||||
notificationMgr.DeleteWebhook(webhook.ID)
|
||||
}
|
||||
// Add imported webhooks
|
||||
for _, webhook := range webhooks {
|
||||
notificationMgr.AddWebhook(webhook)
|
||||
}
|
||||
log.Info().Int("count", len(webhooks)).Msg("Reloaded webhook configuration after import")
|
||||
} else {
|
||||
log.Warn().Err(err).Msg("Failed to reload webhook configuration after import")
|
||||
}
|
||||
|
||||
// Reload email configuration
|
||||
if emailConfig, err := h.persistence.LoadEmailConfig(); err == nil {
|
||||
h.monitor.GetNotificationManager().SetEmailConfig(*emailConfig)
|
||||
log.Info().Msg("Reloaded email configuration after import")
|
||||
} else {
|
||||
log.Warn().Err(err).Msg("Failed to reload email configuration after import")
|
||||
}
|
||||
}
|
||||
|
||||
log.Info().Msg("Configuration imported successfully")
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user