Add a setting for repeating notifications or not
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/analogj/scrutiny/webapp/backend/pkg"
|
"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/m20201107210306"
|
||||||
"github.com/analogj/scrutiny/webapp/backend/pkg/database/migrations/m20220503120000"
|
"github.com/analogj/scrutiny/webapp/backend/pkg/database/migrations/m20220503120000"
|
||||||
@@ -17,8 +20,6 @@ import (
|
|||||||
"github.com/influxdata/influxdb-client-go/v2/api/http"
|
"github.com/influxdata/influxdb-client-go/v2/api/http"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -369,6 +370,21 @@ func (sr *scrutinyRepository) Migrate(ctx context.Context) error {
|
|||||||
return tx.Create(&defaultSettings).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 {
|
if err := m.Migrate(); err != nil {
|
||||||
|
|||||||
@@ -20,5 +20,6 @@ type Settings struct {
|
|||||||
NotifyLevel int `json:"notify_level" mapstructure:"notify_level"`
|
NotifyLevel int `json:"notify_level" mapstructure:"notify_level"`
|
||||||
StatusFilterAttributes int `json:"status_filter_attributes" mapstructure:"status_filter_attributes"`
|
StatusFilterAttributes int `json:"status_filter_attributes" mapstructure:"status_filter_attributes"`
|
||||||
StatusThreshold int `json:"status_threshold" mapstructure:"status_threshold"`
|
StatusThreshold int `json:"status_threshold" mapstructure:"status_threshold"`
|
||||||
|
RepeatNotifications bool `json:"repeat_notifications" mapstructure:"repeat_notifications"`
|
||||||
} `json:"metrics" mapstructure:"metrics"`
|
} `json:"metrics" mapstructure:"metrics"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ export interface AppConfig {
|
|||||||
notify_level?: MetricsNotifyLevel
|
notify_level?: MetricsNotifyLevel
|
||||||
status_filter_attributes?: MetricsStatusFilterAttributes
|
status_filter_attributes?: MetricsStatusFilterAttributes
|
||||||
status_threshold?: MetricsStatusThreshold
|
status_threshold?: MetricsStatusThreshold
|
||||||
|
repeat_notifications?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -82,7 +83,8 @@ export const appConfig: AppConfig = {
|
|||||||
metrics: {
|
metrics: {
|
||||||
notify_level: MetricsNotifyLevel.Fail,
|
notify_level: MetricsNotifyLevel.Fail,
|
||||||
status_filter_attributes: MetricsStatusFilterAttributes.All,
|
status_filter_attributes: MetricsStatusFilterAttributes.All,
|
||||||
status_threshold: MetricsStatusThreshold.Both
|
status_threshold: MetricsStatusThreshold.Both,
|
||||||
|
repeat_notifications: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+10
@@ -84,6 +84,16 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col mt-5 gt-md:flex-row">
|
||||||
|
<mat-form-field class="flex-auto gt-xs:pr-3 gt-md:pr-3">
|
||||||
|
<mat-label>Repeat Notifications</mat-label>
|
||||||
|
<mat-select [(ngModel)]=repeatNotifications>
|
||||||
|
<mat-option [value]=true>Always</mat-option>
|
||||||
|
<mat-option [value]=false>Only when the value has changed</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|||||||
+4
-1
@@ -28,6 +28,7 @@ export class DashboardSettingsComponent implements OnInit {
|
|||||||
theme: string;
|
theme: string;
|
||||||
statusThreshold: number;
|
statusThreshold: number;
|
||||||
statusFilterAttributes: number;
|
statusFilterAttributes: number;
|
||||||
|
repeatNotifications: boolean;
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
private _unsubscribeAll: Subject<void>;
|
private _unsubscribeAll: Subject<void>;
|
||||||
@@ -55,6 +56,7 @@ export class DashboardSettingsComponent implements OnInit {
|
|||||||
|
|
||||||
this.statusFilterAttributes = config.metrics.status_filter_attributes;
|
this.statusFilterAttributes = config.metrics.status_filter_attributes;
|
||||||
this.statusThreshold = config.metrics.status_threshold;
|
this.statusThreshold = config.metrics.status_threshold;
|
||||||
|
this.repeatNotifications = config.metrics.repeat_notifications;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +72,8 @@ export class DashboardSettingsComponent implements OnInit {
|
|||||||
theme: this.theme as Theme,
|
theme: this.theme as Theme,
|
||||||
metrics: {
|
metrics: {
|
||||||
status_filter_attributes: this.statusFilterAttributes as MetricsStatusFilterAttributes,
|
status_filter_attributes: this.statusFilterAttributes as MetricsStatusFilterAttributes,
|
||||||
status_threshold: this.statusThreshold as MetricsStatusThreshold
|
status_threshold: this.statusThreshold as MetricsStatusThreshold,
|
||||||
|
repeat_notifications: this.repeatNotifications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._configService.config = newSettings
|
this._configService.config = newSettings
|
||||||
|
|||||||
Reference in New Issue
Block a user