本文整理匯總了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,
});
}
}
示例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) },
})
);
}
}
};
示例3:
.catch(resp => {
toastNotifications.addDanger(
i18n.translate('xpack.ml.fullTimeRangeSelector.errorSettingTimeRangeNotification', {
defaultMessage: 'An error occurred setting the time range.',
})
);
});
示例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;
}
}
}
示例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',
}),
});
}
示例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) },
})
);
}
};
示例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,
});
}
}
示例8: _displayError
public _displayError() {
toastNotifications.addDanger({
title: 'Unable to change your Space',
text: 'please try again later',
});
}