mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 01:53:57 +08:00
PanelEvents: Isolate more for old angular query editors (#30379)
This commit is contained in:
@ -14,12 +14,10 @@ import {
|
|||||||
fieldColorModeRegistry,
|
fieldColorModeRegistry,
|
||||||
FieldConfigProperty,
|
FieldConfigProperty,
|
||||||
FieldConfigSource,
|
FieldConfigSource,
|
||||||
PanelEvents,
|
|
||||||
PanelPlugin,
|
PanelPlugin,
|
||||||
ScopedVars,
|
ScopedVars,
|
||||||
ThresholdsConfig,
|
ThresholdsConfig,
|
||||||
ThresholdsMode,
|
ThresholdsMode,
|
||||||
EventBusExtended,
|
|
||||||
EventBusSrv,
|
EventBusSrv,
|
||||||
DataFrameDTO,
|
DataFrameDTO,
|
||||||
urlUtil,
|
urlUtil,
|
||||||
@ -154,7 +152,7 @@ export class PanelModel implements DataConfigSource {
|
|||||||
isInView: boolean;
|
isInView: boolean;
|
||||||
|
|
||||||
hasRefreshed: boolean;
|
hasRefreshed: boolean;
|
||||||
events: EventBusExtended;
|
events: EventBusSrv;
|
||||||
cacheTimeout?: any;
|
cacheTimeout?: any;
|
||||||
cachedPluginOptions?: any;
|
cachedPluginOptions?: any;
|
||||||
legend?: { show: boolean; sort?: string; sortDesc?: boolean };
|
legend?: { show: boolean; sort?: string; sortDesc?: boolean };
|
||||||
@ -479,7 +477,6 @@ export class PanelModel implements DataConfigSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.events.emit(PanelEvents.panelTeardown);
|
|
||||||
this.events.removeAllListeners();
|
this.events.removeAllListeners();
|
||||||
|
|
||||||
if (this.queryRunner) {
|
if (this.queryRunner) {
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
toLegacyResponseData,
|
toLegacyResponseData,
|
||||||
EventBusExtended,
|
EventBusExtended,
|
||||||
DataSourceInstanceSettings,
|
DataSourceInstanceSettings,
|
||||||
|
EventBusSrv,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { QueryEditorRowTitle } from './QueryEditorRowTitle';
|
import { QueryEditorRowTitle } from './QueryEditorRowTitle';
|
||||||
import {
|
import {
|
||||||
@ -88,7 +89,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
|
|||||||
onRunQuery();
|
onRunQuery();
|
||||||
},
|
},
|
||||||
render: () => () => console.log('legacy render function called, it does nothing'),
|
render: () => () => console.log('legacy render function called, it does nothing'),
|
||||||
events: panel.events,
|
events: new EventBusSrv(),
|
||||||
range: getTimeSrv().timeRange(),
|
range: getTimeSrv().timeRange(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -128,7 +129,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.angularQueryEditor) {
|
if (this.angularQueryEditor) {
|
||||||
notifyAngularQueryEditorsOfData(this.angularScope?.panel!, data, this.angularQueryEditor);
|
notifyAngularQueryEditorsOfData(this.angularScope!, data, this.angularQueryEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +323,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
|
|||||||
// So we can check if we already emitted this legacy data event
|
// So we can check if we already emitted this legacy data event
|
||||||
let globalLastPanelDataCache: PanelData | null = null;
|
let globalLastPanelDataCache: PanelData | null = null;
|
||||||
|
|
||||||
function notifyAngularQueryEditorsOfData(panel: PanelModel, data: PanelData, editor: AngularComponent) {
|
function notifyAngularQueryEditorsOfData(scope: AngularQueryComponentScope, data: PanelData, editor: AngularComponent) {
|
||||||
if (data === globalLastPanelDataCache) {
|
if (data === globalLastPanelDataCache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -331,9 +332,9 @@ function notifyAngularQueryEditorsOfData(panel: PanelModel, data: PanelData, edi
|
|||||||
|
|
||||||
if (data.state === LoadingState.Done) {
|
if (data.state === LoadingState.Done) {
|
||||||
const legacy = data.series.map(v => toLegacyResponseData(v));
|
const legacy = data.series.map(v => toLegacyResponseData(v));
|
||||||
panel.events.emit(PanelEvents.dataReceived, legacy);
|
scope.events.emit(PanelEvents.dataReceived, legacy);
|
||||||
} else if (data.state === LoadingState.Error) {
|
} else if (data.state === LoadingState.Error) {
|
||||||
panel.events.emit(PanelEvents.dataError, data.error);
|
scope.events.emit(PanelEvents.dataError, data.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some query controllers listen to data error events and need a digest
|
// Some query controllers listen to data error events and need a digest
|
||||||
|
Reference in New Issue
Block a user