当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TemplateSrv.init方法代码示例

本文整理汇总了TypeScript中app/features/templating/template_srv.TemplateSrv.init方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TemplateSrv.init方法的具体用法?TypeScript TemplateSrv.init怎么用?TypeScript TemplateSrv.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app/features/templating/template_srv.TemplateSrv的用法示例。


在下文中一共展示了TemplateSrv.init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: init

  init(dashboard: DashboardModel) {
    this.dashboard = dashboard;
    this.dashboard.events.on('time-range-updated', this.onTimeRangeUpdated.bind(this));
    this.dashboard.events.on('template-variable-value-updated', this.updateUrlParamsWithCurrentVariables.bind(this));

    // create working class models representing variables
    this.variables = dashboard.templating.list = dashboard.templating.list.map(this.createVariableFromModel.bind(this));
    this.templateSrv.init(this.variables, this.timeSrv.timeRange());

    // init variables
    for (const variable of this.variables) {
      variable.initLock = this.$q.defer();
    }

    const queryParams = this.$location.search();
    return this.$q
      .all(
        this.variables.map(variable => {
          return this.processVariable(variable, queryParams);
        })
      )
      .then(() => {
        this.templateSrv.updateIndex();
      });
  }
开发者ID:bergquist,项目名称:grafana,代码行数:25,代码来源:variable_srv.ts

示例2: initTemplateSrv

function initTemplateSrv(values: any, multi = false) {
  const templateSrv = new TemplateSrv();
  templateSrv.init([
    new CustomVariable(
      {
        name: 'test',
        current: {
          value: values,
        },
        multi: multi,
      },
      {}
    ),
  ]);
  return templateSrv;
}
开发者ID:CorpGlory,项目名称:grafana,代码行数:16,代码来源:datasource.test.ts

示例3: beforeEach

    beforeEach(() => {
      templateSrv.init([
        new CustomVariable(
          {
            name: 'var1',
            current: {
              value: 'var1-foo',
            },
            multi: false,
          },
          {}
        ),
        new CustomVariable(
          {
            name: 'var2',
            current: {
              value: 'var2-foo',
            },
            multi: false,
          },
          {}
        ),
        new CustomVariable(
          {
            name: 'var3',
            options: [
              { selected: true, value: 'var3-foo' },
              { selected: false, value: 'var3-bar' },
              { selected: true, value: 'var3-baz' },
            ],
            current: {
              value: ['var3-foo', 'var3-baz'],
            },
            multi: true,
          },
          {}
        ),
      ]);

      ctx.backendSrv.datasourceRequest = jest.fn(params => {
        requestParams = params.data;
        return Promise.resolve({ data: {} });
      });
    });
开发者ID:grafana,项目名称:grafana,代码行数:44,代码来源:datasource.test.ts

示例4: it

    it('should generate the correct query with interval variable', done => {
      templateSrv.init([
        new CustomVariable(
          {
            name: 'period',
            current: {
              value: '10m',
            },
            multi: false,
          },
          {}
        ),
      ]);

      const query = {
        range: { from: 'now-1h', to: 'now' },
        rangeRaw: { from: 1483228800, to: 1483232400 },
        targets: [
          {
            refId: 'A',
            region: 'us-east-1',
            namespace: 'AWS/EC2',
            metricName: 'CPUUtilization',
            dimensions: {
              InstanceId: 'i-12345678',
            },
            statistics: ['Average'],
            period: '[[period]]',
          },
        ],
      };

      ctx.ds.query(query).then(() => {
        const params = requestParams.queries[0];
        expect(params.period).toBe('600');
        done();
      });
    });
开发者ID:grafana,项目名称:grafana,代码行数:38,代码来源:datasource.test.ts


注:本文中的app/features/templating/template_srv.TemplateSrv.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。