mirror of
https://github.com/grafana/grafana.git
synced 2025-09-24 19:03:49 +08:00
allow templating for test datasource (#33447)
This commit is contained in:

committed by
GitHub

parent
83f26e9ce2
commit
cee30a05a1
@ -12,6 +12,7 @@ import {
|
||||
LiveChannelScope,
|
||||
LoadingState,
|
||||
TimeRange,
|
||||
ScopedVars,
|
||||
} from '@grafana/data';
|
||||
import { Scenario, TestDataQuery } from './types';
|
||||
import { DataSourceWithBackend, getBackendSrv, getGrafanaLiveSrv, getTemplateSrv, TemplateSrv } from '@grafana/runtime';
|
||||
@ -42,6 +43,8 @@ export class TestDataDataSource extends DataSourceWithBackend<TestDataQuery> {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.resolveTemplateVariables(target, options.scopedVars);
|
||||
|
||||
switch (target.scenarioId) {
|
||||
case 'live':
|
||||
streams.push(runGrafanaLiveQuery(target, options));
|
||||
@ -98,6 +101,10 @@ export class TestDataDataSource extends DataSourceWithBackend<TestDataQuery> {
|
||||
return merge(...streams);
|
||||
}
|
||||
|
||||
resolveTemplateVariables(query: TestDataQuery, scopedVars: ScopedVars) {
|
||||
query.labels = this.templateSrv.replace(query.labels!, scopedVars);
|
||||
}
|
||||
|
||||
annotationDataTopicTest(target: TestDataQuery, req: DataQueryRequest<TestDataQuery>): Observable<DataQueryResponse> {
|
||||
const events = this.buildFakeAnnotationEvents(req.range, 10);
|
||||
const dataFrame = new ArrayDataFrame(events);
|
||||
|
Reference in New Issue
Block a user