Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
80479724
Commit
80479724
authored
Oct 11, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): make it possible to pause from alert tab
parent
f3825263
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
17 deletions
+21
-17
pkg/api/alerting.go
+12
-12
pkg/api/api.go
+3
-1
pkg/api/dtos/alerting.go
+1
-0
pkg/models/alert.go
+2
-2
public/app/features/alerting/alert_list_ctrl.ts
+3
-2
No files found.
pkg/api/alerting.go
View file @
80479724
...
...
@@ -252,13 +252,17 @@ func NotificationTest(c *middleware.Context, dto dtos.NotificationTestCommand) R
return
ApiSuccess
(
"Test notification sent"
)
}
//POST /api/alerts/:alertId/pause
func
PauseAlert
(
c
*
middleware
.
Context
,
cmd
models
.
PauseAlertCommand
)
Response
{
cmd
.
OrgId
=
c
.
OrgId
cmd
.
AlertId
=
c
.
ParamsInt64
(
":alertId"
)
//POST /api/pause-alert
func
PauseAlert
(
c
*
middleware
.
Context
,
dto
dtos
.
PauseAlertCommand
)
Response
{
alertId
,
err
:=
getAlertIdForRequest
(
c
.
OrgId
,
dto
.
AlertId
,
dto
.
PanelId
,
dto
.
DashboardId
)
if
err
!=
nil
{
return
ApiError
(
400
,
"Bad request"
,
err
)
}
if
cmd
.
AlertId
==
0
{
return
ApiError
(
400
,
"Missing alert id"
,
nil
)
cmd
:=
models
.
PauseAlertCommand
{
OrgId
:
c
.
OrgId
,
AlertId
:
alertId
,
Paused
:
dto
.
Paused
,
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
...
...
@@ -278,11 +282,7 @@ func PauseAlert(c *middleware.Context, cmd models.PauseAlertCommand) Response {
return
Json
(
200
,
result
)
}
func
getAlertIdForRequest
(
c
*
middleware
.
Context
)
(
int64
,
error
)
{
alertId
:=
c
.
QueryInt64
(
"alertId"
)
panelId
:=
c
.
QueryInt64
(
"panelId"
)
dashboardId
:=
c
.
QueryInt64
(
"dashboardId"
)
func
getAlertIdForRequest
(
orgId
,
alertId
,
panelId
,
dashboardId
int64
)
(
int64
,
error
)
{
if
alertId
==
0
&&
dashboardId
==
0
&&
panelId
==
0
{
return
0
,
fmt
.
Errorf
(
"Missing alertId or dashboardId and panelId"
)
}
...
...
@@ -290,7 +290,7 @@ func getAlertIdForRequest(c *middleware.Context) (int64, error) {
if
alertId
==
0
{
//fetch alertId
query
:=
models
.
GetAlertsQuery
{
OrgId
:
c
.
O
rgId
,
OrgId
:
o
rgId
,
DashboardId
:
dashboardId
,
PanelId
:
panelId
,
}
...
...
pkg/api/api.go
View file @
80479724
...
...
@@ -252,12 +252,14 @@ func Register(r *macaron.Macaron) {
r
.
Group
(
"/alerts"
,
func
()
{
r
.
Post
(
"/test"
,
bind
(
dtos
.
AlertTestCommand
{}),
wrap
(
AlertTest
))
r
.
Post
(
"/:alertId/pause"
,
ValidateOrgAlert
,
bind
(
m
.
PauseAlertCommand
{}),
wrap
(
PauseAlert
))
r
.
Get
(
"/:alertId"
,
ValidateOrgAlert
,
wrap
(
GetAlert
))
r
.
Get
(
"/"
,
wrap
(
GetAlerts
))
r
.
Get
(
"/states-for-dashboard"
,
wrap
(
GetAlertStatesForDashboard
))
})
r
.
Post
(
"/pause-alert"
,
bind
(
dtos
.
PauseAlertCommand
{}),
wrap
(
PauseAlert
))
r
.
Get
(
"/alert-notifications"
,
wrap
(
GetAlertNotifications
))
r
.
Group
(
"/alert-notifications"
,
func
()
{
...
...
pkg/api/dtos/alerting.go
View file @
80479724
...
...
@@ -63,4 +63,5 @@ type PauseAlertCommand struct {
AlertId
int64
`json:"alertId"`
DashboardId
int64
`json:"dashboardId"`
PanelId
int64
`json:"panelId"`
Paused
bool
`json:"paused"`
}
pkg/models/alert.go
View file @
80479724
...
...
@@ -103,8 +103,8 @@ type SaveAlertsCommand struct {
type
PauseAlertCommand
struct
{
OrgId
int64
AlertId
int64
`json:"alertId"`
Paused
bool
`json:"paused"`
AlertId
int64
Paused
bool
}
type
SetAlertStateCommand
struct
{
...
...
public/app/features/alerting/alert_list_ctrl.ts
View file @
80479724
...
...
@@ -47,10 +47,11 @@ export class AlertListCtrl {
var
alert
=
_
.
find
(
this
.
alerts
,
{
id
:
alertId
});
var
payload
=
{
paused
:
alert
.
state
!==
"paused"
paused
:
alert
.
state
!==
"paused"
,
alertId
:
alert
.
id
};
this
.
backendSrv
.
post
(
`/api/
alerts/
${
alertId
}
/pause
`
,
payload
).
then
(
result
=>
{
this
.
backendSrv
.
post
(
`/api/
pause-alert
`
,
payload
).
then
(
result
=>
{
alert
.
state
=
result
.
state
;
alert
.
stateModel
=
alertDef
.
getStateDisplayModel
(
result
.
state
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment