Move the ntfy alert sink to Settings, shared by all alert rules
Alert rules no longer carry their own ntfy topic/server; Settings now holds one process-wide ntfy sink (with its own "send test notification"), and the Alerts panel is left to just define rule conditions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ae4e550c1f
commit
18c2d72d22
+12
-4
@@ -1,4 +1,4 @@
|
||||
use crate::alerts::{AlertCondition, AlertSink};
|
||||
use crate::alerts::AlertCondition;
|
||||
use crate::data_value::{MetricPrimitiveKind, RegexToMetricPrimitiveMatcher};
|
||||
use crate::metric_primitive::MetricPrimitive;
|
||||
use crate::profile::{ChartType, Dashboard, Panel, Profile};
|
||||
@@ -171,6 +171,10 @@ pub struct SettingsDto {
|
||||
pub max_logs: Option<usize>,
|
||||
/// Id of the selected custom theme entry, if any. `None` means `color_scheme` alone determines the active palette.
|
||||
pub custom_theme_id: Option<String>,
|
||||
/// Ntfy topic every alert rule delivers to; `None` until configured.
|
||||
pub ntfy_topic: Option<String>,
|
||||
/// Ntfy server override; `None` means `https://ntfy.sh`.
|
||||
pub ntfy_server: Option<String>,
|
||||
}
|
||||
|
||||
impl From<&Settings> for SettingsDto {
|
||||
@@ -180,11 +184,13 @@ impl From<&Settings> for SettingsDto {
|
||||
active_profile: settings.profiles.active_profile.clone(),
|
||||
max_logs: settings.max_logs,
|
||||
custom_theme_id: settings.custom_theme_id.clone(),
|
||||
ntfy_topic: settings.ntfy_topic.clone(),
|
||||
ntfy_server: settings.ntfy_server.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `max_logs`/`custom_theme_id` distinguish "omitted" (leave unchanged) from "present" (null clears, value sets), via `deserialize_double_option`.
|
||||
/// `max_logs`/`custom_theme_id`/`ntfy_topic`/`ntfy_server` distinguish "omitted" (leave unchanged) from "present" (null clears, value sets), via `deserialize_double_option`.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct UpdateSettingsRequest {
|
||||
pub color_scheme: Option<ColorScheme>,
|
||||
@@ -192,6 +198,10 @@ pub struct UpdateSettingsRequest {
|
||||
pub max_logs: Option<Option<usize>>,
|
||||
#[serde(default, deserialize_with = "deserialize_double_option")]
|
||||
pub custom_theme_id: Option<Option<String>>,
|
||||
#[serde(default, deserialize_with = "deserialize_double_option")]
|
||||
pub ntfy_topic: Option<Option<String>>,
|
||||
#[serde(default, deserialize_with = "deserialize_double_option")]
|
||||
pub ntfy_server: Option<Option<String>>,
|
||||
}
|
||||
|
||||
/// Distinguishes a missing field (outer `None`) from present `null` (`Some(None)`) or present value (`Some(Some(value))`), which plain `Option<Option<T>>` can't do alone.
|
||||
@@ -208,7 +218,6 @@ pub struct CreateAlertRuleRequest {
|
||||
pub name: String,
|
||||
pub enabled: bool,
|
||||
pub condition: AlertCondition,
|
||||
pub sink: AlertSink,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -216,7 +225,6 @@ pub struct UpdateAlertRuleRequest {
|
||||
pub name: String,
|
||||
pub enabled: bool,
|
||||
pub condition: AlertCondition,
|
||||
pub sink: AlertSink,
|
||||
}
|
||||
|
||||
/// `server` defaults to `https://ntfy.sh` when absent.
|
||||
|
||||
Reference in New Issue
Block a user