diff --git a/pkg/api/alerting.go b/pkg/api/alerting.go index aaa5752c446..46a0df32f01 100644 --- a/pkg/api/alerting.go +++ b/pkg/api/alerting.go @@ -265,12 +265,17 @@ func PauseAlert(c *middleware.Context, cmd models.PauseAlertCommand) Response { return ApiError(500, "", err) } - response := "un paused" + var response models.AlertStateType = models.AlertStateNoData if cmd.Paused { - response = "paused" + response = models.AlertStatePaused } - return ApiSuccess("Alert " + response) + result := map[string]interface{}{ + "alertId": cmd.AlertId, + "state": response, + } + + return Json(200, result) } func getAlertIdForRequest(c *middleware.Context) (int64, error) { diff --git a/pkg/models/alert.go b/pkg/models/alert.go index 419e832ae39..de103143ac3 100644 --- a/pkg/models/alert.go +++ b/pkg/models/alert.go @@ -104,7 +104,7 @@ type SaveAlertsCommand struct { type PauseAlertCommand struct { OrgId int64 AlertId int64 `json:"alertId"` - Paused bool `json:"bool"` + Paused bool `json:"paused"` } type SetAlertStateCommand struct { diff --git a/public/app/features/alerting/alert_list_ctrl.ts b/public/app/features/alerting/alert_list_ctrl.ts index 4b429e961a7..5d62a0790cb 100644 --- a/public/app/features/alerting/alert_list_ctrl.ts +++ b/public/app/features/alerting/alert_list_ctrl.ts @@ -23,7 +23,7 @@ export class AlertListCtrl { }; /** @ngInject */ - constructor(private backendSrv, private $location) { + constructor(private backendSrv, private $location, private $scope) { var params = $location.search(); this.filters.state = params.state || null; this.loadAlerts(); @@ -43,6 +43,19 @@ export class AlertListCtrl { }); } + pauseAlertRule(alertId: any) { + var alert = _.find(this.alerts, {id: alertId}); + + var payload = { + paused: alert.state !== "paused" + }; + + this.backendSrv.post(`/api/alerts/${alertId}/pause`, payload).then(result => { + alert.state = result.state; + alert.stateModel = alertDef.getStateDisplayModel(result.state); + }); + } + openHowTo() { appEvents.emit('show-modal', { src: 'public/app/features/alerting/partials/alert_howto.html', diff --git a/public/app/features/alerting/partials/alert_list.html b/public/app/features/alerting/partials/alert_list.html index a8678bc4cdc..da4e3b3a695 100644 --- a/public/app/features/alerting/partials/alert_list.html +++ b/public/app/features/alerting/partials/alert_list.html @@ -33,6 +33,9 @@ +
+ pause +