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


TypeScript datasource_srv.getDatasourceSrv函数代码示例

本文整理汇总了TypeScript中app/features/plugins/datasource_srv.getDatasourceSrv函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getDatasourceSrv函数的具体用法?TypeScript getDatasourceSrv怎么用?TypeScript getDatasourceSrv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getDatasourceSrv

  return async dispatch => {
    const exploreDatasources: DataSourceSelectItem[] = getDatasourceSrv()
      .getExternal()
      .map(ds => ({
        value: ds.name,
        name: ds.name,
        meta: ds.meta,
      }));

    dispatch(
      initializeExploreAction({
        exploreId,
        containerWidth,
        eventBridge,
        exploreDatasources,
        queries,
        range,
        ui,
      })
    );

    if (exploreDatasources.length >= 1) {
      let instance;

      if (datasourceName) {
        try {
          instance = await getDatasourceSrv().get(datasourceName);
        } catch (error) {
          console.error(error);
        }
      }
      // Checking on instance here because requested datasource could be deleted already
      if (!instance) {
        instance = await getDatasourceSrv().get();
      }

      dispatch(updateDatasourceInstanceAction({ exploreId, datasourceInstance: instance }));

      try {
        await dispatch(loadDatasource(exploreId, instance));
      } catch (error) {
        console.error(error);
        return;
      }
      dispatch(runQueries(exploreId, true));
    } else {
      dispatch(loadDatasourceMissingAction({ exploreId }));
    }
  };
开发者ID:CorpGlory,项目名称:grafana,代码行数:49,代码来源:actions.ts

示例2: async

  return async (dispatch, getState) => {
    let newDataSourceInstance: DataSourceApi = null;

    if (!datasource) {
      newDataSourceInstance = await getDatasourceSrv().get();
    } else {
      newDataSourceInstance = await getDatasourceSrv().get(datasource);
    }

    const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
    const queries = getState().explore[exploreId].queries;

    await dispatch(importQueries(exploreId, queries, currentDataSourceInstance, newDataSourceInstance));

    dispatch(updateDatasourceInstanceAction({ exploreId, datasourceInstance: newDataSourceInstance }));

    await dispatch(loadDatasource(exploreId, newDataSourceInstance));
    dispatch(runQueries(exploreId, false, replaceUrl));
  };
开发者ID:grafana,项目名称:grafana,代码行数:19,代码来源:actions.ts

示例3: async

  return async (dispatch, getState) => {
    const newDataSourceInstance = await getDatasourceSrv().get(datasource);
    const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
    const queries = getState().explore[exploreId].queries;

    await dispatch(importQueries(exploreId, queries, currentDataSourceInstance, newDataSourceInstance));

    dispatch(updateDatasourceInstanceAction({ exploreId, datasourceInstance: newDataSourceInstance }));

    try {
      await dispatch(loadDatasource(exploreId, newDataSourceInstance));
    } catch (error) {
      console.error(error);
      return;
    }

    dispatch(runQueries(exploreId));
  };
开发者ID:CorpGlory,项目名称:grafana,代码行数:18,代码来源:actions.ts

示例4: getDatasourceSrv

  return dispatch => {
    const exploreDatasources: DataSourceSelectItem[] = getDatasourceSrv()
      .getExternal()
      .map(
        (ds: any) =>
          ({
            value: ds.name,
            name: ds.name,
            meta: ds.meta,
          } as DataSourceSelectItem)
      );

    dispatch(loadExploreDatasources({ exploreId, exploreDatasources }));

    if (exploreDatasources.length >= 1) {
      dispatch(changeDatasource(exploreId, datasourceName));
    } else {
      dispatch(loadDatasourceMissingAction({ exploreId }));
    }
  };
开发者ID:johntdyer,项目名称:grafana,代码行数:20,代码来源:actions.ts

示例5: getDatasourceSrv

 .then(settings => {
   config.datasources = settings.datasources;
   config.defaultDatasource = settings.defaultDatasource;
   getDatasourceSrv().init();
 });
开发者ID:CorpGlory,项目名称:grafana,代码行数:5,代码来源:actions.ts


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