Skip to content

Commit 0c5da91

Browse files
committed
feat(alerting): only expose DTO info when requesting all notifications
1 parent 96e5ad3 commit 0c5da91

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

pkg/api/alerting.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,19 @@ func GetAlertNotifications(c *middleware.Context) Response {
166166
return ApiError(500, "Failed to get alert notifications", err)
167167
}
168168

169-
return Json(200, query.Result)
169+
var result []dtos.AlertNotificationDTO
170+
171+
for _, notification := range query.Result {
172+
result = append(result, dtos.AlertNotificationDTO{
173+
Id: notification.Id,
174+
Name: notification.Name,
175+
Type: notification.Type,
176+
Created: notification.Created,
177+
Updated: notification.Updated,
178+
})
179+
}
180+
181+
return Json(200, result)
170182
}
171183

172184
func GetAlertNotificationById(c *middleware.Context) Response {

pkg/api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func Register(r *macaron.Macaron) {
263263
r.Delete("/:notificationId", wrap(DeleteAlertNotification))
264264
})
265265

266-
r.Get("/changes", wrap(GetAlertChanges))
266+
//r.Get("/changes", wrap(GetAlertChanges))
267267
})
268268

269269
// error test

pkg/api/dtos/alerting.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dtos
22

3+
import "time"
4+
35
type AlertRuleDTO struct {
46
Id int64 `json:"id"`
57
DashboardId int64 `json:"dashboardId"`
@@ -19,3 +21,11 @@ type AlertRuleDTO struct {
1921

2022
DashbboardUri string `json:"dashboardUri"`
2123
}
24+
25+
type AlertNotificationDTO struct {
26+
Id int64 `json:"id"`
27+
Name string `json:"name"`
28+
Type string `json:"type"`
29+
Created time.Time `json:"created"`
30+
Updated time.Time `json:"updated"`
31+
}

public/app/plugins/panel/graph/partials/tab_alerting.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ <h5 class="section-heading">Notifications</h5>
109109
<div class="gf-form-inline">
110110
<div class="gf-form">
111111
<span class="gf-form-label">Groups</span>
112+
<input class="gf-form-input max-width-7" type="text" ng-model="ctrl.alert.notify"></input>
113+
<!--
112114
<bootstrap-tagsinput ng-model="ctrl.alert.notify" tagclass="label label-tag" placeholder="add tags">
113115
</bootstrap-tagsinput>
116+
-->
114117
</div>
115118
</div>
116119
</div>

0 commit comments

Comments
 (0)