Commit 7b2499c2 authored by JzoNg's avatar JzoNg

add meta data of run log

parent 2be2bc58
...@@ -139,7 +139,7 @@ const Logs: FC<ILogsProps> = ({ appId }) => { ...@@ -139,7 +139,7 @@ const Logs: FC<ILogsProps> = ({ appId }) => {
onClose={onCloseDrawer} onClose={onCloseDrawer}
mask={false} mask={false}
footer={null} footer={null}
panelClassname='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[640px] rounded-xl border border-gray-200' panelClassname='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[600px] rounded-xl border border-gray-200'
> >
<DetailPanel onClose={onCloseDrawer} appDetail={appDetail} /> <DetailPanel onClose={onCloseDrawer} appDetail={appDetail} />
</Drawer> </Drawer>
......
...@@ -123,7 +123,7 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => { ...@@ -123,7 +123,7 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
onClose={onCloseDrawer} onClose={onCloseDrawer}
mask={isMobile} mask={isMobile}
footer={null} footer={null}
panelClassname='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[640px] rounded-xl border border-gray-200' panelClassname='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[600px] rounded-xl border border-gray-200'
> >
<DetailPanel onClose={onCloseDrawer} appDetail={appDetail} /> <DetailPanel onClose={onCloseDrawer} appDetail={appDetail} />
</Drawer> </Drawer>
......
...@@ -35,8 +35,8 @@ const RunPanel: FC<RunProps> = ({ activeTab, appId }) => { ...@@ -35,8 +35,8 @@ const RunPanel: FC<RunProps> = ({ activeTab, appId }) => {
>{t('runLog.tracing')}</div> >{t('runLog.tracing')}</div>
</div> </div>
{/* panel detal */} {/* panel detal */}
<div className={cn('grow bg-white overflow-y-auto', currentTab === 'TRACING' && '!bg-gray-50')}> <div className={cn('grow bg-white h-0 overflow-y-auto', currentTab === 'TRACING' && '!bg-gray-50')}>
{currentTab === 'RESULT' && <Result appId={appId}/>} {currentTab === 'RESULT' && <Result />}
{currentTab === 'TRACING' && <Tracing appId={appId}/>} {currentTab === 'TRACING' && <Tracing appId={appId}/>}
</div> </div>
</div> </div>
......
'use client'
import type { FC } from 'react'
import { useTranslation } from 'react-i18next'
// import cn from 'classnames'
import dayjs from 'dayjs'
type Props = {
status: 'running' | 'succeeded' | 'failed' | 'stopped'
executor?: string
startTime?: number
time?: number
tokens?: number
fee?: number
currency?: string
steps?: number
}
const MetaData: FC<Props> = ({
status,
executor,
startTime = 0,
time,
tokens,
fee = 0,
currency = 'USD',
steps = 1,
}) => {
const { t } = useTranslation()
return (
<div className='relative'>
<div className='h-6 leading-6 text-gray-500 text-xs font-medium'>{t('runLog.meta.title')}</div>
<div className='py-1'>
<div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.status')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
{status === 'running' && (
<div className='my-[5px] w-16 h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)}
{status === 'succeeded' && (
<span>SUCCESS</span>
)}
{status === 'failed' && (
<span>FAIL</span>
)}
{status === 'stopped' && (
<span>STOP</span>
)}
</div>
</div>
<div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.executor')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
{status === 'running' && (
<div className='my-[5px] w-[88px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)}
{status !== 'running' && (
<span>{executor}</span>
)}
</div>
</div>
<div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.startTime')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
{status === 'running' && (
<div className='my-[5px] w-[72px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)}
{status !== 'running' && (
<span>{dayjs(startTime * 1000).format('YYYY-MM-DD hh:mm:ss')}</span>
)}
</div>
</div>
<div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.time')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
{status === 'running' && (
<div className='my-[5px] w-[72px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)}
{status !== 'running' && (
<span>{`${time}s`}</span>
)}
</div>
</div>
<div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.tokens')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
{status === 'running' && (
<div className='my-[5px] w-[48px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)}
{status !== 'running' && (
<span>{`${tokens} Tokens · ${fee.toLocaleString('en-US', { style: 'currency', currency, minimumFractionDigits: 4 })}`}</span>
)}
</div>
</div>
<div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.steps')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
{status === 'running' && (
<div className='my-[5px] w-[24px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)}
{status !== 'running' && (
<span>{steps}</span>
)}
</div>
</div>
</div>
</div>
)
}
export default MetaData
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
// import React, { useState } from 'react' // import React, { useState } from 'react'
import { useTranslation } from 'react-i18next' // import { useTranslation } from 'react-i18next'
// import cn from 'classnames' // import cn from 'classnames'
import StatusPanel from './status' import StatusPanel from './status'
import MetaData from './meta'
// import Loading from '@/app/components/base/loading' // import Loading from '@/app/components/base/loading'
// import Indicator from '@/app/components/header/indicator'
type ResultProps = { type ResultProps = {
appId: string // appId: string
} }
const Result: FC<ResultProps> = ({ appId }) => { const Result: FC<ResultProps> = () => {
const { t } = useTranslation() // const { t } = useTranslation()
// const [currentTab, setCurrentTab] = useState<string>(activeTab) // const [currentTab, setCurrentTab] = useState<string>(activeTab)
return ( return (
<div className='bg-white py-2'> <div className='bg-white py-2'>
<div className='px-4 py-2'> <div className='px-4 py-2'>
<StatusPanel status='running' time={0.653} tokens={27} /> <StatusPanel status={'running'} time={0.653} tokens={27} />
</div> </div>
<div className='px-4 py-2'> <div className='px-4 py-2'>
<StatusPanel status='succeeded' time={0.653} tokens={27} /> <StatusPanel status={'succeeded'} time={0.653} tokens={27} />
</div> </div>
<div className='px-4 py-2'> <div className='px-4 py-2'>
<StatusPanel status='failed' time={0.653} tokens={27} /> <StatusPanel status={'failed'} time={0.653} tokens={27} error='Fail message here' />
</div> </div>
<div className='px-4 py-2'> <div className='px-4 py-2'>
<StatusPanel status='stopped' time={0.653} tokens={27} /> <StatusPanel status={'stopped'} time={0.653} tokens={27} />
</div> </div>
<div className='px-4 py-2 flex flex-col gap-2'> <div className='px-4 py-2 flex flex-col gap-2'>
<div>INPUT TODO</div> <div>INPUT TODO</div>
<div>OUPUT TODO</div> <div>OUPUT TODO</div>
</div> </div>
<div className='px-4 py-2'> <div className='px-4 py-2'>
<div className='h-[0.5px] bg-[rbga(0,0,0,0.05)]'/> <div className='h-[0.5px] bg-black opacity-5'/>
</div>
<div className='px-4 py-2'>
<MetaData status={'running'} />
</div>
<div className='px-4 py-2'>
<MetaData status={'succeeded'} executor={'Vince'} startTime={1702972783} time={0.653} tokens={27} fee={0.035} currency={'USD'} steps={7} />
</div> </div>
<div className='px-4 py-2'>META DATA TODO</div>
</div> </div>
) )
} }
......
...@@ -8,25 +8,28 @@ type ResultProps = { ...@@ -8,25 +8,28 @@ type ResultProps = {
status: 'running' | 'succeeded' | 'failed' | 'stopped' status: 'running' | 'succeeded' | 'failed' | 'stopped'
time?: number time?: number
tokens?: number tokens?: number
error?: string
} }
const StatusPanel: FC<ResultProps> = ({ const StatusPanel: FC<ResultProps> = ({
status, status,
time, time,
tokens, tokens,
error,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
return ( return (
<div <div
className={cn( className={cn(
'flex px-3 py-[10px] rounded-lg border-[0.5px] border-[rbga(0,0,0,0.05)] shadow-xs', 'px-3 py-[10px] rounded-lg border-[0.5px] border-[rbga(0,0,0,0.05)] shadow-xs',
status === 'running' && '!bg-primary-50', status === 'running' && '!bg-primary-50',
status === 'succeeded' && '!bg-[#ecfdf3]', status === 'succeeded' && '!bg-[#ecfdf3]',
status === 'failed' && '!bg-[#fef3f2]', status === 'failed' && '!bg-[#fef3f2]',
status === 'stopped' && '!bg-gray-200', status === 'stopped' && '!bg-gray-200',
)} )}
> >
<div className='flex'>
<div className='mr-24'> <div className='mr-24'>
<div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.status')}</div> <div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.status')}</div>
<div <div
...@@ -84,6 +87,13 @@ const StatusPanel: FC<ResultProps> = ({ ...@@ -84,6 +87,13 @@ const StatusPanel: FC<ResultProps> = ({
</div> </div>
</div> </div>
</div> </div>
{status === 'failed' && error && (
<>
<div className='my-2 h-[0.5px] bg-black opacity-5'/>
<div className='text-xs leading-[18px] text-[#d92d20]'>{error}</div>
</>
)}
</div>
) )
} }
......
...@@ -6,6 +6,16 @@ const translation = { ...@@ -6,6 +6,16 @@ const translation = {
time: 'ELAPSED TIME', time: 'ELAPSED TIME',
tokens: 'TOTAL TOKENS', tokens: 'TOTAL TOKENS',
}, },
meta: {
title: 'METADATA',
status: 'Status',
version: 'Version',
executor: 'Executor',
startTime: 'Start Time',
time: 'Elapsed Time',
tokens: 'Total Tokens',
steps: 'Run Steps',
},
} }
export default translation export default translation
...@@ -6,6 +6,16 @@ const translation = { ...@@ -6,6 +6,16 @@ const translation = {
time: '运行时间', time: '运行时间',
tokens: '总 token 数', tokens: '总 token 数',
}, },
meta: {
title: '元数据',
status: '状态',
version: '版本',
executor: '执行人',
startTime: '开始时间',
time: '运行时间',
tokens: '总 token 数',
steps: '运行步数',
},
} }
export default translation export default translation
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment