|
@@ -56,7 +56,7 @@ func GetDashboard(c *middleware.Context) {
|
|
|
Type: m.DashTypeDB,
|
|
Type: m.DashTypeDB,
|
|
|
CanStar: c.IsSignedIn,
|
|
CanStar: c.IsSignedIn,
|
|
|
CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
|
|
CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
|
|
|
- CanEdit: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR || c.OrgRole == m.ROLE_READ_ONLY_EDITOR,
|
|
|
|
|
|
|
+ CanEdit: canEditDashboard(c.OrgRole),
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -122,6 +122,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) {
|
|
|
c.JSON(200, util.DynMap{"status": "success", "slug": cmd.Result.Slug, "version": cmd.Result.Version})
|
|
c.JSON(200, util.DynMap{"status": "success", "slug": cmd.Result.Slug, "version": cmd.Result.Version})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func canEditDashboard(role m.RoleType) bool {
|
|
|
|
|
+ return role == m.ROLE_ADMIN || role == m.ROLE_EDITOR || role == m.ROLE_READ_ONLY_EDITOR
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func GetHomeDashboard(c *middleware.Context) {
|
|
func GetHomeDashboard(c *middleware.Context) {
|
|
|
filePath := path.Join(setting.StaticRootPath, "dashboards/home.json")
|
|
filePath := path.Join(setting.StaticRootPath, "dashboards/home.json")
|
|
|
file, err := os.Open(filePath)
|
|
file, err := os.Open(filePath)
|
|
@@ -132,6 +136,7 @@ func GetHomeDashboard(c *middleware.Context) {
|
|
|
|
|
|
|
|
dash := dtos.DashboardFullWithMeta{}
|
|
dash := dtos.DashboardFullWithMeta{}
|
|
|
dash.Meta.IsHome = true
|
|
dash.Meta.IsHome = true
|
|
|
|
|
+ dash.Meta.CanEdit = canEditDashboard(c.OrgRole)
|
|
|
jsonParser := json.NewDecoder(file)
|
|
jsonParser := json.NewDecoder(file)
|
|
|
if err := jsonParser.Decode(&dash.Dashboard); err != nil {
|
|
if err := jsonParser.Decode(&dash.Dashboard); err != nil {
|
|
|
c.JsonApiErr(500, "Failed to load home dashboard", err)
|
|
c.JsonApiErr(500, "Failed to load home dashboard", err)
|
|
@@ -152,6 +157,7 @@ func GetDashboardFromJsonFile(c *middleware.Context) {
|
|
|
|
|
|
|
|
dash := dtos.DashboardFullWithMeta{Dashboard: dashboard.Data}
|
|
dash := dtos.DashboardFullWithMeta{Dashboard: dashboard.Data}
|
|
|
dash.Meta.Type = m.DashTypeJson
|
|
dash.Meta.Type = m.DashTypeJson
|
|
|
|
|
+ dash.Meta.CanEdit = canEditDashboard(c.OrgRole)
|
|
|
|
|
|
|
|
c.JSON(200, &dash)
|
|
c.JSON(200, &dash)
|
|
|
}
|
|
}
|