mirror of
https://github.com/grafana/grafana.git
synced 2025-09-20 16:02:53 +08:00
Dashboard: Dashboard schema fixes and scene to save model fixes (#81867)
This commit is contained in:
@ -450,7 +450,6 @@ Dashboard panels are the basic visualization building blocks.
|
|||||||
| `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
|
| `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
|
||||||
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
|
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
|
||||||
| `repeat` | string | No | | Name of template variable to repeat for. |
|
| `repeat` | string | No | | Name of template variable to repeat for. |
|
||||||
| `tags` | string[] | No | | Tags for the panel. |
|
|
||||||
| `targets` | [Target](#target)[] | No | | Depends on the panel plugin. See the plugin documentation for details. |
|
| `targets` | [Target](#target)[] | No | | Depends on the panel plugin. See the plugin documentation for details. |
|
||||||
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||||
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||||
@ -515,7 +514,6 @@ Dashboard panels are the basic visualization building blocks.
|
|||||||
| `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
|
| `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
|
||||||
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
|
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
|
||||||
| `repeat` | string | No | | Name of template variable to repeat for. |
|
| `repeat` | string | No | | Name of template variable to repeat for. |
|
||||||
| `tags` | string[] | No | | Tags for the panel. |
|
|
||||||
| `targets` | [Target](#target)[] | No | | Depends on the panel plugin. See the plugin documentation for details. |
|
| `targets` | [Target](#target)[] | No | | Depends on the panel plugin. See the plugin documentation for details. |
|
||||||
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||||
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||||
|
@ -521,9 +521,6 @@ lineage: schemas: [{
|
|||||||
// The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
|
// The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
|
||||||
pluginVersion?: string
|
pluginVersion?: string
|
||||||
|
|
||||||
// Tags for the panel.
|
|
||||||
tags?: [...string]
|
|
||||||
|
|
||||||
// Depends on the panel plugin. See the plugin documentation for details.
|
// Depends on the panel plugin. See the plugin documentation for details.
|
||||||
targets?: [...#Target]
|
targets?: [...#Target]
|
||||||
|
|
||||||
|
@ -757,10 +757,6 @@ export interface Panel {
|
|||||||
* `h` for horizontal, `v` for vertical.
|
* `h` for horizontal, `v` for vertical.
|
||||||
*/
|
*/
|
||||||
repeatDirection?: ('h' | 'v');
|
repeatDirection?: ('h' | 'v');
|
||||||
/**
|
|
||||||
* Tags for the panel.
|
|
||||||
*/
|
|
||||||
tags?: Array<string>;
|
|
||||||
/**
|
/**
|
||||||
* Depends on the panel plugin. See the plugin documentation for details.
|
* Depends on the panel plugin. See the plugin documentation for details.
|
||||||
*/
|
*/
|
||||||
@ -806,7 +802,6 @@ export interface Panel {
|
|||||||
export const defaultPanel: Partial<Panel> = {
|
export const defaultPanel: Partial<Panel> = {
|
||||||
links: [],
|
links: [],
|
||||||
repeatDirection: 'h',
|
repeatDirection: 'h',
|
||||||
tags: [],
|
|
||||||
targets: [],
|
targets: [],
|
||||||
transformations: [],
|
transformations: [],
|
||||||
transparent: false,
|
transparent: false,
|
||||||
|
@ -558,9 +558,6 @@ type Panel struct {
|
|||||||
// `h` for horizontal, `v` for vertical.
|
// `h` for horizontal, `v` for vertical.
|
||||||
RepeatDirection *PanelRepeatDirection `json:"repeatDirection,omitempty"`
|
RepeatDirection *PanelRepeatDirection `json:"repeatDirection,omitempty"`
|
||||||
|
|
||||||
// Tags for the panel.
|
|
||||||
Tags []string `json:"tags,omitempty"`
|
|
||||||
|
|
||||||
// Depends on the panel plugin. See the plugin documentation for details.
|
// Depends on the panel plugin. See the plugin documentation for details.
|
||||||
Targets []Target `json:"targets,omitempty"`
|
Targets []Target `json:"targets,omitempty"`
|
||||||
|
|
||||||
|
@ -110,7 +110,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
|||||||
"y": 1,
|
"y": 1,
|
||||||
},
|
},
|
||||||
"id": 15,
|
"id": 15,
|
||||||
"links": [],
|
|
||||||
"options": {
|
"options": {
|
||||||
"code": {
|
"code": {
|
||||||
"language": "plaintext",
|
"language": "plaintext",
|
||||||
@ -124,9 +123,8 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
|||||||
</div>",
|
</div>",
|
||||||
"mode": "markdown",
|
"mode": "markdown",
|
||||||
},
|
},
|
||||||
|
"pluginVersion": "10.2.0-pre",
|
||||||
"title": "",
|
"title": "",
|
||||||
"transformations": [],
|
|
||||||
"transparent": false,
|
|
||||||
"type": "text",
|
"type": "text",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -165,7 +163,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
|||||||
"y": 26,
|
"y": 26,
|
||||||
},
|
},
|
||||||
"id": 30,
|
"id": 30,
|
||||||
"links": [],
|
|
||||||
"options": {
|
"options": {
|
||||||
"code": {
|
"code": {
|
||||||
"language": "plaintext",
|
"language": "plaintext",
|
||||||
@ -177,9 +174,8 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
|||||||
</div>",
|
</div>",
|
||||||
"mode": "markdown",
|
"mode": "markdown",
|
||||||
},
|
},
|
||||||
|
"pluginVersion": "10.2.0-pre",
|
||||||
"title": "Text panel in collapsed row",
|
"title": "Text panel in collapsed row",
|
||||||
"transformations": [],
|
|
||||||
"transparent": false,
|
|
||||||
"type": "text",
|
"type": "text",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -378,7 +374,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
|||||||
"y": 0,
|
"y": 0,
|
||||||
},
|
},
|
||||||
"id": 28,
|
"id": 28,
|
||||||
"links": [],
|
|
||||||
"options": {
|
"options": {
|
||||||
"legend": {
|
"legend": {
|
||||||
"calcs": [],
|
"calcs": [],
|
||||||
@ -404,8 +399,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"title": "Simple time series graph ",
|
"title": "Simple time series graph ",
|
||||||
"transformations": [],
|
|
||||||
"transparent": false,
|
|
||||||
"type": "timeseries",
|
"type": "timeseries",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -437,7 +430,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
|||||||
"y": 9,
|
"y": 9,
|
||||||
},
|
},
|
||||||
"id": 29,
|
"id": 29,
|
||||||
"links": [],
|
|
||||||
"options": {},
|
"options": {},
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
@ -452,8 +444,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"title": "panel inside row",
|
"title": "panel inside row",
|
||||||
"transformations": [],
|
|
||||||
"transparent": false,
|
|
||||||
"type": "timeseries",
|
"type": "timeseries",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -468,7 +458,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
|||||||
"y": 9,
|
"y": 9,
|
||||||
},
|
},
|
||||||
"id": 25,
|
"id": 25,
|
||||||
"links": [],
|
|
||||||
"options": {
|
"options": {
|
||||||
"code": {
|
"code": {
|
||||||
"language": "plaintext",
|
"language": "plaintext",
|
||||||
@ -478,8 +467,8 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
|||||||
"content": "content",
|
"content": "content",
|
||||||
"mode": "markdown",
|
"mode": "markdown",
|
||||||
},
|
},
|
||||||
|
"pluginVersion": "10.2.0-pre",
|
||||||
"title": "Transparent text panel",
|
"title": "Transparent text panel",
|
||||||
"transformations": [],
|
|
||||||
"transparent": true,
|
"transparent": true,
|
||||||
"type": "text",
|
"type": "text",
|
||||||
},
|
},
|
||||||
@ -697,7 +686,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
|||||||
"y": 0,
|
"y": 0,
|
||||||
},
|
},
|
||||||
"id": 28,
|
"id": 28,
|
||||||
"links": [],
|
|
||||||
"options": {
|
"options": {
|
||||||
"legend": {
|
"legend": {
|
||||||
"calcs": [],
|
"calcs": [],
|
||||||
@ -723,8 +711,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"title": "Simple time series graph ",
|
"title": "Simple time series graph ",
|
||||||
"transformations": [],
|
|
||||||
"transparent": false,
|
|
||||||
"type": "timeseries",
|
"type": "timeseries",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -756,7 +742,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
|||||||
"y": 9,
|
"y": 9,
|
||||||
},
|
},
|
||||||
"id": 29,
|
"id": 29,
|
||||||
"links": [],
|
|
||||||
"options": {},
|
"options": {},
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
@ -771,8 +756,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"title": "panel inside row",
|
"title": "panel inside row",
|
||||||
"transformations": [],
|
|
||||||
"transparent": false,
|
|
||||||
"type": "timeseries",
|
"type": "timeseries",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -787,7 +770,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
|||||||
"y": 9,
|
"y": 9,
|
||||||
},
|
},
|
||||||
"id": 25,
|
"id": 25,
|
||||||
"links": [],
|
|
||||||
"options": {
|
"options": {
|
||||||
"code": {
|
"code": {
|
||||||
"language": "plaintext",
|
"language": "plaintext",
|
||||||
@ -797,8 +779,8 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
|||||||
"content": "content",
|
"content": "content",
|
||||||
"mode": "markdown",
|
"mode": "markdown",
|
||||||
},
|
},
|
||||||
|
"pluginVersion": "10.2.0-pre",
|
||||||
"title": "Transparent text panel",
|
"title": "Transparent text panel",
|
||||||
"transformations": [],
|
|
||||||
"transparent": true,
|
"transparent": true,
|
||||||
"type": "text",
|
"type": "text",
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
SceneGridLayout,
|
SceneGridLayout,
|
||||||
SceneGridRow,
|
SceneGridRow,
|
||||||
VizPanel,
|
VizPanel,
|
||||||
SceneQueryRunner,
|
|
||||||
SceneDataTransformer,
|
SceneDataTransformer,
|
||||||
SceneVariableSet,
|
SceneVariableSet,
|
||||||
AdHocFilterSet,
|
AdHocFilterSet,
|
||||||
@ -39,7 +38,7 @@ import { PanelRepeaterGridItem } from '../scene/PanelRepeaterGridItem';
|
|||||||
import { PanelTimeRange } from '../scene/PanelTimeRange';
|
import { PanelTimeRange } from '../scene/PanelTimeRange';
|
||||||
import { RowRepeaterBehavior } from '../scene/RowRepeaterBehavior';
|
import { RowRepeaterBehavior } from '../scene/RowRepeaterBehavior';
|
||||||
import { dashboardSceneGraph } from '../utils/dashboardSceneGraph';
|
import { dashboardSceneGraph } from '../utils/dashboardSceneGraph';
|
||||||
import { getPanelIdForVizPanel } from '../utils/utils';
|
import { getPanelIdForVizPanel, getQueryRunnerFor } from '../utils/utils';
|
||||||
|
|
||||||
import { GRAFANA_DATASOURCE_REF } from './const';
|
import { GRAFANA_DATASOURCE_REF } from './const';
|
||||||
import { dataLayersToAnnotations } from './dataLayersToAnnotations';
|
import { dataLayersToAnnotations } from './dataLayersToAnnotations';
|
||||||
@ -208,6 +207,7 @@ export function gridItemToPanel(gridItem: SceneGridItemLike, isSnapshot = false)
|
|||||||
fieldConfig: (vizPanel.state.fieldConfig as FieldConfigSource) ?? { defaults: {}, overrides: [] },
|
fieldConfig: (vizPanel.state.fieldConfig as FieldConfigSource) ?? { defaults: {}, overrides: [] },
|
||||||
transformations: [],
|
transformations: [],
|
||||||
transparent: vizPanel.state.displayMode === 'transparent',
|
transparent: vizPanel.state.displayMode === 'transparent',
|
||||||
|
pluginVersion: vizPanel.state.pluginVersion,
|
||||||
...vizPanelDataToPanel(vizPanel, isSnapshot),
|
...vizPanelDataToPanel(vizPanel, isSnapshot),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,6 +228,18 @@ export function gridItemToPanel(gridItem: SceneGridItemLike, isSnapshot = false)
|
|||||||
const panelLinks = dashboardSceneGraph.getPanelLinks(vizPanel);
|
const panelLinks = dashboardSceneGraph.getPanelLinks(vizPanel);
|
||||||
panel.links = (panelLinks.state.rawLinks as DashboardLink[]) ?? [];
|
panel.links = (panelLinks.state.rawLinks as DashboardLink[]) ?? [];
|
||||||
|
|
||||||
|
if (panel.links.length === 0) {
|
||||||
|
delete panel.links;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (panel.transformations?.length === 0) {
|
||||||
|
delete panel.transformations;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!panel.transparent) {
|
||||||
|
delete panel.transparent;
|
||||||
|
}
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,24 +250,15 @@ function vizPanelDataToPanel(
|
|||||||
const dataProvider = vizPanel.state.$data;
|
const dataProvider = vizPanel.state.$data;
|
||||||
|
|
||||||
const panel: Pick<Panel, 'datasource' | 'targets' | 'maxDataPoints' | 'transformations'> = {};
|
const panel: Pick<Panel, 'datasource' | 'targets' | 'maxDataPoints' | 'transformations'> = {};
|
||||||
|
const queryRunner = getQueryRunnerFor(vizPanel);
|
||||||
|
|
||||||
// Regular queries handling
|
if (queryRunner) {
|
||||||
if (dataProvider instanceof SceneQueryRunner) {
|
panel.targets = queryRunner.state.queries;
|
||||||
panel.targets = dataProvider.state.queries;
|
panel.maxDataPoints = queryRunner.state.maxDataPoints;
|
||||||
panel.maxDataPoints = dataProvider.state.maxDataPoints;
|
panel.datasource = queryRunner.state.datasource;
|
||||||
panel.datasource = dataProvider.state.datasource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transformations handling
|
|
||||||
if (dataProvider instanceof SceneDataTransformer) {
|
if (dataProvider instanceof SceneDataTransformer) {
|
||||||
const panelData = dataProvider.state.$data;
|
|
||||||
|
|
||||||
if (panelData instanceof SceneQueryRunner) {
|
|
||||||
panel.targets = panelData.state.queries;
|
|
||||||
panel.maxDataPoints = panelData.state.maxDataPoints;
|
|
||||||
panel.datasource = panelData.state.datasource;
|
|
||||||
}
|
|
||||||
|
|
||||||
panel.transformations = dataProvider.state.transformations as DataTransformerConfig[];
|
panel.transformations = dataProvider.state.transformations as DataTransformerConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,8 @@ const defaults: any = {
|
|||||||
cachedPluginOptions: {},
|
cachedPluginOptions: {},
|
||||||
transparent: false,
|
transparent: false,
|
||||||
options: {},
|
options: {},
|
||||||
|
links: [],
|
||||||
|
transformations: [],
|
||||||
fieldConfig: {
|
fieldConfig: {
|
||||||
defaults: {},
|
defaults: {},
|
||||||
overrides: [],
|
overrides: [],
|
||||||
|
Reference in New Issue
Block a user