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


TypeScript wrappers.getDeep函數代碼示例

本文整理匯總了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,
  }
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:32,代碼來源:config.ts

示例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)))
  }
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:33,代碼來源:index.ts

示例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,
  }
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:30,代碼來源:config.ts

示例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
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:11,代碼來源:index.ts

示例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)
  }
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:9,代碼來源:index.ts

示例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)
  }
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:9,代碼來源:index.ts


注:本文中的src/utils/wrappers.getDeep函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。