feat(ui): improve workflow runs history

This commit is contained in:
Fu Diwei 2025-01-19 06:15:38 +08:00
parent 5b613bcf84
commit c0dc9b1882
3 changed files with 16 additions and 8 deletions

View File

@ -42,12 +42,12 @@ const WorkflowRunDetailDrawer = ({ data, loading, trigger, ...props }: WorkflowR
<div className="mt-4 rounded-md bg-black p-4 text-stone-200"> <div className="mt-4 rounded-md bg-black p-4 text-stone-200">
<div className="flex flex-col space-y-3"> <div className="flex flex-col space-y-3">
{data!.logs.map((item, i) => { {data!.logs?.map((item, i) => {
return ( return (
<div key={i} className="flex flex-col space-y-2"> <div key={i} className="flex flex-col space-y-2">
<div>{item.nodeName}</div> <div>{item.nodeName}</div>
<div className="flex flex-col space-y-1"> <div className="flex flex-col space-y-1">
{item.outputs.map((output, j) => { {item.outputs?.map((output, j) => {
return ( return (
<div key={j} className="flex space-x-2 text-sm" style={{ wordBreak: "break-word" }}> <div key={j} className="flex space-x-2 text-sm" style={{ wordBreak: "break-word" }}>
<div className="whitespace-nowrap">[{dayjs(output.time).format("YYYY-MM-DD HH:mm:ss")}]</div> <div className="whitespace-nowrap">[{dayjs(output.time).format("YYYY-MM-DD HH:mm:ss")}]</div>

View File

@ -6,8 +6,8 @@ export interface WorkflowRunModel extends BaseModel {
trigger: string; trigger: string;
startedAt: ISO8601String; startedAt: ISO8601String;
endedAt: ISO8601String; endedAt: ISO8601String;
logs: WorkflowRunLog[]; logs?: WorkflowRunLog[];
error: string; error?: string;
expand?: { expand?: {
workflowId?: WorkflowModel; workflowId?: WorkflowModel;
}; };
@ -16,15 +16,15 @@ export interface WorkflowRunModel extends BaseModel {
export type WorkflowRunLog = { export type WorkflowRunLog = {
nodeId: string; nodeId: string;
nodeName: string; nodeName: string;
outputs: WorkflowRunLogOutput[]; outputs?: WorkflowRunLogOutput[];
error: string; error?: string;
}; };
export type WorkflowRunLogOutput = { export type WorkflowRunLogOutput = {
time: ISO8601String; time: ISO8601String;
title: string; title: string;
content: string; content: string;
error: string; error?: string;
}; };
export const WORKFLOW_RUN_STATUSES = Object.freeze({ export const WORKFLOW_RUN_STATUSES = Object.freeze({

View File

@ -7,6 +7,7 @@ import {
DeleteOutlined as DeleteOutlinedIcon, DeleteOutlined as DeleteOutlinedIcon,
EditOutlined as EditOutlinedIcon, EditOutlined as EditOutlinedIcon,
PlusOutlined as PlusOutlinedIcon, PlusOutlined as PlusOutlinedIcon,
SyncOutlined as SyncOutlinedIcon,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { PageHeader } from "@ant-design/pro-components"; import { PageHeader } from "@ant-design/pro-components";
@ -159,7 +160,14 @@ const WorkflowList = () => {
title: t("workflow.props.last_run_at"), title: t("workflow.props.last_run_at"),
render: (_, record) => { render: (_, record) => {
if (record.lastRunId) { if (record.lastRunId) {
if (record.lastRunStatus === WORKFLOW_RUN_STATUSES.SUCCEEDED) { if (record.lastRunStatus === WORKFLOW_RUN_STATUSES.RUNNING) {
return (
<Space>
<Badge status="processing" count={<SyncOutlinedIcon style={{ color: themeToken.colorInfo }} />} />
<Typography.Text>{dayjs(record.lastRunTime!).format("YYYY-MM-DD HH:mm:ss")}</Typography.Text>
</Space>
);
} else if (record.lastRunStatus === WORKFLOW_RUN_STATUSES.SUCCEEDED) {
return ( return (
<Space> <Space>
<Badge status="success" count={<CheckCircleOutlinedIcon style={{ color: themeToken.colorSuccess }} />} /> <Badge status="success" count={<CheckCircleOutlinedIcon style={{ color: themeToken.colorSuccess }} />} />