diff --git a/webapp/backend/pkg/database/scrutiny_repository_migrations.go b/webapp/backend/pkg/database/scrutiny_repository_migrations.go index 542677f..e1b948b 100644 --- a/webapp/backend/pkg/database/scrutiny_repository_migrations.go +++ b/webapp/backend/pkg/database/scrutiny_repository_migrations.go @@ -4,6 +4,9 @@ import ( "context" "errors" "fmt" + "strconv" + "time" + "github.com/analogj/scrutiny/webapp/backend/pkg" "github.com/analogj/scrutiny/webapp/backend/pkg/database/migrations/m20201107210306" "github.com/analogj/scrutiny/webapp/backend/pkg/database/migrations/m20220503120000" @@ -17,8 +20,6 @@ import ( "github.com/influxdata/influxdb-client-go/v2/api/http" log "github.com/sirupsen/logrus" "gorm.io/gorm" - "strconv" - "time" ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -369,6 +370,21 @@ func (sr *scrutinyRepository) Migrate(ctx context.Context) error { return tx.Create(&defaultSettings).Error }, }, + { + ID: "m20231123123300", // add repeat_notifications setting. + Migrate: func(tx *gorm.DB) error { + //add repeat_notifications setting default. + var defaultSettings = []m20220716214900.Setting{ + { + SettingKeyName: "metrics.repeat_notifications", + SettingKeyDescription: "Whether to repeat all notifications or just when values change (true | false)", + SettingDataType: "bool", + SettingValueBool: true, + }, + } + return tx.Create(&defaultSettings).Error + }, + }, }) if err := m.Migrate(); err != nil { diff --git a/webapp/backend/pkg/models/settings.go b/webapp/backend/pkg/models/settings.go index f5564ef..e564301 100644 --- a/webapp/backend/pkg/models/settings.go +++ b/webapp/backend/pkg/models/settings.go @@ -17,8 +17,9 @@ type Settings struct { LineStroke string `json:"line_stroke" mapstructure:"line_stroke"` Metrics struct { - NotifyLevel int `json:"notify_level" mapstructure:"notify_level"` - StatusFilterAttributes int `json:"status_filter_attributes" mapstructure:"status_filter_attributes"` - StatusThreshold int `json:"status_threshold" mapstructure:"status_threshold"` + NotifyLevel int `json:"notify_level" mapstructure:"notify_level"` + StatusFilterAttributes int `json:"status_filter_attributes" mapstructure:"status_filter_attributes"` + StatusThreshold int `json:"status_threshold" mapstructure:"status_threshold"` + RepeatNotifications bool `json:"repeat_notifications" mapstructure:"repeat_notifications"` } `json:"metrics" mapstructure:"metrics"` } diff --git a/webapp/frontend/src/app/core/config/app.config.ts b/webapp/frontend/src/app/core/config/app.config.ts index c48d25a..1b6dfe3 100644 --- a/webapp/frontend/src/app/core/config/app.config.ts +++ b/webapp/frontend/src/app/core/config/app.config.ts @@ -55,6 +55,7 @@ export interface AppConfig { notify_level?: MetricsNotifyLevel status_filter_attributes?: MetricsStatusFilterAttributes status_threshold?: MetricsStatusThreshold + repeat_notifications?: boolean } } @@ -82,7 +83,8 @@ export const appConfig: AppConfig = { metrics: { notify_level: MetricsNotifyLevel.Fail, status_filter_attributes: MetricsStatusFilterAttributes.All, - status_threshold: MetricsStatusThreshold.Both + status_threshold: MetricsStatusThreshold.Both, + repeat_notifications: true } }; diff --git a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html index 69ebd76..0eb9a03 100644 --- a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html +++ b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html @@ -84,6 +84,16 @@ + +