initTemplateSrv.ts 514 B

1234567891011121314
  1. import { TimeRange } from '@grafana/data';
  2. import { TemplateSrv } from '../../app/features/templating/template_srv';
  3. import { convertToStoreState } from './convertToStoreState';
  4. import { getTemplateSrvDependencies } from './getTemplateSrvDependencies';
  5. export function initTemplateSrv(key: string, variables: any[], timeRange?: TimeRange) {
  6. const state = convertToStoreState(key, variables);
  7. const srv = new TemplateSrv(getTemplateSrvDependencies(state));
  8. srv.init(variables, timeRange);
  9. return srv;
  10. }