Annotations: Turns on annotations in Graph and TimeSeries (#33402)

* Annotations: Turns on annotations in Graph and TimeSeries

* Refactor: moves to notPersistedProperties
This commit is contained in:
Hugo Häggmark
2021-04-27 07:39:02 +02:00
committed by GitHub
parent 495345c0c2
commit a3584f21de
4 changed files with 8 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import {
EventBusSrv, EventBusSrv,
FieldConfigSource, FieldConfigSource,
PanelPlugin, PanelPlugin,
PanelPluginDataSupport,
ScopedVars, ScopedVars,
urlUtil, urlUtil,
} from '@grafana/data'; } from '@grafana/data';
@@ -61,6 +62,7 @@ const notPersistedProperties: { [str: string]: boolean } = {
editSourceId: true, editSourceId: true,
configRev: true, configRev: true,
getDisplayTitle: true, getDisplayTitle: true,
dataSupport: true,
}; };
// For angular panels we need to clean up properties when changing type // For angular panels we need to clean up properties when changing type
@@ -171,6 +173,7 @@ export class PanelModel implements DataConfigSource {
declare cachedPluginOptions: Record<string, PanelOptionsCache>; declare cachedPluginOptions: Record<string, PanelOptionsCache>;
legend?: { show: boolean; sort?: string; sortDesc?: boolean }; legend?: { show: boolean; sort?: string; sortDesc?: boolean };
plugin?: PanelPlugin; plugin?: PanelPlugin;
dataSupport?: PanelPluginDataSupport;
private queryRunner?: PanelQueryRunner; private queryRunner?: PanelQueryRunner;
@@ -354,6 +357,7 @@ export class PanelModel implements DataConfigSource {
} }
} }
this.dataSupport = plugin.dataSupport;
this.applyPluginOptionDefaults(plugin, false); this.applyPluginOptionDefaults(plugin, false);
this.resendLastResult(); this.resendLastResult();
} }

View File

@@ -72,6 +72,7 @@ export class PanelQueryRunner {
constructor(dataConfigSource: DataConfigSource) { constructor(dataConfigSource: DataConfigSource) {
this.subject = new ReplaySubject(1); this.subject = new ReplaySubject(1);
this.dataConfigSource = dataConfigSource; this.dataConfigSource = dataConfigSource;
this.dataSupport = this.dataConfigSource.dataSupport;
} }
/** /**

View File

@@ -373,6 +373,7 @@ export const plugin = new PanelPlugin<GraphPanelOptions, GraphFieldConfig>(null)
FieldConfigProperty.Mappings, FieldConfigProperty.Mappings,
], ],
}) })
.setDataSupport({ annotations: true, alertStates: true })
.setMigrationHandler(graphPanelMigrationHandler); .setMigrationHandler(graphPanelMigrationHandler);
// Use the angular ctrt rather than a react one // Use the angular ctrt rather than a react one

View File

@@ -25,4 +25,5 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(TimeSeriesPanel
}); });
addLegendOptions(builder); addLegendOptions(builder);
}); })
.setDataSupport({ annotations: true });