mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
dashboards: api for retrieving uid by slug. #7883
This commit is contained in:
@@ -113,6 +113,21 @@ func GetDashboard(c *middleware.Context) Response {
|
||||
return Json(200, dto)
|
||||
}
|
||||
|
||||
func GetDashboardUidBySlug(c *middleware.Context) Response {
|
||||
dash, rsp := getDashboardHelper(c.OrgId, c.Params(":slug"), 0, "")
|
||||
if rsp != nil {
|
||||
return rsp
|
||||
}
|
||||
|
||||
guardian := guardian.NewDashboardGuardian(dash.Id, c.OrgId, c.SignedInUser)
|
||||
if canView, err := guardian.CanView(); err != nil || !canView {
|
||||
fmt.Printf("%v", err)
|
||||
return dashboardGuardianResponse(err)
|
||||
}
|
||||
|
||||
return Json(200, util.DynMap{"uid": dash.Uid})
|
||||
}
|
||||
|
||||
func getUserLogin(userId int64) string {
|
||||
query := m.GetUserByIdQuery{Id: userId}
|
||||
err := bus.Dispatch(&query)
|
||||
|
||||
Reference in New Issue
Block a user