DashboardService: Consolidate constructors (#31886)

* DashboardService: Consolidate constructors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2021-03-12 11:51:02 +01:00
committed by GitHub
parent f917c2ab0f
commit 1716de88b5
8 changed files with 50 additions and 75 deletions

View File

@@ -122,7 +122,8 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
meta.FolderUrl = query.Result.GetUrl()
}
provisioningData, err := dashboards.NewProvisioningService().GetProvisionedDashboardDataByDashboardID(dash.Id)
svc := dashboards.NewProvisioningService()
provisioningData, err := svc.GetProvisionedDashboardDataByDashboardID(dash.Id)
if err != nil {
return response.Error(500, "Error while checking if dashboard is provisioned", err)
}
@@ -226,7 +227,8 @@ func (hs *HTTPServer) deleteDashboard(c *models.ReqContext) response.Response {
}
}
err := dashboards.NewService(hs.DataService).DeleteDashboard(dash.Id, c.OrgId)
svc := dashboards.NewService()
err := svc.DeleteDashboard(dash.Id, c.OrgId)
if err != nil {
var dashboardErr models.DashboardErr
if ok := errors.As(err, &dashboardErr); ok {
@@ -262,7 +264,8 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
}
}
provisioningData, err := dashboards.NewProvisioningService().GetProvisionedDashboardDataByDashboardID(dash.Id)
svc := dashboards.NewProvisioningService()
provisioningData, err := svc.GetProvisionedDashboardDataByDashboardID(dash.Id)
if err != nil {
return response.Error(500, "Error while checking if dashboard is provisioned", err)
}
@@ -288,7 +291,8 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
Overwrite: cmd.Overwrite,
}
dashboard, err := dashboards.NewService(hs.DataService).SaveDashboard(dashItem, allowUiUpdate)
dashSvc := dashboards.NewService()
dashboard, err := dashSvc.SaveDashboard(dashItem, allowUiUpdate)
if err != nil {
return dashboardSaveErrorToApiResponse(err)
}