Worked on dashboard starring and unstarring, renamed favorite model to star
This commit is contained in:
+21
-2
@@ -8,6 +8,19 @@ import (
|
||||
"github.com/torkelo/grafana-pro/pkg/util"
|
||||
)
|
||||
|
||||
func isDasboardStarredByUser(c *middleware.Context, dashId int64) (bool, error) {
|
||||
if !c.IsSignedIn {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
query := m.IsStarredByUserQuery{UserId: c.UserId, DashboardId: dashId}
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return query.Result, nil
|
||||
}
|
||||
|
||||
func GetDashboard(c *middleware.Context) {
|
||||
slug := c.Params(":slug")
|
||||
|
||||
@@ -18,10 +31,16 @@ func GetDashboard(c *middleware.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
isStarred, err := isDasboardStarredByUser(c, query.Result.Id)
|
||||
if err != nil {
|
||||
c.JsonApiErr(500, "Error while checking if dashboard was starred by user", err)
|
||||
return
|
||||
}
|
||||
|
||||
dash := query.Result
|
||||
dto := dtos.Dashboard{
|
||||
IsFavorite: false,
|
||||
Dashboard: dash.Data,
|
||||
Model: dash.Data,
|
||||
Meta: dtos.DashboardMeta{IsStarred: isStarred},
|
||||
}
|
||||
|
||||
c.JSON(200, dto)
|
||||
|
||||
Reference in New Issue
Block a user