From d8e4decc60a6976a8a68ead37086addbab268e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 11 Oct 2017 14:36:25 +0200 Subject: [PATCH] grid: fixed migration for rows without height --- .../app/features/dashboard/DashboardModel.ts | 2 +- public/app/features/dashboard/all.js | 1 - .../dashboard/dashgrid/DashboardGrid.tsx | 1 - .../features/dashboard/graphiteImportCtrl.js | 95 ------------------- .../plugins/panel/graph/specs/graph_specs.ts | 2 +- 5 files changed, 2 insertions(+), 99 deletions(-) delete mode 100644 public/app/features/dashboard/graphiteImportCtrl.js diff --git a/public/app/features/dashboard/DashboardModel.ts b/public/app/features/dashboard/DashboardModel.ts index 45141d57534..a036e418c4b 100644 --- a/public/app/features/dashboard/DashboardModel.ts +++ b/public/app/features/dashboard/DashboardModel.ts @@ -672,7 +672,7 @@ export class DashboardModel { for (let row of old.rows) { let xPos = 0; - let height: any = row.height; + let height: any = row.height || 250; // if (this.meta.keepRows) { // this.panels.push({ diff --git a/public/app/features/dashboard/all.js b/public/app/features/dashboard/all.js index 3871dc3ff85..75009abc4ca 100644 --- a/public/app/features/dashboard/all.js +++ b/public/app/features/dashboard/all.js @@ -15,7 +15,6 @@ define([ './unsavedChangesSrv', './unsaved_changes_modal', './timepicker/timepicker', - './graphiteImportCtrl', './impression_store', './upload', './import/dash_import', diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index da75231d0aa..7cf0cb190ea 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -117,7 +117,6 @@ export class DashboardGrid extends React.Component { } render() { - console.log('DashboardGrid.render()'); return ( {this.renderPanels()} diff --git a/public/app/features/dashboard/graphiteImportCtrl.js b/public/app/features/dashboard/graphiteImportCtrl.js deleted file mode 100644 index 53338883274..00000000000 --- a/public/app/features/dashboard/graphiteImportCtrl.js +++ /dev/null @@ -1,95 +0,0 @@ -define([ - 'angular', - 'lodash', - 'app/core/utils/kbn' -], -function (angular, _, kbn) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('GraphiteImportCtrl', function($scope, datasourceSrv, dashboardSrv, $location) { - $scope.options = {}; - - $scope.init = function() { - $scope.datasources = []; - _.each(datasourceSrv.getAll(), function(ds) { - if (ds.type === 'graphite') { - $scope.options.sourceName = ds.name; - $scope.datasources.push(ds.name); - } - }); - }; - - $scope.listAll = function() { - datasourceSrv.get($scope.options.sourceName).then(function(datasource) { - $scope.datasource = datasource; - $scope.datasource.listDashboards('').then(function(results) { - $scope.dashboards = results; - }, function(err) { - var message = err.message || err.statusText || 'Error'; - $scope.appEvent('alert-error', ['Failed to load dashboard list from graphite', message]); - }); - }); - }; - - $scope.import = function(dashName) { - $scope.datasource.loadDashboard(dashName).then(function(results) { - if (!results.data || !results.data.state) { - throw { message: 'no dashboard state received from graphite' }; - } - - graphiteToGrafanaTranslator(results.data.state, $scope.datasource.name); - }, function(err) { - var message = err.message || err.statusText || 'Error'; - $scope.appEvent('alert-error', ['Failed to load dashboard from graphite', message]); - }); - }; - - function graphiteToGrafanaTranslator(state, datasource) { - var graphsPerRow = 2; - var rowHeight = 300; - var rowTemplate; - var currentRow; - var panel; - - rowTemplate = { - title: '', - panels: [], - height: rowHeight - }; - - currentRow = angular.copy(rowTemplate); - - var newDashboard = dashboardSrv.create({}); - newDashboard.rows = []; - newDashboard.title = state.name; - newDashboard.rows.push(currentRow); - - _.each(state.graphs, function(graph, index) { - if (currentRow.panels.length === graphsPerRow) { - currentRow = angular.copy(rowTemplate); - newDashboard.rows.push(currentRow); - } - - panel = { - type: 'graph', - span: 12 / graphsPerRow, - title: graph[1].title, - targets: [], - datasource: datasource, - id: index + 1 - }; - - _.each(graph[1].target, function(target) { - panel.targets.push({ target: target }); - }); - - currentRow.panels.push(panel); - }); - - window.grafanaImportDashboard = newDashboard; - $location.path('/dashboard-import/' + kbn.slugifyForUrl(newDashboard.title)); - } - }); -}); diff --git a/public/app/plugins/panel/graph/specs/graph_specs.ts b/public/app/plugins/panel/graph/specs/graph_specs.ts index 1c240bb2967..a4f74e395ae 100644 --- a/public/app/plugins/panel/graph/specs/graph_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_specs.ts @@ -26,9 +26,9 @@ describe('grafanaGraph', function() { beforeEach(angularMocks.inject(function($rootScope, $compile) { var ctrl: any = { - events: new Emitter(), height: 200, panel: { + events: new Emitter(), legend: {}, grid: { }, yaxes: [