Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow editors to publish dashboards #10

Open
wants to merge 4 commits into
base: soracom_main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ license_path =
# enable = feature1,feature2
enable =

publicDashboards = true
# feature1 = true
# feature2 = false

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/accesscontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
{Action: dashboards.ActionDashboardsPublicWrite, Scope: dashboards.ScopeDashboardsAll},
},
},
Grants: []string{"Admin"},
Grants: []string{string(org.RoleEditor)},
}

return hs.accesscontrolService.DeclareFixedRoles(
Expand Down
23 changes: 11 additions & 12 deletions pkg/services/publicdashboards/service/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,18 @@ func groupQueriesByPanelId(dashboard *simplejson.Json) map[int64][]*simplejson.J
for _, queryObj := range panel.Get("targets").MustArray() {
query := simplejson.NewFromAny(queryObj)

if hideAttr, exists := query.CheckGet("hide"); !exists || !hideAttr.MustBool() {
// We dont support exemplars for public dashboards currently
query.Del("exemplar")

// if query target has no datasource, set it to have the datasource on the panel
if _, ok := query.CheckGet("datasource"); !ok {
uid := getDataSourceUidFromJson(panel)
datasource := map[string]interface{}{"type": "public-ds", "uid": uid}
query.Set("datasource", datasource)
}

panelQueries = append(panelQueries, query)
// We dont support exemplars for public dashboards currently
query.Del("exemplar")

// if query target has no datasource, set it to have the datasource on the panel
if _, ok := query.CheckGet("datasource"); !ok {
uid := getDataSourceUidFromJson(panel)
datasource := map[string]interface{}{"type": "public-ds", "uid": uid}
query.Set("datasource", datasource)
}

panelQueries = append(panelQueries, query)

}

result[panel.Get("id").MustInt64()] = panelQueries
Expand Down