chore: add iteration running status

This commit is contained in:
Nov1c444 2024-11-08 13:45:56 +08:00
parent 8ef66bc460
commit e31fcbef2f
2 changed files with 31 additions and 18 deletions

View File

@ -193,7 +193,7 @@ const BaseNode: FC<BaseNodeProps> = ({
{
data._iterationLength && data._iterationIndex && data._runningStatus === NodeRunningStatus.Running && (
<div className='mr-1.5 text-xs font-medium text-primary-600'>
{data._iterationIndex}/{data._iterationLength}
{data._iterationIndex > data._iterationLength ? data._iterationLength : data._iterationIndex}/{data._iterationLength}
</div>
)
}

View File

@ -6,8 +6,10 @@ import {
RiArrowRightSLine,
RiCloseLine,
RiErrorWarningLine,
RiLoader2Line,
} from '@remixicon/react'
import { ArrowNarrowLeft } from '../../base/icons/src/vender/line/arrows'
import { NodeRunningStatus } from '../types'
import TracingPanel from './tracing-panel'
import { Iteration } from '@/app/components/base/icons/src/vender/workflow'
import cn from '@/utils/classnames'
@ -45,6 +47,33 @@ const IterationResultPanel: FC<Props> = ({
const duration = iterItem
return `${(duration && duration > 0.1) ? duration.toFixed(2) : 0.1}s`
}
const iterationStatusShow = (index: number, iteration: NodeTracing[], iterDurationMap?: IterationDurationMap) => {
const hasFailed = iteration.some(item => item.status === NodeRunningStatus.Failed)
const isRunning = iteration.some(item => item.status === NodeRunningStatus.Running)
const hasDurationMap = iterDurationMap && Object.keys(iterDurationMap).length !== 0
if (hasFailed)
return <RiErrorWarningLine className='w-4 h-4 text-text-destructive' />
if (isRunning)
return <RiLoader2Line className='w-3.5 h-3.5 text-primary-600 animate-spin' />
return (
<>
{hasDurationMap && (
<div className='system-xs-regular text-text-tertiary'>
{countIterDuration(iteration, iterDurationMap)}
</div>
)}
<RiArrowRightSLine
className={cn(
'w-4 h-4 text-text-tertiary transition-transform duration-200 flex-shrink-0',
expandedIterations[index] && 'transform rotate-90',
)}
/>
</>
)
}
const main = (
<>
@ -81,23 +110,7 @@ const IterationResultPanel: FC<Props> = ({
<span className='system-sm-semibold-uppercase text-text-primary flex-grow'>
{t(`${i18nPrefix}.iteration`)} {index + 1}
</span>
{
iteration.some(item => item.status === 'failed')
? (
<RiErrorWarningLine className='w-4 h-4 text-text-destructive' />
)
: (
<>
{ (iterDurationMap && Object.keys(iterDurationMap).length !== 0) && <div className='system-xs-regular text-text-tertiary'>{countIterDuration(iteration, iterDurationMap)}</div>}
< RiArrowRightSLine className={
cn(
'w-4 h-4 text-text-tertiary transition-transform duration-200 flex-shrink-0',
expandedIterations[index] && 'transform rotate-90',
)} />
</>
)
}
{iterationStatusShow(index, iteration, iterDurationMap)}
</div>
</div>
{expandedIterations[index] && <div