alertlist: disable pause button when user does not have permission

This commit is contained in:
Daniel Lee
2018-01-30 23:31:02 +01:00
parent 4bc5945c17
commit eb765d288c
10 changed files with 191 additions and 9 deletions

View File

@ -99,6 +99,27 @@ func GetAlerts(c *middleware.Context) Response {
}
}
permissionsQuery := models.GetDashboardPermissionsForUserQuery{
DashboardIds: dashboardIds,
OrgId: c.OrgId,
UserId: c.SignedInUser.UserId,
OrgRole: c.SignedInUser.OrgRole,
}
if len(alertDTOs) > 0 {
if err := bus.Dispatch(&permissionsQuery); err != nil {
return ApiError(500, "List alerts failed", err)
}
}
for _, alert := range alertDTOs {
for _, perm := range permissionsQuery.Result {
if alert.DashboardId == perm.DashboardId {
alert.CanEdit = perm.Permission > 1
}
}
}
return Json(200, alertDTOs)
}

View File

@ -20,6 +20,7 @@ type AlertRule struct {
EvalData *simplejson.Json `json:"evalData"`
ExecutionError string `json:"executionError"`
DashbboardUri string `json:"dashboardUri"`
CanEdit bool `json:"canEdit"`
}
type AlertNotification struct {