Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): taskattempts orientated #1251

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const NodeRun: FC<Modal> = ({ data }) => {
const node = nodeRunsList[0]
const { showModal, setShowModal } = useModal()

const sortedNodeRunsList = nodeRunsList?.sort((a, b) => b.id!.position - a.id!.position)

return (
<Dialog open={showModal} onOpenChange={open => setShowModal(open)}>
<DialogContent className="flex max-w-5xl flex-col">
Expand All @@ -35,11 +37,11 @@ export const NodeRun: FC<Modal> = ({ data }) => {
<Accordion.Root
className="bg-mauve6 wfull rounded-md shadow-[0_2px_10px] shadow-black/5"
type="single"
defaultValue="item-1"
defaultValue={`item-${sortedNodeRunsList[0].id?.position}`}
collapsible
>
{nodeRunsList?.map(nodeRun => (
<AccordionItem key={`item-${node.id?.position}`} node={nodeRun} userTaskNode={userTaskNode} />
{sortedNodeRunsList?.map(nodeRun => (
<AccordionItem key={`item-${nodeRun.id?.position}`} node={nodeRun} userTaskNode={userTaskNode} />
))}
</Accordion.Root>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { formatJsonOrReturnOriginalValue, getVariableValue, utcToLocalDateTime }
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
import { getTaskRun } from '../../NodeTypes/Task/getTaskRun'
import { AccordionNode } from './AccordionContent'
import { OverflowText } from '@/app/(authenticated)/[tenantId]/components/OverflowText'
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '@/components/ui/accordion'

export const TaskDefDetail: FC<AccordionNode> = ({ nodeRun }) => {
const taskId = nodeRun.task?.taskRunId?.taskGuid
Expand Down Expand Up @@ -40,6 +42,8 @@ export const TaskDefDetail: FC<AccordionNode> = ({ nodeRun }) => {

if (!data) return

const lastLogOutput = data?.attempts[data?.attempts.length - 1]?.logOutput?.str

return (
<>
<div className="flex justify-between align-top">
Expand All @@ -57,6 +61,7 @@ export const TaskDefDetail: FC<AccordionNode> = ({ nodeRun }) => {
})}
</div>
)}

<div className="mb-2 mt-1 flex ">
<span className="font-bold">Task GUID :</span>
<span> {taskId}</span>
Expand All @@ -74,53 +79,69 @@ export const TaskDefDetail: FC<AccordionNode> = ({ nodeRun }) => {
<hr className="mt-6" />

<div className="flex min-h-[160px] flex-col gap-4">
<Table>
<TableHeader>
<TableRow className="bg-neutral-300 ">
<TableHead scope="col">
<strong>Attempt </strong>
</TableHead>
<TableHead scope="col">
<strong>Start Time</strong>
</TableHead>
<TableHead scope="col">
<strong>End Time</strong>
</TableHead>
<TableHead scope="col">
<strong>Status</strong>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data?.attempts.map((attempt, index) => {
return (
<Fragment key={attempt.taskWorkerId}>
<TableRow>
<TableCell className="p-1">{index + 1}</TableCell>
<TableCell className="p-1">{attempt.startTime && utcToLocalDateTime(attempt.startTime)}</TableCell>
<TableCell className="p-1">{attempt.endTime && utcToLocalDateTime(attempt.endTime)}</TableCell>
<TableCell className="p-1">
<Accordion type="single" defaultValue="item-1" collapsible>
{data?.attempts.map((attempt, index) => (
<Fragment key={attempt.taskWorkerId}>
<AccordionItem value={`item-${index + 1}`}>
<AccordionTrigger>
TaskAttempt {index + 1}
</AccordionTrigger>
<AccordionContent>
<Table>
<TableHeader>
<TableRow className="bg-neutral-300 ">
<TableHead scope="col">
<strong>Start Time</strong>
</TableHead>
<TableHead scope="col">
<strong>End Time</strong>
</TableHead>
<TableHead scope="col">
<strong>Status</strong>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell className="p-1">{attempt.startTime && utcToLocalDateTime(attempt.startTime)}</TableCell>
<TableCell className="p-1">{attempt.endTime && utcToLocalDateTime(attempt.endTime)}</TableCell>
<TableCell className="p-1">
<div
className={cn(
'flex items-center justify-between p-2',
attempt.exception || attempt.error ? 'bg-red-200' : 'bg-green-200'
)}
>
{attempt?.status}
</div>
</TableCell>
</TableRow>
</TableBody>
</Table>

<div className="flex gap-2 mb-3">
{nodeRun && (
<div
className={cn(
'flex items-center justify-between p-2',
attempt.exception || attempt.error ? 'bg-red-200' : 'bg-green-200'
)}
className={cn('mt-2 h-fit flex flex-col rounded bg-green-200 p-1', { 'bg-red-200': nodeRun.errorMessage })}
>
{attempt?.status}
<p className="text-md font-bold">{nodeRun.errorMessage ? 'TaskRun Error' : 'No TaskRun Error'}</p>
<OverflowText variant="error" className="w-36 text-nowrap" text={nodeRun.errorMessage ?? ''} />
</div>
</TableCell>
</TableRow>
)}
{nodeRun && (
<div className={'mt-2 flex h-fit flex-col rounded bg-gray-200 p-1'}>
<p className="text-md font-bold">{lastLogOutput ? 'Worker Log Output' : 'No Worker Log Output'}</p>
<OverflowText className="w-36 text-nowrap" text={lastLogOutput ?? ''} />
</div>
)}
</div>

<TableRow>
<TableCell colSpan={4} className="px-0">
<AttemptErrorExceptionOutput attempt={attempt} />
</TableCell>
</TableRow>
</Fragment>
)
})}
</TableBody>
</Table>
<AttemptErrorExceptionOutput attempt={attempt} />
</AccordionContent>
</AccordionItem>
</Fragment>
))}
</Accordion>
</div>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const NodeRunsList: FC<Prop> = ({ nodeRuns, taskNode, userTaskNode, nodeR
onClick={showNodeRuns}
>
<EyeIcon className="h-4 w-4" />
View NodeRuns
{nodeRuns.length > 1 ? 'View NodeRuns' : 'View NodeRun'}
</Button>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ export const TaskDetails: FC<{
</ol>
</div>
)}
{nodeRun && (
<div className={cn('mt-2 flex flex-col rounded bg-green-200 p-1', { 'bg-red-200': nodeRun.errorMessage })}>
<h3 className="font-bold">{nodeRun.errorMessage ? 'TaskRun Error' : 'No TaskRun Error'}</h3>
<OverflowText variant="error" className="w-36 text-nowrap" text={nodeRun.errorMessage ?? ''} />
</div>
)}
{nodeRun && (
<div className={'mt-2 flex flex-col rounded bg-gray-200 p-1'}>
<p className="text-xs font-bold">{lastLogOutput ? 'Worker Log Output' : 'No Worker Log Output'}</p>
<OverflowText className="w-36 text-nowrap" text={lastLogOutput ?? ''} />
</div>
)}
<NodeRunsList nodeRuns={nodeRunsList} />
</NodeDetails>
)
Expand Down
Loading