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
c6cf7647
Commit
c6cf7647
authored
Oct 11, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): pausing alerts requires alert id
parent
8b0c29b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
44 deletions
+7
-44
pkg/api/alerting.go
+2
-34
pkg/api/api.go
+1
-3
pkg/api/dtos/alerting.go
+2
-4
public/app/features/alerting/alert_list_ctrl.ts
+2
-3
No files found.
pkg/api/alerting.go
View file @
c6cf7647
...
...
@@ -252,16 +252,11 @@ func NotificationTest(c *middleware.Context, dto dtos.NotificationTestCommand) R
return
ApiSuccess
(
"Test notification sent"
)
}
//POST /api/
pause-alert
//POST /api/
:alertId/pause
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
)
}
cmd
:=
models
.
PauseAlertCommand
{
OrgId
:
c
.
OrgId
,
AlertId
:
alertId
,
AlertId
:
c
.
ParamsInt64
(
"alertId"
)
,
Paused
:
dto
.
Paused
,
}
...
...
@@ -284,30 +279,3 @@ func PauseAlert(c *middleware.Context, dto dtos.PauseAlertCommand) Response {
return
Json
(
200
,
result
)
}
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"
)
}
if
alertId
==
0
{
//fetch alertId
query
:=
models
.
GetAlertsQuery
{
OrgId
:
orgId
,
DashboardId
:
dashboardId
,
PanelId
:
panelId
,
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
return
0
,
err
}
if
len
(
query
.
Result
)
!=
1
{
return
0
,
fmt
.
Errorf
(
"PanelId is not unique on dashboard"
)
}
alertId
=
query
.
Result
[
0
]
.
Id
}
return
alertId
,
nil
}
pkg/api/api.go
View file @
c6cf7647
...
...
@@ -252,14 +252,12 @@ func Register(r *macaron.Macaron) {
r
.
Group
(
"/alerts"
,
func
()
{
r
.
Post
(
"/test"
,
bind
(
dtos
.
AlertTestCommand
{}),
wrap
(
AlertTest
))
r
.
Post
(
"/:alertId/pause"
,
ValidateOrgAlert
,
bind
(
dtos
.
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 @
c6cf7647
...
...
@@ -60,8 +60,6 @@ type NotificationTestCommand struct {
}
type
PauseAlertCommand
struct
{
AlertId
int64
`json:"alertId"`
DashboardId
int64
`json:"dashboardId"`
PanelId
int64
`json:"panelId"`
Paused
bool
`json:"paused"`
AlertId
int64
`json:"alertId"`
Paused
bool
`json:"paused"`
}
public/app/features/alerting/alert_list_ctrl.ts
View file @
c6cf7647
...
...
@@ -47,11 +47,10 @@ export class AlertListCtrl {
var
alert
=
_
.
find
(
this
.
alerts
,
{
id
:
alertId
});
var
payload
=
{
paused
:
alert
.
state
!==
"paused"
,
alertId
:
alert
.
id
paused
:
alert
.
state
!==
"paused"
};
this
.
backendSrv
.
post
(
`/api/
pause-alert
`
,
payload
).
then
(
result
=>
{
this
.
backendSrv
.
post
(
`/api/
alerts/
${
alert
.
id
}
/pause
`
,
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