當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript template_srv.TemplateSrv類代碼示例

本文整理匯總了TypeScript中app/features/templating/template_srv.TemplateSrv的典型用法代碼示例。如果您正苦於以下問題:TypeScript TemplateSrv類的具體用法?TypeScript TemplateSrv怎麽用?TypeScript TemplateSrv使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TemplateSrv類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2:

 getEc2InstanceAttribute(region, attributeName, filters) {
   return this.doMetricQueryRequest('ec2_instance_attribute', {
     region: this.templateSrv.replace(this.getActualRegion(region)),
     attributeName: this.templateSrv.replace(attributeName),
     filters: filters,
   });
 }
開發者ID:johntdyer,項目名稱:grafana,代碼行數:7,代碼來源:datasource.ts

示例3: getResourceARNs

 getResourceARNs(region, resourceType, tags) {
   return this.doMetricQueryRequest('resource_arns', {
     region: this.templateSrv.replace(this.getActualRegion(region)),
     resourceType: this.templateSrv.replace(resourceType),
     tags: tags,
   });
 }
開發者ID:johntdyer,項目名稱:grafana,代碼行數:7,代碼來源:datasource.ts

示例4: LogAnalyticsQuerystringBuilder

    }).map(target => {
      const item = target.azureLogAnalytics;

      const querystringBuilder = new LogAnalyticsQuerystringBuilder(
        this.templateSrv.replace(item.query, options.scopedVars, this.interpolateVariable),
        options,
        'TimeGenerated'
      );
      const generated = querystringBuilder.generate();

      const workspace = this.templateSrv.replace(item.workspace, options.scopedVars);

      const url = `${this.baseUrl}/${workspace}/query?${generated.uriString}`;

      return {
        refId: target.refId,
        intervalMs: options.intervalMs,
        maxDataPoints: options.maxDataPoints,
        datasourceId: this.id,
        url: url,
        query: generated.rawQuery,
        format: target.format,
        resultFormat: item.resultFormat,
      };
    });
開發者ID:grafana,項目名稱:grafana,代碼行數:25,代碼來源:azure_log_analytics_datasource.ts

示例5: getDimensionValues

 getDimensionValues(region, namespace, metricName, dimensionKey, filterDimensions) {
   return this.doMetricQueryRequest('dimension_values', {
     region: this.templateSrv.replace(this.getActualRegion(region)),
     namespace: this.templateSrv.replace(namespace),
     metricName: this.templateSrv.replace(metricName),
     dimensionKey: this.templateSrv.replace(dimensionKey),
     dimensions: this.convertDimensionFormat(filterDimensions, {}),
   });
 }
開發者ID:johntdyer,項目名稱:grafana,代碼行數:9,代碼來源:datasource.ts

示例6: targetContainsTemplate

 targetContainsTemplate(target) {
   return (
     this.templateSrv.variableExists(target.region) ||
     this.templateSrv.variableExists(target.namespace) ||
     this.templateSrv.variableExists(target.metricName) ||
     _.find(target.dimensions, (v, k) => {
       return this.templateSrv.variableExists(k) || this.templateSrv.variableExists(v);
     })
   );
 }
開發者ID:johntdyer,項目名稱:grafana,代碼行數:10,代碼來源:datasource.ts

示例7: 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

示例8:

 .map(t => {
   return {
     refId: t.refId,
     intervalMs: options.intervalMs,
     datasourceId: this.id,
     metricType: this.templateSrv.replace(t.metricType, options.scopedVars || {}),
     crossSeriesReducer: this.templateSrv.replace(t.crossSeriesReducer || 'REDUCE_MEAN', options.scopedVars || {}),
     perSeriesAligner: this.templateSrv.replace(t.perSeriesAligner, options.scopedVars || {}),
     alignmentPeriod: this.templateSrv.replace(t.alignmentPeriod, options.scopedVars || {}),
     groupBys: this.interpolateGroupBys(t.groupBys, options.scopedVars),
     view: t.view || 'FULL',
     filters: this.interpolateFilters(t.filters, options.scopedVars),
     aliasBy: this.templateSrv.replace(t.aliasBy, options.scopedVars || {}),
     type: 'timeSeriesQuery',
   };
 });
開發者ID:grafana,項目名稱:grafana,代碼行數:16,代碼來源:datasource.ts

示例9: annotationQuery

  annotationQuery(options) {
    const annotation = options.annotation;
    const statistics = _.map(annotation.statistics, s => {
      return this.templateSrv.replace(s);
    });
    const defaultPeriod = annotation.prefixMatching ? '' : '300';
    let period = annotation.period || defaultPeriod;
    period = parseInt(period, 10);
    const parameters = {
      prefixMatching: annotation.prefixMatching,
      region: this.templateSrv.replace(this.getActualRegion(annotation.region)),
      namespace: this.templateSrv.replace(annotation.namespace),
      metricName: this.templateSrv.replace(annotation.metricName),
      dimensions: this.convertDimensionFormat(annotation.dimensions, {}),
      statistics: statistics,
      period: period,
      actionPrefix: annotation.actionPrefix || '',
      alarmNamePrefix: annotation.alarmNamePrefix || '',
    };

    return this.awsRequest('/api/tsdb/query', {
      from: options.range.from.valueOf().toString(),
      to: options.range.to.valueOf().toString(),
      queries: [
        _.extend(
          {
            refId: 'annotationQuery',
            intervalMs: 1, // dummy
            maxDataPoints: 1, // dummy
            datasourceId: this.instanceSettings.id,
            type: 'annotationQuery',
          },
          parameters
        ),
      ],
    }).then(r => {
      return _.map(r.results['annotationQuery'].tables[0].rows, v => {
        return {
          annotation: annotation,
          time: Date.parse(v[0]),
          title: v[1],
          tags: [v[2]],
          text: v[3],
        };
      });
    });
  }
開發者ID:johntdyer,項目名稱:grafana,代碼行數:47,代碼來源:datasource.ts


注:本文中的app/features/templating/template_srv.TemplateSrv類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。