mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Trying to get dashboard loading and dashboard meta flags like canSave, canStar more managable
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user