meta.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. 'use client'
  2. import type { FC } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import useTimestamp from '@/hooks/use-timestamp'
  5. type Props = {
  6. status: string
  7. executor?: string
  8. startTime?: number
  9. time?: number
  10. tokens?: number
  11. steps?: number
  12. showSteps?: boolean
  13. }
  14. const MetaData: FC<Props> = ({
  15. status,
  16. executor,
  17. startTime,
  18. time,
  19. tokens,
  20. steps = 1,
  21. showSteps = true,
  22. }) => {
  23. const { t } = useTranslation()
  24. const { formatTime } = useTimestamp()
  25. return (
  26. <div className='relative'>
  27. <div className='h-6 py-1 text-text-tertiary system-xs-medium-uppercase'>{t('runLog.meta.title')}</div>
  28. <div className='py-1'>
  29. <div className='flex'>
  30. <div className='shrink-0 w-[104px] px-2 py-1.5 text-text-tertiary system-xs-regular truncate'>{t('runLog.meta.status')}</div>
  31. <div className='grow px-2 py-1.5 text-text-secondary system-xs-regular'>
  32. {status === 'running' && (
  33. <div className='my-1 w-16 h-2 rounded-sm bg-text-quaternary'/>
  34. )}
  35. {status === 'succeeded' && (
  36. <span>SUCCESS</span>
  37. )}
  38. {status === 'failed' && (
  39. <span>FAIL</span>
  40. )}
  41. {status === 'stopped' && (
  42. <span>STOP</span>
  43. )}
  44. </div>
  45. </div>
  46. <div className='flex'>
  47. <div className='shrink-0 w-[104px] px-2 py-1.5 text-text-tertiary system-xs-regular truncate'>{t('runLog.meta.executor')}</div>
  48. <div className='grow px-2 py-1.5 text-text-secondary system-xs-regular'>
  49. {status === 'running' && (
  50. <div className='my-1 w-[88px] h-2 rounded-sm bg-text-quaternary'/>
  51. )}
  52. {status !== 'running' && (
  53. <span>{executor || 'N/A'}</span>
  54. )}
  55. </div>
  56. </div>
  57. <div className='flex'>
  58. <div className='shrink-0 w-[104px] px-2 py-1.5 text-text-tertiary system-xs-regular truncate'>{t('runLog.meta.startTime')}</div>
  59. <div className='grow px-2 py-1.5 text-text-secondary system-xs-regular'>
  60. {status === 'running' && (
  61. <div className='my-1 w-[72px] h-2 rounded-sm bg-text-quaternary'/>
  62. )}
  63. {status !== 'running' && (
  64. <span>{startTime ? formatTime(startTime, t('appLog.dateTimeFormat') as string) : '-'}</span>
  65. )}
  66. </div>
  67. </div>
  68. <div className='flex'>
  69. <div className='shrink-0 w-[104px] px-2 py-1.5 text-text-tertiary system-xs-regular truncate'>{t('runLog.meta.time')}</div>
  70. <div className='grow px-2 py-1.5 text-text-secondary system-xs-regular'>
  71. {status === 'running' && (
  72. <div className='my-1 w-[72px] h-2 rounded-sm bg-text-quaternary'/>
  73. )}
  74. {status !== 'running' && (
  75. <span>{time ? `${time.toFixed(3)}s` : '-'}</span>
  76. )}
  77. </div>
  78. </div>
  79. <div className='flex'>
  80. <div className='shrink-0 w-[104px] px-2 py-1.5 text-text-tertiary system-xs-regular truncate'>{t('runLog.meta.tokens')}</div>
  81. <div className='grow px-2 py-1.5 text-text-secondary system-xs-regular'>
  82. {status === 'running' && (
  83. <div className='my-1 w-[48px] h-2 rounded-sm bg-text-quaternary'/>
  84. )}
  85. {status !== 'running' && (
  86. <span>{`${tokens || 0} Tokens`}</span>
  87. )}
  88. </div>
  89. </div>
  90. {showSteps && (
  91. <div className='flex'>
  92. <div className='shrink-0 w-[104px] px-2 py-1.5 text-text-tertiary system-xs-regular truncate'>{t('runLog.meta.steps')}</div>
  93. <div className='grow px-2 py-1.5 text-text-secondary system-xs-regular'>
  94. {status === 'running' && (
  95. <div className='my-1 w-[24px] h-2 rounded-sm bg-text-quaternary'/>
  96. )}
  97. {status !== 'running' && (
  98. <span>{steps}</span>
  99. )}
  100. </div>
  101. </div>
  102. )}
  103. </div>
  104. </div>
  105. )
  106. }
  107. export default MetaData