2020-12-15 06:29:37 -06:00
|
|
|
import { TimeRange } from '@grafana/data';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2020-12-15 06:29:37 -06:00
|
|
|
import { TemplateSrv } from '../../app/features/templating/template_srv';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
|
|
|
import { convertToStoreState } from './convertToStoreState';
|
2020-12-15 06:29:37 -06:00
|
|
|
import { getTemplateSrvDependencies } from './getTemplateSrvDependencies';
|
|
|
|
|
2022-02-17 23:06:04 -06:00
|
|
|
export function initTemplateSrv(key: string, variables: any[], timeRange?: TimeRange) {
|
|
|
|
const state = convertToStoreState(key, variables);
|
2020-12-15 06:29:37 -06:00
|
|
|
const srv = new TemplateSrv(getTemplateSrvDependencies(state));
|
|
|
|
srv.init(variables, timeRange);
|
|
|
|
|
|
|
|
return srv;
|
|
|
|
}
|