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
b907ce34
Commit
b907ce34
authored
Jun 16, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): enables deletes for alert notifications
parent
149c2ae9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
11 deletions
+64
-11
pkg/api/alerting.go
+13
-0
pkg/api/api.go
+1
-0
pkg/models/alert_notifications.go
+5
-0
pkg/services/sqlstore/alert_notification.go
+14
-0
public/app/features/alerting/notification_edit_ctrl.ts
+7
-3
public/app/features/alerting/notifications_list_ctrl.ts
+14
-1
public/app/features/alerting/partials/notifications_list.html
+10
-7
No files found.
pkg/api/alerting.go
View file @
b907ce34
...
...
@@ -201,3 +201,16 @@ func UpdateAlertNotification(c *middleware.Context, cmd models.UpdateAlertNotifi
return
Json
(
200
,
cmd
.
Result
)
}
func
DeleteAlertNotification
(
c
*
middleware
.
Context
)
Response
{
cmd
:=
models
.
DeleteAlertNotificationCommand
{
OrgId
:
c
.
OrgId
,
Id
:
c
.
ParamsInt64
(
"notificationId"
),
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed to delete alert notification"
,
err
)
}
return
Json
(
200
,
map
[
string
]
interface
{}{
"notificationId"
:
cmd
.
Id
})
}
pkg/api/api.go
View file @
b907ce34
...
...
@@ -257,6 +257,7 @@ func Register(r *macaron.Macaron) {
r
.
Post
(
"/"
,
bind
(
m
.
CreateAlertNotificationCommand
{}),
wrap
(
CreateAlertNotification
))
r
.
Put
(
"/:notificationId"
,
bind
(
m
.
UpdateAlertNotificationCommand
{}),
wrap
(
UpdateAlertNotification
))
r
.
Get
(
"/:notificationId"
,
wrap
(
GetAlertNotificationById
))
r
.
Delete
(
"/:notificationId"
,
wrap
(
DeleteAlertNotification
))
})
r
.
Get
(
"/changes"
,
wrap
(
GetAlertChanges
))
...
...
pkg/models/alert_notifications.go
View file @
b907ce34
...
...
@@ -35,6 +35,11 @@ type UpdateAlertNotificationCommand struct {
Result
*
AlertNotification
}
type
DeleteAlertNotificationCommand
struct
{
Id
int64
OrgId
int64
}
type
GetAlertNotificationQuery
struct
{
Name
string
Id
int64
...
...
pkg/services/sqlstore/alert_notification.go
View file @
b907ce34
...
...
@@ -15,6 +15,20 @@ func init() {
bus
.
AddHandler
(
"sql"
,
AlertNotificationQuery
)
bus
.
AddHandler
(
"sql"
,
CreateAlertNotificationCommand
)
bus
.
AddHandler
(
"sql"
,
UpdateAlertNotification
)
bus
.
AddHandler
(
"sql"
,
DeleteAlertNotification
)
}
func
DeleteAlertNotification
(
cmd
*
m
.
DeleteAlertNotificationCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
sql
:=
"DELETE FROM alert_notification WHERE alert_notification.org_id = ? AND alert_notification.id = ?"
_
,
err
:=
sess
.
Exec
(
sql
,
cmd
.
OrgId
,
cmd
.
Id
)
if
err
!=
nil
{
return
err
}
return
nil
})
}
func
AlertNotificationQuery
(
query
*
m
.
GetAlertNotificationQuery
)
error
{
...
...
public/app/features/alerting/notification_edit_ctrl.ts
View file @
b907ce34
...
...
@@ -10,7 +10,7 @@ export class AlertNotificationEditCtrl {
notification
:
any
;
/** @ngInject */
constructor
(
private
$routeParams
,
private
backendSrv
)
{
constructor
(
private
$routeParams
,
private
backendSrv
,
private
$scope
)
{
if
(
$routeParams
.
notificationId
)
{
this
.
loadNotification
(
$routeParams
.
notificationId
);
}
...
...
@@ -33,13 +33,17 @@ export class AlertNotificationEditCtrl {
this
.
backendSrv
.
put
(
`/api/alerts/notification/
${
this
.
notification
.
id
}
`
,
this
.
notification
)
.
then
(
result
=>
{
this
.
notification
=
result
;
console
.
log
(
'updated notification'
,
result
);
this
.
$scope
.
appEvent
(
'alert-success'
,
[
'Notification created!'
,
''
]);
},
()
=>
{
this
.
$scope
.
appEvent
(
'alert-error'
,
[
'Unable to create notification.'
,
''
]);
});
}
else
{
this
.
backendSrv
.
post
(
`/api/alerts/notification`
,
this
.
notification
)
.
then
(
result
=>
{
this
.
notification
=
result
;
console
.
log
(
'created new notification'
,
result
);
this
.
$scope
.
appEvent
(
'alert-success'
,
[
'Notification updated!'
,
''
]);
},
()
=>
{
this
.
$scope
.
appEvent
(
'alert-error'
,
[
'Unable to update notification.'
,
''
]);
});
}
}
...
...
public/app/features/alerting/notifications_list_ctrl.ts
View file @
b907ce34
...
...
@@ -10,7 +10,7 @@ export class AlertNotificationsListCtrl {
notifications
:
any
;
/** @ngInject */
constructor
(
private
backendSrv
)
{
constructor
(
private
backendSrv
,
private
$scope
)
{
this
.
loadNotifications
();
}
...
...
@@ -19,7 +19,20 @@ export class AlertNotificationsListCtrl {
this
.
notifications
=
result
;
});
}
deleteNotification
(
notificationId
)
{
this
.
backendSrv
.
delete
(
`/api/alerts/notification/
${
notificationId
}
`
)
.
then
(()
=>
{
this
.
notifications
=
this
.
notifications
.
filter
(
notification
=>
{
return
notification
.
id
!==
notificationId
;
});
this
.
$scope
.
appEvent
(
'alert-success'
,
[
'Notification deleted'
,
''
]);
},
()
=>
{
this
.
$scope
.
appEvent
(
'alert-error'
,
[
'Unable to delete notification'
,
''
]);
});
}
}
coreModule
.
controller
(
'AlertNotificationsListCtrl'
,
AlertNotificationsListCtrl
);
public/app/features/alerting/partials/notifications_list.html
View file @
b907ce34
...
...
@@ -4,32 +4,35 @@
<div
class=
"page-container"
>
<div
class=
"page-header"
>
<h1>
Alert notifications
</h1>
<
button
class=
"btn btn-success pull-right"
>
<
a
href=
"alerting/notification/new"
class=
"btn btn-success pull-right"
>
<i
class=
"fa fa-plus"
></i>
New Notification
</
button
>
</
a
>
</div>
<table
class=
"grafana-options-table"
>
<table
class=
"grafana-options-table"
style=
"/*width: 600px;*/"
>
<thead>
<th
style=
"min-width: 200px"
><strong>
Name
</strong></th>
<th
style=
"
width: 1%
"
>
Type
</th>
<th
style=
"
min-width: 100px
"
>
Type
</th>
<th
style=
"width: 1%"
></th>
</thead>
<tr
ng-repeat=
"notification in ctrl.notifications"
>
<td>
<a
href=
"alerting/notification{{notification.id}}/edit"
>
{{
alert
.name}}
{{
notification
.name}}
</a>
</td>
<td
class=
"text-center"
>
<td>
{{notification.type}}
</td>
<td
class=
"text-center"
>
<td>
<a
href=
"alerting/notification/{{notification.id}}/edit"
class=
"btn btn-inverse btn-small"
>
<i
class=
"fa fa-edit"
></i>
edit
</a>
<a
ng-click=
"ctrl.deleteNotification(notification.id)"
class=
"btn btn-danger btn-small"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
</tr>
</table>
...
...
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