mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: define base panel type in @grafana/data (#37766)
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
PanelPluginDataSupport,
|
||||
ScopedVars,
|
||||
urlUtil,
|
||||
PanelModel as IPanelModel,
|
||||
DatasourceRef,
|
||||
} from '@grafana/data';
|
||||
import { EDIT_PANEL_ID } from 'app/core/constants';
|
||||
import config from 'app/core/config';
|
||||
@@ -124,7 +126,7 @@ const defaults: any = {
|
||||
title: '',
|
||||
};
|
||||
|
||||
export class PanelModel implements DataConfigSource {
|
||||
export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
/* persisted id, used in URL to identify a panel */
|
||||
id!: number;
|
||||
editSourceId?: number;
|
||||
@@ -144,7 +146,7 @@ export class PanelModel implements DataConfigSource {
|
||||
panels?: any;
|
||||
declare targets: DataQuery[];
|
||||
transformations?: DataTransformerConfig[];
|
||||
datasource: string | null = null;
|
||||
datasource: DatasourceRef | null = null;
|
||||
thresholds?: any;
|
||||
pluginVersion?: string;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
DataQueryResponse,
|
||||
DataSourceApi,
|
||||
DataSourceInstanceSettings,
|
||||
DatasourceRef,
|
||||
isValidLiveChannelAddress,
|
||||
parseLiveChannelAddress,
|
||||
StreamingFrameOptions,
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
import { GrafanaAnnotationQuery, GrafanaAnnotationType, GrafanaQuery, GrafanaQueryType } from './types';
|
||||
import AnnotationQueryEditor from './components/AnnotationQueryEditor';
|
||||
import { getDashboardSrv } from '../../../features/dashboard/services/DashboardSrv';
|
||||
import { isString } from 'lodash';
|
||||
|
||||
let counter = 100;
|
||||
|
||||
@@ -37,7 +39,11 @@ export class GrafanaDatasource extends DataSourceApi<GrafanaQuery> {
|
||||
return json;
|
||||
},
|
||||
prepareQuery(anno: AnnotationQuery<GrafanaAnnotationQuery>): GrafanaQuery {
|
||||
return { ...anno, refId: anno.name, queryType: GrafanaQueryType.Annotations };
|
||||
let datasource: DatasourceRef | undefined | null = undefined;
|
||||
if (isString(anno.datasource)) {
|
||||
datasource = anno.datasource as DatasourceRef;
|
||||
}
|
||||
return { ...anno, refId: anno.name, queryType: GrafanaQueryType.Annotations, datasource };
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PanelModel, FieldConfigSource } from '@grafana/data';
|
||||
import { PanelModel, FieldConfigSource, DataQuery } from '@grafana/data';
|
||||
import { graphPanelMigrationHandler } from './GraphMigrations';
|
||||
|
||||
describe('Graph Panel Migrations', () => {
|
||||
@@ -52,7 +52,7 @@ describe('Graph Panel Migrations', () => {
|
||||
spaceLength: 10,
|
||||
stack: false,
|
||||
steppedLine: false,
|
||||
targets: [
|
||||
targets: ([
|
||||
{
|
||||
alias: 'Foo datacenter',
|
||||
labels: 'datacenter=foo,region=us-east-1',
|
||||
@@ -71,7 +71,7 @@ describe('Graph Panel Migrations', () => {
|
||||
refId: 'C',
|
||||
scenarioId: 'random_walk',
|
||||
},
|
||||
],
|
||||
] as unknown) as DataQuery[],
|
||||
thresholds: [],
|
||||
timeFrom: null,
|
||||
timeRegions: [],
|
||||
|
||||
Reference in New Issue
Block a user