grafana/public/app/features/scenes/scenes/variablesDemo.tsx
Torkel Ödegaard 156ed4b56c
VizPanel: Support panel migrations and state changes (#58501)
* VizPanel: Make it more real

* Updates

* Progress on query runner and max data points from width

* Updated

* Update

* Tests

* Fixed issue with migration

* Moving VizPanel

* Fixed migration issue due to pluginVersion not being set

* Update public/app/features/scenes/querying/SceneQueryRunner.test.ts

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>

* Some minor review fixes

* Added expect

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
2022-11-21 15:31:01 +01:00

78 lines
2.2 KiB
TypeScript

import { VizPanel } from '../components';
import { Scene } from '../components/Scene';
import { SceneCanvasText } from '../components/SceneCanvasText';
import { SceneSubMenu } from '../components/SceneSubMenu';
import { SceneTimePicker } from '../components/SceneTimePicker';
import { SceneFlexLayout } from '../components/layout/SceneFlexLayout';
import { SceneTimeRange } from '../core/SceneTimeRange';
import { VariableValueSelectors } from '../variables/components/VariableValueSelectors';
import { SceneVariableSet } from '../variables/sets/SceneVariableSet';
import { TestVariable } from '../variables/variants/TestVariable';
import { getQueryRunnerWithRandomWalkQuery } from './queries';
export function getVariablesDemo(): Scene {
const scene = new Scene({
title: 'Variables',
$variables: new SceneVariableSet({
variables: [
new TestVariable({
name: 'server',
query: 'A.*',
value: 'server',
text: '',
delayMs: 1000,
options: [],
}),
new TestVariable({
name: 'pod',
query: 'A.$server.*',
value: 'pod',
delayMs: 1000,
isMulti: true,
text: '',
options: [],
}),
new TestVariable({
name: 'handler',
query: 'A.$server.$pod.*',
value: 'handler',
delayMs: 1000,
//isMulti: true,
text: '',
options: [],
}),
],
}),
layout: new SceneFlexLayout({
direction: 'row',
children: [
new SceneFlexLayout({
children: [
new VizPanel({
pluginId: 'timeseries',
title: 'handler: $handler',
$data: getQueryRunnerWithRandomWalkQuery({
alias: 'handler: $handler',
}),
}),
new SceneCanvasText({
size: { width: '40%' },
text: 'server: ${server} pod:${pod}',
fontSize: 20,
align: 'center',
}),
],
}),
],
}),
$timeRange: new SceneTimeRange(),
actions: [new SceneTimePicker({})],
subMenu: new SceneSubMenu({
children: [new VariableValueSelectors({})],
}),
});
return scene;
}