Commit 31bb2f80 by Torkel Ödegaard

Merge branch 'develop' of github.com:grafana/grafana into develop

parents 6fae999f afc03649
...@@ -383,8 +383,8 @@ export class DashboardMigrator { ...@@ -383,8 +383,8 @@ export class DashboardMigrator {
return; return;
} }
// Add special "row" panels if even one row is collapsed or has visible title // Add special "row" panels if even one row is collapsed, repeated or has visible title
const showRows = _.some(old.rows, (row) => row.collapse || row.showTitle); const showRows = _.some(old.rows, (row) => row.collapse || row.showTitle || row.repeat);
for (let row of old.rows) { for (let row of old.rows) {
let height: any = row.height || DEFAULT_ROW_HEIGHT; let height: any = row.height || DEFAULT_ROW_HEIGHT;
...@@ -398,6 +398,7 @@ export class DashboardMigrator { ...@@ -398,6 +398,7 @@ export class DashboardMigrator {
rowPanel.type = 'row'; rowPanel.type = 'row';
rowPanel.title = row.title; rowPanel.title = row.title;
rowPanel.collapsed = row.collapse; rowPanel.collapsed = row.collapse;
rowPanel.repeat = row.repeat;
rowPanel.panels = []; rowPanel.panels = [];
rowPanel.gridPos = {x: 0, y: yPos, w: GRID_COLUMN_COUNT, h: rowGridHeight}; rowPanel.gridPos = {x: 0, y: yPos, w: GRID_COLUMN_COUNT, h: rowGridHeight};
rowPanelModel = new PanelModel(rowPanel); rowPanelModel = new PanelModel(rowPanel);
......
...@@ -2,6 +2,7 @@ import _ from 'lodash'; ...@@ -2,6 +2,7 @@ import _ from 'lodash';
import { DashboardModel } from '../dashboard_model'; import { DashboardModel } from '../dashboard_model';
import { PanelModel } from '../panel_model'; import { PanelModel } from '../panel_model';
import {GRID_CELL_HEIGHT, GRID_CELL_VMARGIN} from 'app/core/constants'; import {GRID_CELL_HEIGHT, GRID_CELL_VMARGIN} from 'app/core/constants';
import { expect } from 'test/lib/common';
jest.mock('app/core/services/context_srv', () => ({})); jest.mock('app/core/services/context_srv', () => ({}));
...@@ -315,12 +316,33 @@ describe('DashboardModel', function() { ...@@ -315,12 +316,33 @@ describe('DashboardModel', function() {
expect(panelGridPos).toEqual(expectedGrid); expect(panelGridPos).toEqual(expectedGrid);
}); });
it('should add repeated row if repeat set', function() {
model.rows = [
createRow({showTitle: true, title: "Row", height: 8, repeat: "server"}, [[6]]),
createRow({height: 8}, [[12]])
];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
{x: 0, y: 0, w: 24, h: 8},
{x: 0, y: 1, w: 12, h: 8},
{x: 0, y: 9, w: 24, h: 8},
{x: 0, y: 10, w: 24, h: 8}
];
expect(panelGridPos).toEqual(expectedGrid);
expect(dashboard.panels[0].repeat).toBe("server");
expect(dashboard.panels[1].repeat).toBeUndefined();
expect(dashboard.panels[2].repeat).toBeUndefined();
expect(dashboard.panels[3].repeat).toBeUndefined();
});
}); });
}); });
function createRow(options, panelDescriptions: any[]) { function createRow(options, panelDescriptions: any[]) {
const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN; const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN;
let {collapse, height, showTitle, title} = options; let {collapse, height, showTitle, title, repeat} = options;
height = height * PANEL_HEIGHT_STEP; height = height * PANEL_HEIGHT_STEP;
let panels = []; let panels = [];
_.each(panelDescriptions, panelDesc => { _.each(panelDescriptions, panelDesc => {
...@@ -330,7 +352,7 @@ function createRow(options, panelDescriptions: any[]) { ...@@ -330,7 +352,7 @@ function createRow(options, panelDescriptions: any[]) {
} }
panels.push(panel); panels.push(panel);
}); });
let row = {collapse, height, showTitle, title, panels}; let row = {collapse, height, showTitle, title, panels, repeat};
return row; return row;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment