removes d in disableResolvedMessage

This commit is contained in:
bergquist
2018-10-17 10:41:18 +02:00
parent 5566a61aef
commit 70385119bc
10 changed files with 109 additions and 109 deletions

View File

@@ -57,7 +57,7 @@ func NewAlertNotification(notification *models.AlertNotification) *AlertNotifica
Updated: notification.Updated, Updated: notification.Updated,
Frequency: formatShort(notification.Frequency), Frequency: formatShort(notification.Frequency),
SendReminder: notification.SendReminder, SendReminder: notification.SendReminder,
DisableResolvedMessage: notification.DisableResolvedMessage, DisableResolveMessage: notification.DisableResolveMessage,
Settings: notification.Settings, Settings: notification.Settings,
} }
} }
@@ -68,7 +68,7 @@ type AlertNotification struct {
Type string `json:"type"` Type string `json:"type"`
IsDefault bool `json:"isDefault"` IsDefault bool `json:"isDefault"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
DisableResolvedMessage bool `json:"disableResolvedMessage"` DisableResolveMessage bool `json:"disableResolveMessage"`
Frequency string `json:"frequency"` Frequency string `json:"frequency"`
Created time.Time `json:"created"` Created time.Time `json:"created"`
Updated time.Time `json:"updated"` Updated time.Time `json:"updated"`
@@ -105,7 +105,7 @@ type NotificationTestCommand struct {
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
DisableResolvedMessage bool `json:"disableResolvedMessage"` DisableResolveMessage bool `json:"disableResolveMessage"`
Frequency string `json:"frequency"` Frequency string `json:"frequency"`
Settings *simplejson.Json `json:"settings"` Settings *simplejson.Json `json:"settings"`
} }

View File

@@ -28,7 +28,7 @@ type AlertNotification struct {
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
DisableResolvedMessage bool `json:"disableResolvedMessage"` DisableResolveMessage bool `json:"disableResolveMessage"`
Frequency time.Duration `json:"frequency"` Frequency time.Duration `json:"frequency"`
IsDefault bool `json:"isDefault"` IsDefault bool `json:"isDefault"`
Settings *simplejson.Json `json:"settings"` Settings *simplejson.Json `json:"settings"`
@@ -40,7 +40,7 @@ type CreateAlertNotificationCommand struct {
Name string `json:"name" binding:"Required"` Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"` Type string `json:"type" binding:"Required"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
DisableResolvedMessage bool `json:"disableResolvedMessage"` DisableResolveMessage bool `json:"disableResolveMessage"`
Frequency string `json:"frequency"` Frequency string `json:"frequency"`
IsDefault bool `json:"isDefault"` IsDefault bool `json:"isDefault"`
Settings *simplejson.Json `json:"settings"` Settings *simplejson.Json `json:"settings"`
@@ -54,7 +54,7 @@ type UpdateAlertNotificationCommand struct {
Name string `json:"name" binding:"Required"` Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"` Type string `json:"type" binding:"Required"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
DisableResolvedMessage bool `json:"disableResolvedMessage"` DisableResolveMessage bool `json:"disableResolveMessage"`
Frequency string `json:"frequency"` Frequency string `json:"frequency"`
IsDefault bool `json:"isDefault"` IsDefault bool `json:"isDefault"`
Settings *simplejson.Json `json:"settings" binding:"Required"` Settings *simplejson.Json `json:"settings" binding:"Required"`

View File

@@ -27,7 +27,7 @@ type Notifier interface {
GetNotifierId() int64 GetNotifierId() int64
GetIsDefault() bool GetIsDefault() bool
GetSendReminder() bool GetSendReminder() bool
GetDisableResolvedMessage() bool GetDisableResolveMessage() bool
GetFrequency() time.Duration GetFrequency() time.Duration
} }

View File

@@ -20,7 +20,7 @@ type NotifierBase struct {
IsDeault bool IsDeault bool
UploadImage bool UploadImage bool
SendReminder bool SendReminder bool
DisableResolvedMessage bool DisableResolveMessage bool
Frequency time.Duration Frequency time.Duration
log log.Logger log log.Logger
@@ -40,7 +40,7 @@ func NewNotifierBase(model *models.AlertNotification) NotifierBase {
Type: model.Type, Type: model.Type,
UploadImage: uploadImage, UploadImage: uploadImage,
SendReminder: model.SendReminder, SendReminder: model.SendReminder,
DisableResolvedMessage: model.DisableResolvedMessage, DisableResolveMessage: model.DisableResolveMessage,
Frequency: model.Frequency, Frequency: model.Frequency,
log: log.New("alerting.notifier." + model.Name), log: log.New("alerting.notifier." + model.Name),
} }
@@ -84,8 +84,8 @@ func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalC
} }
} }
// Do not notify when state is OK if DisableResolvedMessage is set to true // Do not notify when state is OK if DisableResolveMessage is set to true
if context.Rule.State == models.AlertStateOK && n.DisableResolvedMessage { if context.Rule.State == models.AlertStateOK && n.DisableResolveMessage {
return false return false
} }
@@ -112,8 +112,8 @@ func (n *NotifierBase) GetSendReminder() bool {
return n.SendReminder return n.SendReminder
} }
func (n *NotifierBase) GetDisableResolvedMessage() bool { func (n *NotifierBase) GetDisableResolveMessage() bool {
return n.DisableResolvedMessage return n.DisableResolveMessage
} }
func (n *NotifierBase) GetFrequency() time.Duration { func (n *NotifierBase) GetFrequency() time.Duration {

View File

@@ -182,7 +182,7 @@ func TestBaseNotifier(t *testing.T) {
Convey("default value should be false for backwards compatibility", func() { Convey("default value should be false for backwards compatibility", func() {
base := NewNotifierBase(model) base := NewNotifierBase(model)
So(base.DisableResolvedMessage, ShouldBeFalse) So(base.DisableResolveMessage, ShouldBeFalse)
}) })
}) })
} }

View File

@@ -66,7 +66,7 @@ func GetAlertNotificationsToSend(query *m.GetAlertNotificationsToSendQuery) erro
alert_notification.updated, alert_notification.updated,
alert_notification.settings, alert_notification.settings,
alert_notification.is_default, alert_notification.is_default,
alert_notification.disable_resolved_message, alert_notification.disable_resolve_message,
alert_notification.send_reminder, alert_notification.send_reminder,
alert_notification.frequency alert_notification.frequency
FROM alert_notification FROM alert_notification
@@ -107,7 +107,7 @@ func getAlertNotificationInternal(query *m.GetAlertNotificationsQuery, sess *DBS
alert_notification.updated, alert_notification.updated,
alert_notification.settings, alert_notification.settings,
alert_notification.is_default, alert_notification.is_default,
alert_notification.disable_resolved_message, alert_notification.disable_resolve_message,
alert_notification.send_reminder, alert_notification.send_reminder,
alert_notification.frequency alert_notification.frequency
FROM alert_notification FROM alert_notification
@@ -173,7 +173,7 @@ func CreateAlertNotificationCommand(cmd *m.CreateAlertNotificationCommand) error
Type: cmd.Type, Type: cmd.Type,
Settings: cmd.Settings, Settings: cmd.Settings,
SendReminder: cmd.SendReminder, SendReminder: cmd.SendReminder,
DisableResolvedMessage: cmd.DisableResolvedMessage, DisableResolveMessage: cmd.DisableResolveMessage,
Frequency: frequency, Frequency: frequency,
Created: time.Now(), Created: time.Now(),
Updated: time.Now(), Updated: time.Now(),
@@ -213,7 +213,7 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error {
current.Type = cmd.Type current.Type = cmd.Type
current.IsDefault = cmd.IsDefault current.IsDefault = cmd.IsDefault
current.SendReminder = cmd.SendReminder current.SendReminder = cmd.SendReminder
current.DisableResolvedMessage = cmd.DisableResolvedMessage current.DisableResolveMessage = cmd.DisableResolveMessage
if current.SendReminder { if current.SendReminder {
if cmd.Frequency == "" { if cmd.Frequency == "" {
@@ -228,7 +228,7 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error {
current.Frequency = frequency current.Frequency = frequency
} }
sess.UseBool("is_default", "send_reminder") sess.UseBool("is_default", "send_reminder", "disable_resolve_message")
if affected, err := sess.ID(cmd.Id).Update(current); err != nil { if affected, err := sess.ID(cmd.Id).Update(current); err != nil {
return err return err

View File

@@ -219,7 +219,7 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
So(cmd.Result.OrgId, ShouldNotEqual, 0) So(cmd.Result.OrgId, ShouldNotEqual, 0)
So(cmd.Result.Type, ShouldEqual, "email") So(cmd.Result.Type, ShouldEqual, "email")
So(cmd.Result.Frequency, ShouldEqual, 10*time.Second) So(cmd.Result.Frequency, ShouldEqual, 10*time.Second)
So(cmd.Result.DisableResolvedMessage, ShouldBeFalse) So(cmd.Result.DisableResolveMessage, ShouldBeFalse)
Convey("Cannot save Alert Notification with the same name", func() { Convey("Cannot save Alert Notification with the same name", func() {
err = CreateAlertNotificationCommand(cmd) err = CreateAlertNotificationCommand(cmd)
@@ -232,7 +232,7 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
Type: "webhook", Type: "webhook",
OrgId: cmd.Result.OrgId, OrgId: cmd.Result.OrgId,
SendReminder: true, SendReminder: true,
DisableResolvedMessage: true, DisableResolveMessage: true,
Frequency: "60s", Frequency: "60s",
Settings: simplejson.New(), Settings: simplejson.New(),
Id: cmd.Result.Id, Id: cmd.Result.Id,
@@ -241,7 +241,7 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(newCmd.Result.Name, ShouldEqual, "NewName") So(newCmd.Result.Name, ShouldEqual, "NewName")
So(newCmd.Result.Frequency, ShouldEqual, 60*time.Second) So(newCmd.Result.Frequency, ShouldEqual, 60*time.Second)
So(newCmd.Result.DisableResolvedMessage, ShouldBeTrue) So(newCmd.Result.DisableResolveMessage, ShouldBeTrue)
}) })
Convey("Can update alert notification to disable sending of reminders", func() { Convey("Can update alert notification to disable sending of reminders", func() {

View File

@@ -71,8 +71,8 @@ func addAlertMigrations(mg *Migrator) {
mg.AddMigration("Add column send_reminder", NewAddColumnMigration(alert_notification, &Column{ mg.AddMigration("Add column send_reminder", NewAddColumnMigration(alert_notification, &Column{
Name: "send_reminder", Type: DB_Bool, Nullable: true, Default: "0", Name: "send_reminder", Type: DB_Bool, Nullable: true, Default: "0",
})) }))
mg.AddMigration("Add column disable_resolved_message", NewAddColumnMigration(alert_notification, &Column{ mg.AddMigration("Add column disable_resolve_message", NewAddColumnMigration(alert_notification, &Column{
Name: "disable_resolved_message", Type: DB_Bool, Nullable: false, Default: "0", Name: "disable_resolve_message", Type: DB_Bool, Nullable: false, Default: "0",
})) }))
mg.AddMigration("add index alert_notification org_id & name", NewAddIndexMigration(alert_notification, alert_notification.Indices[0])) mg.AddMigration("add index alert_notification org_id & name", NewAddIndexMigration(alert_notification, alert_notification.Indices[0]))

View File

@@ -12,7 +12,7 @@ export class AlertNotificationEditCtrl {
defaults: any = { defaults: any = {
type: 'email', type: 'email',
sendReminder: false, sendReminder: false,
disableResolvedMessage: false, disableResolveMessage: false,
frequency: '15m', frequency: '15m',
settings: { settings: {
httpMethod: 'POST', httpMethod: 'POST',

View File

@@ -21,28 +21,28 @@
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="Send on all alerts" label="Send on all alerts"
label-class="width-12" label-class="width-14"
checked="ctrl.model.isDefault" checked="ctrl.model.isDefault"
tooltip="Use this notification for all alerts"> tooltip="Use this notification for all alerts">
</gf-form-switch> </gf-form-switch>
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="Include image" label="Include image"
label-class="width-12" label-class="width-14"
checked="ctrl.model.settings.uploadImage" checked="ctrl.model.settings.uploadImage"
tooltip="Captures an image and include it in the notification"> tooltip="Captures an image and include it in the notification">
</gf-form-switch> </gf-form-switch>
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="Disable Resolved Message" label="Disable Resolve Message"
label-class="width-12" label-class="width-14"
checked="ctrl.model.disableResolvedMessage" checked="ctrl.model.disableResolveMessage"
tooltip="Disable the resolved message [OK] that is sent when alerting state returns to false"> tooltip="Disable the resolve message [OK] that is sent when alerting state returns to false">
</gf-form-switch> </gf-form-switch>
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="Send reminders" label="Send reminders"
label-class="width-12" label-class="width-14"
checked="ctrl.model.sendReminder" checked="ctrl.model.sendReminder"
tooltip="Send additional notifications for triggered alerts"> tooltip="Send additional notifications for triggered alerts">
</gf-form-switch> </gf-form-switch>