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
f5809c02
Commit
f5809c02
authored
Sep 13, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(build): trying to fix build
parent
9cd51778
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
57 deletions
+34
-57
pkg/services/alerting/notifiers/base_test.go
+28
-28
pkg/services/alerting/test_notification.go
+6
-10
public/app/features/alerting/notification_edit_ctrl.ts
+0
-1
public/app/features/alerting/partials/notification_edit.html
+0
-18
No files found.
pkg/services/alerting/notifiers/base_test.go
View file @
f5809c02
package
notifiers
import
.
"github.com/smartystreets/goconvey/convey"
func
TestBaseNotifier
(
/* t *testing.T */
)
{
//
Convey("Parsing base notification state", t, func() {
//
//
Convey("matches", func() {
//
json := `
//
{
//
"states": "critical"
//
}`
//
//
settingsJSON, _ := simplejson.NewJson([]byte(json))
//
not := NewNotifierBase("ops", "email", settingsJSON)
//
So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue)
//
})
//
//
Convey("does not match", func() {
//
json := `
//
{
//
"severityFilter": "critical"
//
}`
//
//
settingsJSON, _ := simplejson.NewJson([]byte(json))
//
not := NewNotifierBase("ops", "email", settingsJSON)
//
So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse)
//
})
//
})
}
//
import . "github.com/smartystreets/goconvey/convey"
//
// func TestBaseNotifier( t *testing.T
) {
//
Convey("Parsing base notification state", t, func() {
//
//
Convey("matches", func() {
//
json := `
//
{
//
"states": "critical"
//
}`
//
//
settingsJSON, _ := simplejson.NewJson([]byte(json))
//
not := NewNotifierBase("ops", "email", settingsJSON)
//
So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue)
//
})
//
//
Convey("does not match", func() {
//
json := `
//
{
//
"severityFilter": "critical"
//
}`
//
//
settingsJSON, _ := simplejson.NewJson([]byte(json))
//
not := NewNotifierBase("ops", "email", settingsJSON)
//
So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse)
//
})
//
})
//
}
pkg/services/alerting/test_notification.go
View file @
f5809c02
...
...
@@ -35,38 +35,34 @@ func handleNotificationTestCommand(cmd *NotificationTestCommand) error {
return
err
}
notifier
.
sendNotifications
([]
Notifier
{
notifiers
},
createTestEvalContext
(
cmd
.
State
))
notifier
.
sendNotifications
([]
Notifier
{
notifiers
},
createTestEvalContext
())
return
nil
}
func
createTestEvalContext
(
state
m
.
AlertStateType
)
*
EvalContext
{
func
createTestEvalContext
()
*
EvalContext
{
testRule
:=
&
Rule
{
DashboardId
:
1
,
PanelId
:
1
,
Name
:
"Test notification"
,
Message
:
"Someone is testing the alert notification within grafana."
,
State
:
state
,
State
:
m
.
AlertStateAlerting
,
}
ctx
:=
NewEvalContext
(
testRule
)
ctx
.
ImagePublicUrl
=
"http://grafana.org/assets/img/blog/mixed_styles.png"
ctx
.
IsTestRun
=
true
ctx
.
Firing
=
state
==
m
.
AlertStateAlerting
ctx
.
Firing
=
true
ctx
.
Error
=
nil
ctx
.
EvalMatches
=
evalMatchesBasedOnState
(
state
)
ctx
.
EvalMatches
=
evalMatchesBasedOnState
()
return
ctx
}
func
evalMatchesBasedOnState
(
state
m
.
AlertStateType
)
[]
*
EvalMatch
{
func
evalMatchesBasedOnState
()
[]
*
EvalMatch
{
matches
:=
make
([]
*
EvalMatch
,
0
)
if
state
==
m
.
AlertStateOK
{
return
matches
}
matches
=
append
(
matches
,
&
EvalMatch
{
Metric
:
"High value"
,
Value
:
100
,
...
...
public/app/features/alerting/notification_edit_ctrl.ts
View file @
f5809c02
...
...
@@ -62,7 +62,6 @@ export class AlertNotificationEditCtrl {
name
:
this
.
model
.
name
,
type
:
this
.
model
.
type
,
settings
:
this
.
model
.
settings
,
severity
:
this
.
testSeverity
};
this
.
backendSrv
.
post
(
`/api/alert-notifications/test`
,
payload
)
...
...
public/app/features/alerting/partials/notification_edit.html
View file @
f5809c02
...
...
@@ -26,15 +26,6 @@
</div>
</div>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-12"
>
Severity filter
</span>
<div
class=
"gf-form-select-wrapper width-15"
>
<select
class=
"gf-form-input"
ng-model=
"ctrl.model.settings.severityFilter"
ng-options=
"t for t in ['none', 'critical', 'warning']"
>
</select>
</div>
</div>
<div
class=
"gf-form"
>
<gf-form-switch
class=
"gf-form"
label=
"Send on all alerts"
...
...
@@ -86,16 +77,7 @@
<div
class=
"gf-form width-8"
>
<button
ng-click=
"ctrl.toggleTest()"
class=
"btn btn-secondary"
>
Test
</button>
</div>
<div
class=
"gf-form width-20"
ng-show=
"ctrl.showTest"
>
<span
class=
"gf-form-label width-13"
>
Severity for test notification
</span>
<div
class=
"gf-form-select-wrapper width-7"
>
<select
class=
"gf-form-input"
ng-model=
"ctrl.testSeverity"
ng-options=
"t for t in ['critical', 'warning', 'ok']"
>
</select>
</div>
</div>
<div
class=
"gf-form"
ng-show=
"ctrl.showTest"
>
<button
ng-click=
"ctrl.testNotification()"
class=
"btn btn-secondary"
>
Send
</button>
</div>
...
...
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