Trying to get dashboard loading and dashboard meta flags like canSave, canStar more managable

This commit is contained in:
Torkel Ödegaard
2015-05-13 09:58:45 +02:00
parent 4822d02787
commit 187834b17c
10 changed files with 21 additions and 16 deletions

View File

@@ -53,7 +53,8 @@ func GetDashboard(c *middleware.Context) {
IsStarred: isStarred,
Slug: slug,
Type: m.DashTypeDB,
CanSave: c.OrgRole != m.ROLE_VIEWER,
CanStar: c.IsSignedIn,
CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
},
}
@@ -136,7 +137,6 @@ func GetDashboardFromJsonFile(c *middleware.Context) {
dash := dtos.DashboardFullWithMeta{Dashboard: dashboard.Data}
dash.Meta.Type = m.DashTypeJson
dash.Meta.CanSave = false
c.JSON(200, &dash)
}

View File

@@ -66,6 +66,7 @@ func GetDashboardSnapshot(c *middleware.Context) {
dto := dtos.DashboardFullWithMeta{
Dashboard: snapshot.Dashboard,
Meta: dtos.DashboardMeta{
Type: m.DashTypeSnapshot,
IsSnapshot: true,
Created: snapshot.Created,
Expires: snapshot.Expires,

View File

@@ -34,6 +34,7 @@ type DashboardMeta struct {
IsSnapshot bool `json:"isSnapshot,omitempty"`
Type string `json:"type,omitempty"`
CanSave bool `json:"canSave"`
CanStar bool `json:"canStar"`
Slug string `json:"slug"`
Expires time.Time `json:"expires"`
Created time.Time `json:"created"`

View File

@@ -7,6 +7,11 @@ import (
)
func StarDashboard(c *middleware.Context) {
if !c.IsSignedIn {
c.JsonApiErr(412, "You need to sign in to star dashboards", nil)
return
}
var cmd = m.StarDashboardCommand{
UserId: c.UserId,
DashboardId: c.ParamsInt64(":id"),