Worked on dashboard starring and unstarring, renamed favorite model to star

This commit is contained in:
Torkel Ödegaard
2015-02-02 11:32:32 +01:00
parent 706481b1a3
commit ad3d15e28d
12 changed files with 231 additions and 118 deletions
+21 -2
View File
@@ -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)