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
df2b2e30
Commit
df2b2e30
authored
Nov 24, 2016
by
Carl Bergquist
Committed by
Torkel Ödegaard
Nov 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): validate alerts before saving dashboard (#6691)
ref #6576
parent
223f2320
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
pkg/api/dashboard.go
+10
-0
pkg/services/alerting/commands.go
+17
-0
No files found.
pkg/api/dashboard.go
View file @
df2b2e30
...
@@ -120,6 +120,16 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
...
@@ -120,6 +120,16 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
cmd
.
UserId
=
c
.
UserId
cmd
.
UserId
=
c
.
UserId
}
}
validateAlertsCmd
:=
alerting
.
ValidateDashboardAlertsCommand
{
OrgId
:
c
.
OrgId
,
UserId
:
c
.
UserId
,
Dashboard
:
cmd
.
Result
,
}
if
err
:=
bus
.
Dispatch
(
&
validateAlertsCmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Invalid alert data. Cannot save dashboard"
,
err
)
}
dash
:=
cmd
.
GetDashboardModel
()
dash
:=
cmd
.
GetDashboardModel
()
if
dash
.
Id
==
0
{
if
dash
.
Id
==
0
{
limitReached
,
err
:=
middleware
.
QuotaReached
(
c
,
"dashboard"
)
limitReached
,
err
:=
middleware
.
QuotaReached
(
c
,
"dashboard"
)
...
...
pkg/services/alerting/commands.go
View file @
df2b2e30
...
@@ -11,8 +11,25 @@ type UpdateDashboardAlertsCommand struct {
...
@@ -11,8 +11,25 @@ type UpdateDashboardAlertsCommand struct {
Dashboard
*
m
.
Dashboard
Dashboard
*
m
.
Dashboard
}
}
type
ValidateDashboardAlertsCommand
struct
{
UserId
int64
OrgId
int64
Dashboard
*
m
.
Dashboard
}
func
init
()
{
func
init
()
{
bus
.
AddHandler
(
"alerting"
,
updateDashboardAlerts
)
bus
.
AddHandler
(
"alerting"
,
updateDashboardAlerts
)
bus
.
AddHandler
(
"alerting"
,
validateDashboardAlerts
)
}
func
validateDashboardAlerts
(
cmd
*
ValidateDashboardAlertsCommand
)
error
{
extractor
:=
NewDashAlertExtractor
(
cmd
.
Dashboard
,
cmd
.
OrgId
)
if
_
,
err
:=
extractor
.
GetAlerts
();
err
!=
nil
{
return
err
}
return
nil
}
}
func
updateDashboardAlerts
(
cmd
*
UpdateDashboardAlertsCommand
)
error
{
func
updateDashboardAlerts
(
cmd
*
UpdateDashboardAlertsCommand
)
error
{
...
...
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