mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PanelEdit: Trigger refresh when changing data source (#30744)
This commit is contained in:
parent
e0356f7b13
commit
a8a3e02699
@ -49,7 +49,10 @@ export class PanelEditorQueries extends PureComponent<Props, State> {
|
|||||||
onOptionsChange = (options: QueryGroupOptions) => {
|
onOptionsChange = (options: QueryGroupOptions) => {
|
||||||
const { panel } = this.props;
|
const { panel } = this.props;
|
||||||
|
|
||||||
panel.datasource = options.dataSource.default ? null : options.dataSource.name!;
|
const newDataSourceName = options.dataSource.default ? null : options.dataSource.name!;
|
||||||
|
const dataSourceChanged = newDataSourceName !== panel.datasource;
|
||||||
|
|
||||||
|
panel.datasource = newDataSourceName;
|
||||||
panel.targets = options.queries;
|
panel.targets = options.queries;
|
||||||
panel.timeFrom = options.timeRange?.from;
|
panel.timeFrom = options.timeRange?.from;
|
||||||
panel.timeShift = options.timeRange?.shift;
|
panel.timeShift = options.timeRange?.shift;
|
||||||
@ -57,6 +60,11 @@ export class PanelEditorQueries extends PureComponent<Props, State> {
|
|||||||
panel.interval = options.minInterval;
|
panel.interval = options.minInterval;
|
||||||
panel.maxDataPoints = options.maxDataPoints;
|
panel.maxDataPoints = options.maxDataPoints;
|
||||||
|
|
||||||
|
if (dataSourceChanged) {
|
||||||
|
// trigger queries when changing data source
|
||||||
|
setTimeout(this.onRunQueries, 10);
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ options: options });
|
this.setState({ options: options });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user