mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Dashboard schema fixes and scene to save model fixes (#81867)
This commit is contained in:
parent
9fab7bd27d
commit
071b301e39
@ -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. |
|
||||
| `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. |
|
||||
| `tags` | string[] | No | | Tags for the panel. |
|
||||
| `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 |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `tags` | string[] | No | | Tags for the panel. |
|
||||
| `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 |
|
||||
| `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.
|
||||
pluginVersion?: string
|
||||
|
||||
// Tags for the panel.
|
||||
tags?: [...string]
|
||||
|
||||
// Depends on the panel plugin. See the plugin documentation for details.
|
||||
targets?: [...#Target]
|
||||
|
||||
|
@ -757,10 +757,6 @@ export interface Panel {
|
||||
* `h` for horizontal, `v` for vertical.
|
||||
*/
|
||||
repeatDirection?: ('h' | 'v');
|
||||
/**
|
||||
* Tags for the panel.
|
||||
*/
|
||||
tags?: Array<string>;
|
||||
/**
|
||||
* Depends on the panel plugin. See the plugin documentation for details.
|
||||
*/
|
||||
@ -806,7 +802,6 @@ export interface Panel {
|
||||
export const defaultPanel: Partial<Panel> = {
|
||||
links: [],
|
||||
repeatDirection: 'h',
|
||||
tags: [],
|
||||
targets: [],
|
||||
transformations: [],
|
||||
transparent: false,
|
||||
|
@ -558,9 +558,6 @@ type Panel struct {
|
||||
// `h` for horizontal, `v` for vertical.
|
||||
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.
|
||||
Targets []Target `json:"targets,omitempty"`
|
||||
|
||||
|
@ -110,7 +110,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
||||
"y": 1,
|
||||
},
|
||||
"id": 15,
|
||||
"links": [],
|
||||
"options": {
|
||||
"code": {
|
||||
"language": "plaintext",
|
||||
@ -124,9 +123,8 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
||||
</div>",
|
||||
"mode": "markdown",
|
||||
},
|
||||
"pluginVersion": "10.2.0-pre",
|
||||
"title": "",
|
||||
"transformations": [],
|
||||
"transparent": false,
|
||||
"type": "text",
|
||||
},
|
||||
{
|
||||
@ -165,7 +163,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
||||
"y": 26,
|
||||
},
|
||||
"id": 30,
|
||||
"links": [],
|
||||
"options": {
|
||||
"code": {
|
||||
"language": "plaintext",
|
||||
@ -177,9 +174,8 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
|
||||
</div>",
|
||||
"mode": "markdown",
|
||||
},
|
||||
"pluginVersion": "10.2.0-pre",
|
||||
"title": "Text panel in collapsed row",
|
||||
"transformations": [],
|
||||
"transparent": false,
|
||||
"type": "text",
|
||||
},
|
||||
],
|
||||
@ -378,7 +374,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
"y": 0,
|
||||
},
|
||||
"id": 28,
|
||||
"links": [],
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
@ -404,8 +399,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
},
|
||||
],
|
||||
"title": "Simple time series graph ",
|
||||
"transformations": [],
|
||||
"transparent": false,
|
||||
"type": "timeseries",
|
||||
},
|
||||
{
|
||||
@ -437,7 +430,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
"y": 9,
|
||||
},
|
||||
"id": 29,
|
||||
"links": [],
|
||||
"options": {},
|
||||
"targets": [
|
||||
{
|
||||
@ -452,8 +444,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
},
|
||||
],
|
||||
"title": "panel inside row",
|
||||
"transformations": [],
|
||||
"transparent": false,
|
||||
"type": "timeseries",
|
||||
},
|
||||
{
|
||||
@ -468,7 +458,6 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
"y": 9,
|
||||
},
|
||||
"id": 25,
|
||||
"links": [],
|
||||
"options": {
|
||||
"code": {
|
||||
"language": "plaintext",
|
||||
@ -478,8 +467,8 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
"content": "content",
|
||||
"mode": "markdown",
|
||||
},
|
||||
"pluginVersion": "10.2.0-pre",
|
||||
"title": "Transparent text panel",
|
||||
"transformations": [],
|
||||
"transparent": true,
|
||||
"type": "text",
|
||||
},
|
||||
@ -697,7 +686,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
"y": 0,
|
||||
},
|
||||
"id": 28,
|
||||
"links": [],
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
@ -723,8 +711,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
},
|
||||
],
|
||||
"title": "Simple time series graph ",
|
||||
"transformations": [],
|
||||
"transparent": false,
|
||||
"type": "timeseries",
|
||||
},
|
||||
{
|
||||
@ -756,7 +742,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
"y": 9,
|
||||
},
|
||||
"id": 29,
|
||||
"links": [],
|
||||
"options": {},
|
||||
"targets": [
|
||||
{
|
||||
@ -771,8 +756,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
},
|
||||
],
|
||||
"title": "panel inside row",
|
||||
"transformations": [],
|
||||
"transparent": false,
|
||||
"type": "timeseries",
|
||||
},
|
||||
{
|
||||
@ -787,7 +770,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
"y": 9,
|
||||
},
|
||||
"id": 25,
|
||||
"links": [],
|
||||
"options": {
|
||||
"code": {
|
||||
"language": "plaintext",
|
||||
@ -797,8 +779,8 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
"content": "content",
|
||||
"mode": "markdown",
|
||||
},
|
||||
"pluginVersion": "10.2.0-pre",
|
||||
"title": "Transparent text panel",
|
||||
"transformations": [],
|
||||
"transparent": true,
|
||||
"type": "text",
|
||||
},
|
||||
|
@ -7,7 +7,6 @@ import {
|
||||
SceneGridLayout,
|
||||
SceneGridRow,
|
||||
VizPanel,
|
||||
SceneQueryRunner,
|
||||
SceneDataTransformer,
|
||||
SceneVariableSet,
|
||||
AdHocFilterSet,
|
||||
@ -39,7 +38,7 @@ import { PanelRepeaterGridItem } from '../scene/PanelRepeaterGridItem';
|
||||
import { PanelTimeRange } from '../scene/PanelTimeRange';
|
||||
import { RowRepeaterBehavior } from '../scene/RowRepeaterBehavior';
|
||||
import { dashboardSceneGraph } from '../utils/dashboardSceneGraph';
|
||||
import { getPanelIdForVizPanel } from '../utils/utils';
|
||||
import { getPanelIdForVizPanel, getQueryRunnerFor } from '../utils/utils';
|
||||
|
||||
import { GRAFANA_DATASOURCE_REF } from './const';
|
||||
import { dataLayersToAnnotations } from './dataLayersToAnnotations';
|
||||
@ -208,6 +207,7 @@ export function gridItemToPanel(gridItem: SceneGridItemLike, isSnapshot = false)
|
||||
fieldConfig: (vizPanel.state.fieldConfig as FieldConfigSource) ?? { defaults: {}, overrides: [] },
|
||||
transformations: [],
|
||||
transparent: vizPanel.state.displayMode === 'transparent',
|
||||
pluginVersion: vizPanel.state.pluginVersion,
|
||||
...vizPanelDataToPanel(vizPanel, isSnapshot),
|
||||
};
|
||||
|
||||
@ -228,6 +228,18 @@ export function gridItemToPanel(gridItem: SceneGridItemLike, isSnapshot = false)
|
||||
const panelLinks = dashboardSceneGraph.getPanelLinks(vizPanel);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -238,24 +250,15 @@ function vizPanelDataToPanel(
|
||||
const dataProvider = vizPanel.state.$data;
|
||||
|
||||
const panel: Pick<Panel, 'datasource' | 'targets' | 'maxDataPoints' | 'transformations'> = {};
|
||||
const queryRunner = getQueryRunnerFor(vizPanel);
|
||||
|
||||
// Regular queries handling
|
||||
if (dataProvider instanceof SceneQueryRunner) {
|
||||
panel.targets = dataProvider.state.queries;
|
||||
panel.maxDataPoints = dataProvider.state.maxDataPoints;
|
||||
panel.datasource = dataProvider.state.datasource;
|
||||
if (queryRunner) {
|
||||
panel.targets = queryRunner.state.queries;
|
||||
panel.maxDataPoints = queryRunner.state.maxDataPoints;
|
||||
panel.datasource = queryRunner.state.datasource;
|
||||
}
|
||||
|
||||
// Transformations handling
|
||||
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[];
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,8 @@ const defaults: any = {
|
||||
cachedPluginOptions: {},
|
||||
transparent: false,
|
||||
options: {},
|
||||
links: [],
|
||||
transformations: [],
|
||||
fieldConfig: {
|
||||
defaults: {},
|
||||
overrides: [],
|
||||
|
Loading…
Reference in New Issue
Block a user