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


TypeScript notify.toastNotifications類代碼示例

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


在下文中一共展示了toastNotifications類的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: 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

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

示例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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。