本文整理汇总了TypeScript中@elastic/datemath.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: setLoading
(async () => {
setLoading(true);
try {
const from = DateMath.parse(timerange.from);
const to = DateMath.parse(timerange.to, { roundUp: true });
if (!from || !to) {
throw new Error('Unalble to parse timerange');
}
const response = await fetch.post<MetricsExplorerResponse>(
'../api/infra/metrics_explorer',
{
metrics:
options.aggregation === MetricsExplorerAggregation.count
? [{ aggregation: MetricsExplorerAggregation.count }]
: options.metrics.map(metric => ({
aggregation: metric.aggregation,
field: metric.field,
})),
groupBy: options.groupBy,
afterKey,
limit: options.limit,
indexPattern: source.metricAlias,
filterQuery:
(options.filterQuery &&
convertKueryToElasticSearchQuery(options.filterQuery, derivedIndexPattern)) ||
void 0,
timerange: {
...timerange,
field: source.fields.timestamp,
from: from.valueOf(),
to: to.valueOf(),
},
}
);
if (response.data) {
if (
data &&
lastOptions &&
data.pageInfo.afterKey !== response.data.pageInfo.afterKey &&
isSameOptions(lastOptions, options) &&
isEqual(timerange, lastTimerange) &&
afterKey
) {
const { series } = data;
setData({
...response.data,
series: [...series, ...response.data.series],
});
} else {
setData(response.data);
}
setLastOptions(options);
setLastTimerange(timerange);
setError(null);
}
} catch (e) {
setError(e);
}
setLoading(false);
})();
开发者ID:elastic,项目名称:kibana,代码行数:60,代码来源:use_metrics_explorer_data.ts
示例2: Error
export const getHistogramInterval = (
dateRangeStart: string,
dateRangeEnd: string,
bucketCount?: number
): string => {
const from = DateMath.parse(dateRangeStart);
const to = DateMath.parse(dateRangeEnd);
if (from === undefined) {
throw Error('Invalid dateRangeStart value');
}
if (to === undefined) {
throw Error('Invalid dateRangeEnd value');
}
return `${Math.round(
(to.valueOf() - from.valueOf()) / (bucketCount || QUERY.DEFAULT_BUCKET_COUNT)
)}ms`;
};
开发者ID:,项目名称:,代码行数:17,代码来源:
示例3: getParsedDate
function getParsedDate(rawDate?: string, opts = {}) {
if (rawDate) {
const parsed = datemath.parse(rawDate, opts);
if (parsed) {
return parsed.toISOString();
}
}
}
开发者ID:njd5475,项目名称:kibana,代码行数:8,代码来源:urlParams.ts
示例4: parseAndValidate
function parseAndValidate(str: string): string {
const moment = dateMath.parse(str);
if (!moment || !moment.isValid()) {
throw new Error(`Invalid date/time string: '${str}'`);
}
return moment.toISOString();
}
开发者ID:elastic,项目名称:kibana,代码行数:9,代码来源:timefilter.ts
示例5: validateParams
export function validateParams(params: any, type: string) {
switch (type) {
case 'date':
const moment = typeof params === 'string' ? dateMath.parse(params) : null;
return Boolean(typeof params === 'string' && moment && moment.isValid());
case 'ip':
try {
return Boolean(new Ipv4Address(params));
} catch (e) {
return false;
}
default:
return true;
}
}
开发者ID:elastic,项目名称:kibana,代码行数:15,代码来源:filter_editor_utils.ts
示例6: calculateBounds
export function calculateBounds(timeRange: TimeRange, options: CalculateBoundsOptions = {}) {
return {
min: dateMath.parse(timeRange.from, { forceNow: options.forceNow }),
max: dateMath.parse(timeRange.to, { roundUp: true, forceNow: options.forceNow }),
};
}
开发者ID:elastic,项目名称:kibana,代码行数:6,代码来源:get_time.ts
示例7:
import {
deleteAllQuery,
setAbsoluteRangeDatePicker,
setDuration,
setQuery,
setRelativeRangeDatePicker,
startAutoReload,
stopAutoReload,
toggleTimelineLinkTo,
setTimelineRangeDatePicker,
} from './actions';
import { toggleLockTimeline, updateInputTimerange } from './helpers';
import { InputsModel, TimeRange } from './model';
export type InputsState = InputsModel;
const momentDate = dateMath.parse('now-24h');
export const initialInputsState: InputsState = {
global: {
timerange: {
kind: 'relative',
fromStr: 'now-24h',
toStr: 'now',
from: momentDate ? momentDate.valueOf() : 0,
to: Date.now(),
},
query: [],
policy: {
kind: 'manual',
duration: 300000,
},
linkTo: ['timeline'],
开发者ID:,项目名称:,代码行数:31,代码来源:
注:本文中的@elastic/datemath.parse函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论