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


TypeScript toastNotifications.addDanger方法代码示例

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


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

示例1: fetch

  public async fetch(params: RequestHandlerParams): Promise<any> {
    this.vis.filters = { timeRange: params.timeRange };
    this.vis.requestError = undefined;
    this.vis.showRequestError = false;

    try {
      // searchSource is only there for courier request handler
      const requestHandlerResponse = await this.requestHandler({
        partialRows: this.vis.params.partialRows || this.vis.type.requiresPartialRows,
        isHierarchical: this.vis.isHierarchical(),
        visParams: this.vis.params,
        ...params,
        filters: params.filters
          ? params.filters.filter(filter => !filter.meta.disabled)
          : undefined,
      });

      // No need to call the response handler when there have been no data nor has been there changes
      // in the vis-state (response handler does not depend on uiStat
      const canSkipResponseHandler =
        this.previousRequestHandlerResponse &&
        this.previousRequestHandlerResponse === requestHandlerResponse &&
        this.previousVisState &&
        isEqual(this.previousVisState, this.vis.getState());

      this.previousVisState = this.vis.getState();
      this.previousRequestHandlerResponse = requestHandlerResponse;

      if (!canSkipResponseHandler) {
        this.visData = await Promise.resolve(this.responseHandler(requestHandlerResponse));
      }
      return this.visData;
    } catch (error) {
      params.searchSource.cancelQueued();

      this.vis.requestError = error;
      this.vis.showRequestError =
        error.type && ['NO_OP_SEARCH_STRATEGY', 'UNSUPPORTED_QUERY'].includes(error.type);

      // tslint:disable-next-line
      console.error(error);

      if (isTermSizeZeroError(error)) {
        return toastNotifications.addDanger(
          `Your visualization ('${this.vis.title}') has an error: it has a term ` +
            `aggregation with a size of 0. Please set it to a number greater than 0 to resolve ` +
            `the error.`
        );
      }

      toastNotifications.addDanger({
        title: 'Error in visualization',
        text: error.message,
      });
    }
  }
开发者ID:gingerwizard,项目名称:kibana,代码行数:56,代码来源:visualize_data_loader.ts

示例2: async

): GetJobs => async (forceRefresh = false) => {
  if (forceRefresh === true || blockRefresh === false) {
    try {
      const jobConfigs: GetDataFrameTransformsResponse = await ml.dataFrame.getDataFrameTransforms();
      const jobStats: GetDataFrameTransformsStatsResponse = await ml.dataFrame.getDataFrameTransformsStats();

      const tableRows = jobConfigs.transforms.map(config => {
        const stats = jobStats.transforms.find(d => config.id === d.id);

        if (stats === undefined) {
          throw new Error('job stats not available');
        }

        // table with expandable rows requires `id` on the outer most level
        return { config, id: config.id, state: stats.state, stats: stats.stats };
      });

      setDataFrameJobs(tableRows);
    } catch (e) {
      toastNotifications.addDanger(
        i18n.translate('xpack.ml.dataframe.jobsList.errorGettingDataFrameJobsList', {
          defaultMessage: 'An error occurred getting the data frame jobs list: {error}',
          values: { error: JSON.stringify(e) },
        })
      );
    }
  }
};
开发者ID:elastic,项目名称:kibana,代码行数:28,代码来源:get_jobs.ts

示例3:

 .catch(resp => {
   toastNotifications.addDanger(
     i18n.translate('xpack.ml.fullTimeRangeSelector.errorSettingTimeRangeNotification', {
       defaultMessage: 'An error occurred setting the time range.',
     })
   );
 });
开发者ID:elastic,项目名称:kibana,代码行数:7,代码来源:full_time_range_selector_service.ts

示例4: queryGeohashBounds

export async function queryGeohashBounds(vis: Vis, params: QueryGeohashBoundsParams) {
  const agg = vis.getAggConfig().find((a: AggConfig) => {
    return get(a, 'type.dslName') === 'geohash_grid';
  });

  if (agg) {
    const searchSource = vis.searchSource.createChild();
    searchSource.setField('size', 0);
    searchSource.setField('aggs', () => {
      const geoBoundsAgg = vis.getAggConfig().createAggConfig(
        {
          type: 'geo_bounds',
          enabled: true,
          params: {
            field: agg.getField(),
          },
          schema: 'metric',
        },
        {
          addToAggConfigs: false,
        }
      );
      return {
        '1': geoBoundsAgg.toDsl(),
      };
    });

    const { filters, query } = params;
    if (filters) {
      searchSource.setField('filter', () => {
        const activeFilters = [...filters];
        const indexPattern = agg.getIndexPattern();
        const useTimeFilter = !!indexPattern.timeFieldName;
        if (useTimeFilter) {
          activeFilters.push(vis.API.timeFilter.createFilter(indexPattern));
        }
        return activeFilters;
      });
    }
    if (query) {
      searchSource.setField('query', query);
    }

    try {
      const esResp = await searchSource.fetch();
      return get(esResp, 'aggregations.1.bounds');
    } catch (error) {
      toastNotifications.addDanger({
        title: i18n.translate('common.ui.visualize.queryGeohashBounds.unableToGetBoundErrorTitle', {
          defaultMessage: 'Unable to get bounds',
        }),
        text: `${error.message}`,
      });
      return;
    }
  }
}
开发者ID:elastic,项目名称:kibana,代码行数:57,代码来源:query_geohash_bounds.ts

示例5: _displayError

 public _displayError() {
   toastNotifications.addDanger({
     title: i18n.translate('xpack.spaces.spacesManager.unableToChangeSpaceWarningTitle', {
       defaultMessage: 'Unable to change your Space',
     }),
     text: i18n.translate('xpack.spaces.spacesManager.unableToChangeSpaceWarningDescription', {
       defaultMessage: 'please try again later',
     }),
   });
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例6: fetch

  public async fetch(params: RequestHandlerParams): Promise<any> {
    this.vis.filters = { timeRange: params.timeRange };

    try {
      // searchSource is only there for courier request handler
      const requestHandlerResponse = await this.requestHandler(this.vis, {
        partialRows: this.vis.params.partialRows || this.vis.type.requiresPartialRows,
        ...params,
      });

      // No need to call the response handler when there have been no data nor has been there changes
      // in the vis-state (response handler does not depend on uiStat
      const canSkipResponseHandler =
        this.previousRequestHandlerResponse &&
        this.previousRequestHandlerResponse === requestHandlerResponse &&
        this.previousVisState &&
        isEqual(this.previousVisState, this.vis.getState());

      this.previousVisState = this.vis.getState();
      this.previousRequestHandlerResponse = requestHandlerResponse;

      if (!canSkipResponseHandler) {
        this.visData = await Promise.resolve(this.responseHandler(requestHandlerResponse));
      }
      return this.visData;
    } catch (e) {
      params.searchSource.cancelQueued();
      this.vis.requestError = e;
      if (isTermSizeZeroError(e)) {
        return toastNotifications.addDanger(
          `Your visualization ('${this.vis.title}') has an error: it has a term ` +
            `aggregation with a size of 0. Please set it to a number greater than 0 to resolve ` +
            `the error.`
        );
      }
      toastNotifications.addDanger({
        title: 'Error in visualization',
        text: e.message,
      });
    }
  }
开发者ID:salihkardan,项目名称:kibana,代码行数:41,代码来源:visualize_data_loader.ts

示例7: async

export const startJobFactory = (getJobs: GetJobs) => async (d: DataFrameJobListRow) => {
  try {
    await ml.dataFrame.startDataFrameTransformsJob(d.config.id);
    toastNotifications.addSuccess(
      i18n.translate('xpack.ml.dataframe.jobsList.startJobSuccessMessage', {
        defaultMessage: 'Data frame job {jobId} started successfully.',
        values: { jobId: d.config.id },
      })
    );
    getJobs(true);
  } catch (e) {
    toastNotifications.addDanger(
      i18n.translate('xpack.ml.dataframe.jobsList.startJobErrorMessage', {
        defaultMessage: 'An error occurred starting the data frame job {jobId}: {error}',
        values: { jobId: d.config.id, error: JSON.stringify(e) },
      })
    );
  }
};
开发者ID:elastic,项目名称:kibana,代码行数:19,代码来源:start_job.ts

示例8: _displayError

 public _displayError() {
   toastNotifications.addDanger({
     title: 'Unable to change your Space',
     text: 'please try again later',
   });
 }
开发者ID:salihkardan,项目名称:kibana,代码行数:6,代码来源:spaces_manager.ts


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