From e5c11691203fe68958e66693e429f6f5a3c77200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 4 May 2015 08:36:44 +0200 Subject: [PATCH] HTTP API: GET /api/dashboards/db/:slug response changed property to to match the POST request nameing, Fixes #1928 --- CHANGELOG.md | 3 +++ pkg/api/dashboard.go | 10 +++++----- pkg/api/dashboard_snapshot.go | 6 +++--- pkg/api/dtos/models.go | 6 +++--- public/app/features/dashboard/dashboardCtrl.js | 2 +- public/app/features/panel/soloPanelCtrl.js | 2 +- public/app/routes/dashLoadControllers.js | 12 ++++++------ public/test/specs/soloPanelCtrl-specs.js | 2 +- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8f21eae095..148d4290907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ - [Issue #1891](https://github.com/grafana/grafana/issues/1891). Security: New config option to disable the use of gravatar for profile images - [Issue #1921](https://github.com/grafana/grafana/issues/1921). Auth: Support for user authentication via reverse proxy header (like X-Authenticated-User, or X-WEBAUTH-USER) +**Breaking changes** +- [Issue #1928](https://github.com/grafana/grafana/issues/1928). HTTP API: GET /api/dashboards/db/:slug response changed property `model` to `dashboard` to match the POST request nameing + # 2.0.3 (unreleased - 2.0.x branch) **Fixes** diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 9ea5089ee7d..99c408c4e15 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -46,9 +46,9 @@ func GetDashboard(c *middleware.Context) { } dash := query.Result - dto := dtos.Dashboard{ - Model: dash.Data, - Meta: dtos.DashboardMeta{IsStarred: isStarred, Slug: slug}, + dto := dtos.DashboardFullWithMeta{ + Dashboard: dash.Data, + Meta: dtos.DashboardMeta{IsStarred: isStarred, Slug: slug}, } c.JSON(200, dto) @@ -108,10 +108,10 @@ func GetHomeDashboard(c *middleware.Context) { return } - dash := dtos.Dashboard{} + dash := dtos.DashboardFullWithMeta{} dash.Meta.IsHome = true jsonParser := json.NewDecoder(file) - if err := jsonParser.Decode(&dash.Model); err != nil { + if err := jsonParser.Decode(&dash.Dashboard); err != nil { c.JsonApiErr(500, "Failed to load home dashboard", err) return } diff --git a/pkg/api/dashboard_snapshot.go b/pkg/api/dashboard_snapshot.go index fe628d580b1..7bdb6807890 100644 --- a/pkg/api/dashboard_snapshot.go +++ b/pkg/api/dashboard_snapshot.go @@ -45,8 +45,8 @@ func CreateDashboardSnapshot(c *middleware.Context, cmd m.CreateDashboardSnapsho } func GetDashboardSnapshot(c *middleware.Context) { - key := c.Params(":key") + key := c.Params(":key") query := &m.GetDashboardSnapshotQuery{Key: key} err := bus.Dispatch(query) @@ -63,8 +63,8 @@ func GetDashboardSnapshot(c *middleware.Context) { return } - dto := dtos.Dashboard{ - Model: snapshot.Dashboard, + dto := dtos.DashboardFullWithMeta{ + Dashboard: snapshot.Dashboard, Meta: dtos.DashboardMeta{ IsSnapshot: true, Created: snapshot.Created, diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index fea88f07550..ce0436eccfa 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -37,9 +37,9 @@ type DashboardMeta struct { Created time.Time `json:"created"` } -type Dashboard struct { - Meta DashboardMeta `json:"meta"` - Model map[string]interface{} `json:"model"` +type DashboardFullWithMeta struct { + Meta DashboardMeta `json:"meta"` + Dashboard map[string]interface{} `json:"dashboard"` } type DataSource struct { diff --git a/public/app/features/dashboard/dashboardCtrl.js b/public/app/features/dashboard/dashboardCtrl.js index f81b808a0e1..d8772fa3988 100644 --- a/public/app/features/dashboard/dashboardCtrl.js +++ b/public/app/features/dashboard/dashboardCtrl.js @@ -40,7 +40,7 @@ function (angular, $, config) { $rootScope.performance.panelsInitialized = 0; $rootScope.performance.panelsRendered = 0; - var dashboard = dashboardSrv.create(data.model, data.meta); + var dashboard = dashboardSrv.create(data.dashboard, data.meta); // init services timeSrv.init(dashboard); diff --git a/public/app/features/panel/soloPanelCtrl.js b/public/app/features/panel/soloPanelCtrl.js index f593f8ee950..977f634a905 100644 --- a/public/app/features/panel/soloPanelCtrl.js +++ b/public/app/features/panel/soloPanelCtrl.js @@ -41,7 +41,7 @@ function (angular, $) { }; $scope.initPanelScope = function(dashData) { - $scope.dashboard = dashboardSrv.create(dashData.model, dashData.meta); + $scope.dashboard = dashboardSrv.create(dashData.dashboard, dashData.meta); $scope.row = { height: ($(window).height() - 10) + 'px', diff --git a/public/app/routes/dashLoadControllers.js b/public/app/routes/dashLoadControllers.js index f85cee09d84..d26827248ce 100644 --- a/public/app/routes/dashLoadControllers.js +++ b/public/app/routes/dashLoadControllers.js @@ -13,7 +13,7 @@ function (angular, _, kbn, moment, $) { module.controller('DashFromDBCtrl', function($scope, $routeParams, backendSrv) { function dashboardLoadFailed(title) { - $scope.initDashboard({meta: {}, model: {title: title}}, $scope); + $scope.initDashboard({meta: {}, dashboard: {title: title}}, $scope); } if (!$routeParams.slug) { @@ -46,7 +46,7 @@ function (angular, _, kbn, moment, $) { canSave: false, canEdit: false, }, - model: { + dashboard: { title: 'Snapshot not found' } }, $scope); @@ -61,14 +61,14 @@ function (angular, _, kbn, moment, $) { } $scope.initDashboard({ meta: { canShare: false, canStar: false }, - model: window.grafanaImportDashboard + dashboard: window.grafanaImportDashboard }, $scope); }); module.controller('NewDashboardCtrl', function($scope) { $scope.initDashboard({ meta: { canStar: false, canShare: false }, - model: { + dashboard: { title: "New dashboard", rows: [{ height: '250px', panels:[] }] }, @@ -98,7 +98,7 @@ function (angular, _, kbn, moment, $) { file_load($routeParams.jsonFile).then(function(result) { $scope.initDashboard({ meta: { canSave: false, canDelete: false }, - model: result + dashboard: result }, $scope); }); @@ -146,7 +146,7 @@ function (angular, _, kbn, moment, $) { script_load($routeParams.jsFile).then(function(result) { $scope.initDashboard({ meta: {fromScript: true, canDelete: false, canSave: false}, - model: result.data + dashboard: result.data }, $scope); }); diff --git a/public/test/specs/soloPanelCtrl-specs.js b/public/test/specs/soloPanelCtrl-specs.js index 44c9f2080cc..09271c1be03 100644 --- a/public/test/specs/soloPanelCtrl-specs.js +++ b/public/test/specs/soloPanelCtrl-specs.js @@ -34,7 +34,7 @@ define([ beforeEach(function() { var dashboard = { - model: { + dashboard: { rows: [ { panels: [