本文整理汇总了TypeScript中src/utils/wrappers.getDeep函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getDeep函数的具体用法?TypeScript getDeep怎么用?TypeScript getDeep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDeep函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateColumnConfig
export const serverToUIConfig = (logView: View | NewView): LogConfig => {
const logConfigID = getDeep<string>(logView, 'id', null)
const logsConfigLink = getDeep<string>(logView, 'links.self', null)
const logViewProperties = getDeep<LogViewerView>(logView, 'properties', null)
const columns = getDeep<LogViewerColumn[]>(logViewProperties, 'columns', [])
if (_.isEmpty(columns)) {
return
}
const sortedColumns = sortViewColumns(columns)
let severityFormat: SeverityFormatOptions
let severityLevelColors: SeverityLevelColor[]
const convertedColumns = sortedColumns.map(c => {
if (c.name === 'severity') {
severityFormat = generateColumnFormatConfig(c)
severityLevelColors = generateColumnColorsConfig(c)
}
return generateColumnConfig(c)
})
return {
id: logConfigID,
link: logsConfigLink,
isTruncated: DEFAULT_TRUNCATION,
tableColumns: convertedColumns,
severityFormat,
severityLevelColors,
}
}
示例2: async
export const importScript = (script: string, fileName: string) => async (
dispatch,
getState: GetStateFunc
): Promise<void> => {
try {
const validFileExtension = '.flux'
const fileExtensionRegex = new RegExp(`${validFileExtension}$`)
if (!fileName.match(fileExtensionRegex)) {
dispatch(notify(taskImportFailed(fileName, 'Please import a .flux file')))
return
}
if (_.isEmpty(script)) {
dispatch(notify(taskImportFailed(fileName, 'No Flux found in file')))
return
}
const {orgs} = await getState()
const orgID = getDeep<string>(orgs, '0.id', '') // TODO org selection by user.
await submitNewTask(orgID, script)
dispatch(populateTasks())
dispatch(notify(taskImportSuccess(fileName)))
} catch (error) {
console.error(error)
const message = getDeep<string>(error, 'message', '')
dispatch(notify(taskImportFailed(fileName, message)))
}
}
示例3: generateViewColumnSettings
export const generateViewProperties = (config: LogConfig): LogViewerView => {
const tableColumns = getDeep<LogsTableColumn[]>(config, 'tableColumns', [])
const severityFormat = getDeep<SeverityFormat>(config, 'severityFormat', null)
const severityLevelColors = getDeep<SeverityLevelColor[]>(
config,
'severityLevelColors',
[]
)
if (_.isEmpty(tableColumns)) {
return EMPTY_VIEW_PROPERTIES
}
const columns: LogViewerColumn[] = tableColumns.map((c, i) => {
const settings = generateViewColumnSettings(
c,
severityFormat,
severityLevelColors
)
const name = c.internalName
const position = i
return {name, position, settings}
})
return {
...EMPTY_VIEW_PROPERTIES,
columns,
}
}
示例4:
const getTableSelectedTime = (state: State): number => {
const custom = getDeep<string>(state, 'logs.tableTime.custom', '')
if (!_.isEmpty(custom)) {
return Date.parse(custom)
}
const relative = getDeep<number>(state, 'logs.tableTime.relative', 0)
return Date.now() - relative * 1000
}
示例5: async
export const getTelegrafConfigs = async (org: string): Promise<Telegraf[]> => {
try {
const data = await telegrafsAPI.telegrafsGet(org)
return getDeep<Telegraf[]>(data, 'data.configurations', [])
} catch (error) {
console.error(error)
}
}
示例6: async
export const getCollectors = async (org: Organization): Promise<Telegraf[]> => {
try {
const data = await telegrafsAPI.telegrafsGet(org.id)
return getDeep<Telegraf[]>(data, 'data.configurations', [])
} catch (error) {
console.error(error)
}
}