Fix multiple bugs

This commit is contained in:
John Baublitz
2018-05-20 12:12:10 -04:00
committed by bergquist
parent 3cb0e27e1c
commit fca97535d1
8 changed files with 95 additions and 36 deletions

View File

@@ -193,12 +193,15 @@ func GetAlertNotifications(c *m.ReqContext) Response {
for _, notification := range query.Result {
result = append(result, &dtos.AlertNotification{
Id: notification.Id,
Name: notification.Name,
Type: notification.Type,
IsDefault: notification.IsDefault,
Created: notification.Created,
Updated: notification.Updated,
Id: notification.Id,
Name: notification.Name,
Type: notification.Type,
IsDefault: notification.IsDefault,
Created: notification.Created,
Updated: notification.Updated,
Frequency: notification.Frequency.String(),
NotifyOnce: notification.NotifyOnce,
Settings: notification.Settings,
})
}
@@ -215,7 +218,19 @@ func GetAlertNotificationByID(c *m.ReqContext) Response {
return Error(500, "Failed to get alert notifications", err)
}
return JSON(200, query.Result)
result := &dtos.AlertNotification{
Id: query.Result.Id,
Name: query.Result.Name,
Type: query.Result.Type,
IsDefault: query.Result.IsDefault,
Created: query.Result.Created,
Updated: query.Result.Updated,
Frequency: query.Result.Frequency.String(),
NotifyOnce: query.Result.NotifyOnce,
Settings: query.Result.Settings,
}
return JSON(200, result)
}
func CreateAlertNotification(c *m.ReqContext, cmd m.CreateAlertNotificationCommand) Response {
@@ -225,7 +240,19 @@ func CreateAlertNotification(c *m.ReqContext, cmd m.CreateAlertNotificationComma
return Error(500, "Failed to create alert notification", err)
}
return JSON(200, cmd.Result)
result := &dtos.AlertNotification{
Id: cmd.Result.Id,
Name: cmd.Result.Name,
Type: cmd.Result.Type,
IsDefault: cmd.Result.IsDefault,
Created: cmd.Result.Created,
Updated: cmd.Result.Updated,
Frequency: cmd.Result.Frequency.String(),
NotifyOnce: cmd.Result.NotifyOnce,
Settings: cmd.Result.Settings,
}
return JSON(200, result)
}
func UpdateAlertNotification(c *m.ReqContext, cmd m.UpdateAlertNotificationCommand) Response {
@@ -235,7 +262,19 @@ func UpdateAlertNotification(c *m.ReqContext, cmd m.UpdateAlertNotificationComma
return Error(500, "Failed to update alert notification", err)
}
return JSON(200, cmd.Result)
result := &dtos.AlertNotification{
Id: cmd.Result.Id,
Name: cmd.Result.Name,
Type: cmd.Result.Type,
IsDefault: cmd.Result.IsDefault,
Created: cmd.Result.Created,
Updated: cmd.Result.Updated,
Frequency: cmd.Result.Frequency.String(),
NotifyOnce: cmd.Result.NotifyOnce,
Settings: cmd.Result.Settings,
}
return JSON(200, result)
}
func DeleteAlertNotification(c *m.ReqContext) Response {

View File

@@ -24,14 +24,15 @@ type AlertRule struct {
}
type AlertNotification struct {
Id int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
IsDefault bool `json:"isDefault"`
NotifyOnce bool `json:"notifyOnce"`
Frequency bool `json:"frequency"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Id int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
IsDefault bool `json:"isDefault"`
NotifyOnce bool `json:"notifyOnce"`
Frequency string `json:"frequency"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Settings *simplejson.Json `json:"settings"`
}
type AlertTestCommand struct {
@@ -64,7 +65,7 @@ type NotificationTestCommand struct {
Name string `json:"name"`
Type string `json:"type"`
NotifyOnce bool `json:"notifyOnce"`
Frequency time.Duration `json:"frequency"`
Frequency string `json:"frequency"`
Settings *simplejson.Json `json:"settings"`
}