public dashboards: insert default public dashboard config into database on save (#49131)
This PR adds endpoints for saving and retrieving a public dashboard configuration and and api endpoint to retrieve the public dashboard. All of this is highly experimental and APIs will change. Notably, we will be removing isPublic from the dashboard model and moving it over to the public dashboard table in the next release. Further context can be found here: https://github.com/grafana/grafana/pull/49131#issuecomment-1145456952
This commit is contained in:
@@ -206,10 +206,6 @@ type Dashboard struct {
|
||||
Data *simplejson.Json
|
||||
}
|
||||
|
||||
type PublicDashboardConfig struct {
|
||||
IsPublic bool `json:"isPublic"`
|
||||
}
|
||||
|
||||
func (d *Dashboard) SetId(id int64) {
|
||||
d.Id = id
|
||||
d.Data.Set("id", id)
|
||||
@@ -417,12 +413,6 @@ type DeleteOrphanedProvisionedDashboardsCommand struct {
|
||||
ReaderNames []string
|
||||
}
|
||||
|
||||
type SavePublicDashboardConfigCommand struct {
|
||||
Uid string
|
||||
OrgId int64
|
||||
PublicDashboardConfig PublicDashboardConfig
|
||||
}
|
||||
|
||||
//
|
||||
// QUERIES
|
||||
//
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package models
|
||||
|
||||
var (
|
||||
ErrPublicDashboardFailedGenerateUniqueUid = DashboardErr{
|
||||
Reason: "Failed to generate unique dashboard id",
|
||||
StatusCode: 500,
|
||||
}
|
||||
ErrPublicDashboardNotFound = DashboardErr{
|
||||
Reason: "Public dashboard not found",
|
||||
StatusCode: 404,
|
||||
Status: "not-found",
|
||||
}
|
||||
ErrPublicDashboardIdentifierNotSet = DashboardErr{
|
||||
Reason: "No Uid for public dashboard specified",
|
||||
StatusCode: 400,
|
||||
}
|
||||
)
|
||||
|
||||
type PublicDashboardConfig struct {
|
||||
IsPublic bool `json:"isPublic"`
|
||||
PublicDashboard PublicDashboard `json:"publicDashboard"`
|
||||
}
|
||||
|
||||
type PublicDashboard struct {
|
||||
Uid string `json:"uid" xorm:"uid"`
|
||||
DashboardUid string `json:"dashboardUid" xorm:"dashboard_uid"`
|
||||
OrgId int64 `json:"orgId" xorm:"org_id"`
|
||||
TimeSettings string `json:"timeSettings" xorm:"time_settings"`
|
||||
}
|
||||
|
||||
func (pd PublicDashboard) TableName() string {
|
||||
return "dashboard_public_config"
|
||||
}
|
||||
|
||||
//
|
||||
// COMMANDS
|
||||
//
|
||||
|
||||
type SavePublicDashboardConfigCommand struct {
|
||||
DashboardUid string
|
||||
OrgId int64
|
||||
PublicDashboardConfig PublicDashboardConfig
|
||||
}
|
||||
Reference in New Issue
Block a user