-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
TemplateSrvStub.ts
31 lines (27 loc) · 1.08 KB
/
TemplateSrvStub.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { ScopedVars, TimeRange } from '@grafana/data';
import { TemplateSrv } from '@grafana/runtime/services/templateSrv';
import template from 'lodash/template';
export default class TemplateSrvStub implements TemplateSrv {
containsTemplate(target?: string | undefined): boolean {
throw new Error('Method not implemented.');
}
updateTimeRange(timeRange: TimeRange): void {
throw new Error('Method not implemented.');
}
templateSettings = { interpolate: /\[\[([\s\S]+?)\]\]/g };
data = {};
adhocFilters = [];
// tslint:disable-next-line:max-line-length
// https://github.com/grafana/grafana/blob/c1c0daa13d5951e3e13d46ef9467d9d832993fe5/public/app/features/variables/utils.ts#L23
regex = /\$(\w+)|\[\[(\w+?)(?::(\w+))?\]\]|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/g;
replace(target?: string, scopedVars?: ScopedVars, format?: string | Function): string {
return template(target, this.templateSettings)(this.data);
}
getVariables() {
return [];
}
getAdhocFilters(datasourceName: string) {
return this.adhocFilters;
}
updateTemplateData() {}
}