mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
feat(ui): enhance workflow logs display
This commit is contained in:
parent
fd6e41c566
commit
882f802585
@ -8,8 +8,9 @@ type WorkflowLog struct {
|
|||||||
Meta
|
Meta
|
||||||
WorkflowId string `json:"workflowId" db:"workflowId"`
|
WorkflowId string `json:"workflowId" db:"workflowId"`
|
||||||
RunId string `json:"workflorunIdwId" db:"runId"`
|
RunId string `json:"workflorunIdwId" db:"runId"`
|
||||||
NodeId string `json:"nodeId"`
|
NodeId string `json:"nodeId" db:"nodeId"`
|
||||||
NodeName string `json:"nodeName"`
|
NodeName string `json:"nodeName" db:"nodeName"`
|
||||||
|
Timestamp int64 `json:"timestamp" db:"timestamp"` // 毫秒级时间戳
|
||||||
Level string `json:"level" db:"level"`
|
Level string `json:"level" db:"level"`
|
||||||
Message string `json:"message" db:"message"`
|
Message string `json:"message" db:"message"`
|
||||||
Data map[string]any `json:"data" db:"data"`
|
Data map[string]any `json:"data" db:"data"`
|
||||||
|
@ -90,14 +90,6 @@ func (d *DeployerProvider) WithLogger(logger *slog.Logger) deployer.Deployer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DeployerProvider) Deploy(ctx context.Context, certPem string, privkeyPem string) (*deployer.DeployResult, error) {
|
func (d *DeployerProvider) Deploy(ctx context.Context, certPem string, privkeyPem string) (*deployer.DeployResult, error) {
|
||||||
// 上传证书到 SCM
|
|
||||||
upres, err := d.sslUploader.Upload(ctx, certPem, privkeyPem)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Wrap(err, "failed to upload certificate file")
|
|
||||||
} else {
|
|
||||||
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据部署资源类型决定部署方式
|
// 根据部署资源类型决定部署方式
|
||||||
switch d.config.ResourceType {
|
switch d.config.ResourceType {
|
||||||
case RESOURCE_TYPE_CERTIFICATE:
|
case RESOURCE_TYPE_CERTIFICATE:
|
||||||
|
@ -22,7 +22,7 @@ func (r *WorkflowLogRepository) ListByWorkflowRunId(ctx context.Context, workflo
|
|||||||
records, err := app.GetApp().FindRecordsByFilter(
|
records, err := app.GetApp().FindRecordsByFilter(
|
||||||
domain.CollectionNameWorkflowLog,
|
domain.CollectionNameWorkflowLog,
|
||||||
"runId={:runId}",
|
"runId={:runId}",
|
||||||
"-created",
|
"timestamp",
|
||||||
0, 0,
|
0, 0,
|
||||||
dbx.Params{"runId": workflowRunId},
|
dbx.Params{"runId": workflowRunId},
|
||||||
)
|
)
|
||||||
@ -66,6 +66,7 @@ func (r *WorkflowLogRepository) Save(ctx context.Context, workflowLog *domain.Wo
|
|||||||
record.Set("runId", workflowLog.RunId)
|
record.Set("runId", workflowLog.RunId)
|
||||||
record.Set("nodeId", workflowLog.NodeId)
|
record.Set("nodeId", workflowLog.NodeId)
|
||||||
record.Set("nodeName", workflowLog.NodeName)
|
record.Set("nodeName", workflowLog.NodeName)
|
||||||
|
record.Set("timestamp", workflowLog.Timestamp)
|
||||||
record.Set("level", workflowLog.Level)
|
record.Set("level", workflowLog.Level)
|
||||||
record.Set("message", workflowLog.Message)
|
record.Set("message", workflowLog.Message)
|
||||||
record.Set("data", workflowLog.Data)
|
record.Set("data", workflowLog.Data)
|
||||||
@ -102,6 +103,7 @@ func (r *WorkflowLogRepository) castRecordToModel(record *core.Record) (*domain.
|
|||||||
RunId: record.GetString("runId"),
|
RunId: record.GetString("runId"),
|
||||||
NodeId: record.GetString("nodeId"),
|
NodeId: record.GetString("nodeId"),
|
||||||
NodeName: record.GetString("nodeName"),
|
NodeName: record.GetString("nodeName"),
|
||||||
|
Timestamp: int64(record.GetInt("timestamp")),
|
||||||
Level: record.GetString("level"),
|
Level: record.GetString("level"),
|
||||||
Message: record.GetString("message"),
|
Message: record.GetString("message"),
|
||||||
Data: logdata,
|
Data: logdata,
|
||||||
|
@ -80,6 +80,7 @@ func (w *workflowInvoker) processNode(ctx context.Context, node *domain.Workflow
|
|||||||
log.RunId = w.runId
|
log.RunId = w.runId
|
||||||
log.NodeId = current.Id
|
log.NodeId = current.Id
|
||||||
log.NodeName = current.Name
|
log.NodeName = current.Name
|
||||||
|
log.Timestamp = record.Time.UnixMilli()
|
||||||
log.Level = record.Level.String()
|
log.Level = record.Level.String()
|
||||||
log.Message = record.Message
|
log.Message = record.Message
|
||||||
log.Data = record.Data
|
log.Data = record.Data
|
||||||
|
@ -42,7 +42,7 @@ func (n *applyNode) Process(ctx context.Context) error {
|
|||||||
|
|
||||||
// 检测是否可以跳过本次执行
|
// 检测是否可以跳过本次执行
|
||||||
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
||||||
n.logger.Warn(fmt.Sprintf("skip this application, because %s", skipReason))
|
n.logger.Info(fmt.Sprintf("skip this application, because %s", skipReason))
|
||||||
return nil
|
return nil
|
||||||
} else if skipReason != "" {
|
} else if skipReason != "" {
|
||||||
n.logger.Info(fmt.Sprintf("continue to apply, because %s", skipReason))
|
n.logger.Info(fmt.Sprintf("continue to apply, because %s", skipReason))
|
||||||
@ -124,7 +124,7 @@ func (n *applyNode) checkCanSkip(ctx context.Context, lastOutput *domain.Workflo
|
|||||||
renewalInterval := time.Duration(currentNodeConfig.SkipBeforeExpiryDays) * time.Hour * 24
|
renewalInterval := time.Duration(currentNodeConfig.SkipBeforeExpiryDays) * time.Hour * 24
|
||||||
expirationTime := time.Until(lastCertificate.ExpireAt)
|
expirationTime := time.Until(lastCertificate.ExpireAt)
|
||||||
if expirationTime > renewalInterval {
|
if expirationTime > renewalInterval {
|
||||||
return true, fmt.Sprintf("the certificate has already been issued (expires in %dD, next renewal in %dD)", int(expirationTime.Hours()/24), currentNodeConfig.SkipBeforeExpiryDays)
|
return true, fmt.Sprintf("the certificate has already been issued (expires in %dd, next renewal in %dd)", int(expirationTime.Hours()/24), currentNodeConfig.SkipBeforeExpiryDays)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (n *deployNode) Process(ctx context.Context) error {
|
|||||||
// 检测是否可以跳过本次执行
|
// 检测是否可以跳过本次执行
|
||||||
if lastOutput != nil && certificate.CreatedAt.Before(lastOutput.UpdatedAt) {
|
if lastOutput != nil && certificate.CreatedAt.Before(lastOutput.UpdatedAt) {
|
||||||
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
||||||
n.logger.Warn(fmt.Sprintf("skip this deployment, because %s", skipReason))
|
n.logger.Info(fmt.Sprintf("skip this deployment, because %s", skipReason))
|
||||||
return nil
|
return nil
|
||||||
} else if skipReason != "" {
|
} else if skipReason != "" {
|
||||||
n.logger.Info(fmt.Sprintf("continue to deploy, because %s", skipReason))
|
n.logger.Info(fmt.Sprintf("continue to deploy, because %s", skipReason))
|
||||||
|
@ -40,7 +40,7 @@ func (n *uploadNode) Process(ctx context.Context) error {
|
|||||||
|
|
||||||
// 检测是否可以跳过本次执行
|
// 检测是否可以跳过本次执行
|
||||||
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
||||||
n.logger.Warn(fmt.Sprintf("skip this upload, because %s", skipReason))
|
n.logger.Info(fmt.Sprintf("skip this upload, because %s", skipReason))
|
||||||
return nil
|
return nil
|
||||||
} else if skipReason != "" {
|
} else if skipReason != "" {
|
||||||
n.logger.Info(fmt.Sprintf("continue to upload, because %s", skipReason))
|
n.logger.Info(fmt.Sprintf("continue to upload, because %s", skipReason))
|
||||||
|
@ -3,6 +3,7 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pocketbase/pocketbase/core"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
@ -86,6 +87,18 @@ func init() {
|
|||||||
"system": false,
|
"system": false,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "number2782324286",
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"name": "timestamp",
|
||||||
|
"onlyInt": false,
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"autogeneratePattern": "",
|
"autogeneratePattern": "",
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
@ -192,13 +205,15 @@ func init() {
|
|||||||
for _, log := range logs {
|
for _, log := range logs {
|
||||||
for _, logRecord := range log.Records {
|
for _, logRecord := range log.Records {
|
||||||
record := core.NewRecord(collection)
|
record := core.NewRecord(collection)
|
||||||
|
createdAt, _ := time.Parse(time.RFC3339, logRecord.Time)
|
||||||
record.Set("workflowId", workflowRun.Get("workflowId"))
|
record.Set("workflowId", workflowRun.Get("workflowId"))
|
||||||
record.Set("runId", workflowRun.Get("id"))
|
record.Set("runId", workflowRun.Get("id"))
|
||||||
record.Set("nodeId", log.NodeId)
|
record.Set("nodeId", log.NodeId)
|
||||||
record.Set("nodeName", log.NodeName)
|
record.Set("nodeName", log.NodeName)
|
||||||
|
record.Set("timestamp", createdAt.UnixMilli())
|
||||||
record.Set("level", logRecord.Level)
|
record.Set("level", logRecord.Level)
|
||||||
record.Set("message", strings.TrimSpace(logRecord.Content+" "+logRecord.Error))
|
record.Set("message", strings.TrimSpace(logRecord.Content+" "+logRecord.Error))
|
||||||
record.Set("created", log.Records)
|
record.Set("created", createdAt)
|
||||||
if err := app.Save(record); err != nil {
|
if err := app.Save(record); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,34 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { RightOutlined as RightOutlinedIcon, SelectOutlined as SelectOutlinedIcon } from "@ant-design/icons";
|
import {
|
||||||
|
CheckCircleOutlined as CheckCircleOutlinedIcon,
|
||||||
|
CheckOutlined as CheckOutlinedIcon,
|
||||||
|
ClockCircleOutlined as ClockCircleOutlinedIcon,
|
||||||
|
CloseCircleOutlined as CloseCircleOutlinedIcon,
|
||||||
|
RightOutlined as RightOutlinedIcon,
|
||||||
|
SelectOutlined as SelectOutlinedIcon,
|
||||||
|
SettingOutlined as SettingOutlinedIcon,
|
||||||
|
StopOutlined as StopOutlinedIcon,
|
||||||
|
SyncOutlined as SyncOutlinedIcon,
|
||||||
|
} from "@ant-design/icons";
|
||||||
import { useRequest } from "ahooks";
|
import { useRequest } from "ahooks";
|
||||||
import { Alert, Button, Collapse, Divider, Empty, Skeleton, Space, Spin, Table, type TableProps, Tooltip, Typography, notification } from "antd";
|
import {
|
||||||
|
Button,
|
||||||
|
Collapse,
|
||||||
|
Divider,
|
||||||
|
Dropdown,
|
||||||
|
Empty,
|
||||||
|
Flex,
|
||||||
|
Skeleton,
|
||||||
|
Space,
|
||||||
|
Spin,
|
||||||
|
Table,
|
||||||
|
type TableProps,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
notification,
|
||||||
|
theme,
|
||||||
|
} from "antd";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { ClientResponseError } from "pocketbase";
|
import { ClientResponseError } from "pocketbase";
|
||||||
|
|
||||||
@ -23,25 +49,14 @@ export type WorkflowRunDetailProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const WorkflowRunDetail = ({ data, ...props }: WorkflowRunDetailProps) => {
|
const WorkflowRunDetail = ({ data, ...props }: WorkflowRunDetailProps) => {
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...props}>
|
<div {...props}>
|
||||||
<Show when={data.status === WORKFLOW_RUN_STATUSES.SUCCEEDED}>
|
<Show when={!!data}>
|
||||||
<Alert showIcon type="success" message={<Typography.Text type="success">{t("workflow_run.props.status.succeeded")}</Typography.Text>} />
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<Show when={data.status === WORKFLOW_RUN_STATUSES.FAILED}>
|
|
||||||
<Alert showIcon type="error" message={<Typography.Text type="danger">{t("workflow_run.props.status.failed")}</Typography.Text>} />
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<div className="my-4">
|
|
||||||
<WorkflowRunLogs runId={data.id} runStatus={data.status} />
|
<WorkflowRunLogs runId={data.id} runStatus={data.status} />
|
||||||
</div>
|
</Show>
|
||||||
|
|
||||||
<Show when={data.status === WORKFLOW_RUN_STATUSES.SUCCEEDED}>
|
<Show when={!!data && data.status === WORKFLOW_RUN_STATUSES.SUCCEEDED}>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
<WorkflowRunArtifacts runId={data.id} />
|
<WorkflowRunArtifacts runId={data.id} />
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
@ -51,9 +66,10 @@ const WorkflowRunDetail = ({ data, ...props }: WorkflowRunDetailProps) => {
|
|||||||
const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: string }) => {
|
const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: string }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
type Log = Pick<WorkflowLogModel, "level" | "message" | "data" | "created">;
|
const { token: themeToken } = theme.useToken();
|
||||||
type LogGroup = { id: string; name: string; records: Log[] };
|
|
||||||
|
|
||||||
|
type Log = Pick<WorkflowLogModel, "timestamp" | "level" | "message" | "data">;
|
||||||
|
type LogGroup = { id: string; name: string; records: Log[] };
|
||||||
const [listData, setListData] = useState<LogGroup[]>([]);
|
const [listData, setListData] = useState<LogGroup[]>([]);
|
||||||
const { loading } = useRequest(
|
const { loading } = useRequest(
|
||||||
() => {
|
() => {
|
||||||
@ -61,13 +77,12 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
refreshDeps: [runId, runStatus],
|
refreshDeps: [runId, runStatus],
|
||||||
pollingInterval: runStatus === WORKFLOW_RUN_STATUSES.PENDING || runStatus === WORKFLOW_RUN_STATUSES.RUNNING ? 5000 : 0,
|
pollingInterval: runStatus === WORKFLOW_RUN_STATUSES.PENDING || runStatus === WORKFLOW_RUN_STATUSES.RUNNING ? 3000 : 0,
|
||||||
pollingWhenHidden: false,
|
pollingWhenHidden: false,
|
||||||
throttleWait: 500,
|
throttleWait: 500,
|
||||||
onBefore: () => {
|
|
||||||
setListData([]);
|
|
||||||
},
|
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
|
if (res.items.length === listData.flatMap((e) => e.records).length) return;
|
||||||
|
|
||||||
setListData(
|
setListData(
|
||||||
res.items.reduce((acc, e) => {
|
res.items.reduce((acc, e) => {
|
||||||
let group = acc.at(-1);
|
let group = acc.at(-1);
|
||||||
@ -75,7 +90,7 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
group = { id: e.nodeId, name: e.nodeName, records: [] };
|
group = { id: e.nodeId, name: e.nodeName, records: [] };
|
||||||
acc.push(group);
|
acc.push(group);
|
||||||
}
|
}
|
||||||
group.records.push({ level: e.level, message: e.message, data: e.data, created: e.created });
|
group.records.push({ timestamp: e.timestamp, level: e.level, message: e.message, data: e.data });
|
||||||
return acc;
|
return acc;
|
||||||
}, [] as LogGroup[])
|
}, [] as LogGroup[])
|
||||||
);
|
);
|
||||||
@ -92,7 +107,52 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderLogRecord = (record: Log) => {
|
const [showTimestamp, setShowTimestamp] = useState(true);
|
||||||
|
const [showWhitespace, setShowWhitespace] = useState(true);
|
||||||
|
|
||||||
|
const renderBadge = () => {
|
||||||
|
switch (runStatus) {
|
||||||
|
case WORKFLOW_RUN_STATUSES.PENDING:
|
||||||
|
return (
|
||||||
|
<Flex gap="small">
|
||||||
|
<ClockCircleOutlinedIcon />
|
||||||
|
{t("workflow_run.props.status.pending")}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
case WORKFLOW_RUN_STATUSES.RUNNING:
|
||||||
|
return (
|
||||||
|
<Flex gap="small" style={{ color: themeToken.colorInfo }}>
|
||||||
|
<SyncOutlinedIcon spin />
|
||||||
|
{t("workflow_run.props.status.running")}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
case WORKFLOW_RUN_STATUSES.SUCCEEDED:
|
||||||
|
return (
|
||||||
|
<Flex gap="small" style={{ color: themeToken.colorSuccess }}>
|
||||||
|
<CheckCircleOutlinedIcon />
|
||||||
|
{t("workflow_run.props.status.succeeded")}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
case WORKFLOW_RUN_STATUSES.FAILED:
|
||||||
|
return (
|
||||||
|
<Flex gap="small" style={{ color: themeToken.colorError }}>
|
||||||
|
<CloseCircleOutlinedIcon />
|
||||||
|
{t("workflow_run.props.status.failed")}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
case WORKFLOW_RUN_STATUSES.CANCELED:
|
||||||
|
return (
|
||||||
|
<Flex gap="small" style={{ color: themeToken.colorWarning }}>
|
||||||
|
<StopOutlinedIcon />
|
||||||
|
{t("workflow_run.props.status.canceled")}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <></>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderRecord = (record: Log) => {
|
||||||
let message = <>{record.message}</>;
|
let message = <>{record.message}</>;
|
||||||
if (record.data != null && Object.keys(record.data).length > 0) {
|
if (record.data != null && Object.keys(record.data).length > 0) {
|
||||||
message = (
|
message = (
|
||||||
@ -100,8 +160,8 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
<summary>{record.message}</summary>
|
<summary>{record.message}</summary>
|
||||||
{Object.entries(record.data).map(([key, value]) => (
|
{Object.entries(record.data).map(([key, value]) => (
|
||||||
<div key={key} className="flex space-x-2 " style={{ wordBreak: "break-word" }}>
|
<div key={key} className="flex space-x-2 " style={{ wordBreak: "break-word" }}>
|
||||||
<div>{key}:</div>
|
<div className="whitespace-nowrap">{key}:</div>
|
||||||
<div>{JSON.stringify(value)}</div>
|
<div className={!showWhitespace ? "whitespace-pre-line" : ""}>{JSON.stringify(value)}</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</details>
|
</details>
|
||||||
@ -110,13 +170,14 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex space-x-2 text-xs" style={{ wordBreak: "break-word" }}>
|
<div className="flex space-x-2 text-xs" style={{ wordBreak: "break-word" }}>
|
||||||
<div className="whitespace-nowrap text-stone-400">[{dayjs(record.created).format("YYYY-MM-DD HH:mm:ss")}]</div>
|
{showTimestamp ? <div className="whitespace-nowrap text-stone-400">[{dayjs(record.timestamp).format("YYYY-MM-DD HH:mm:ss")}]</div> : <></>}
|
||||||
<div
|
<div
|
||||||
className={mergeCls(
|
className={mergeCls(
|
||||||
"font-mono",
|
"font-mono",
|
||||||
record.level === "DEBUG" ? "text-stone-400" : "",
|
record.level === "DEBUG" ? "text-stone-400" : "",
|
||||||
record.level === "WARN" ? "text-yellow-600" : "",
|
record.level === "WARN" ? "text-yellow-600" : "",
|
||||||
record.level === "ERROR" ? "text-red-600" : ""
|
record.level === "ERROR" ? "text-red-600" : "",
|
||||||
|
!showWhitespace ? "whitespace-pre-line" : ""
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{message}
|
{message}
|
||||||
@ -129,6 +190,35 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
<>
|
<>
|
||||||
<Typography.Title level={5}>{t("workflow_run.logs")}</Typography.Title>
|
<Typography.Title level={5}>{t("workflow_run.logs")}</Typography.Title>
|
||||||
<div className="rounded-md bg-black text-stone-200">
|
<div className="rounded-md bg-black text-stone-200">
|
||||||
|
<div className="flex items-center gap-2 p-4">
|
||||||
|
<div className="grow overflow-hidden">{renderBadge()}</div>
|
||||||
|
<div>
|
||||||
|
<Dropdown
|
||||||
|
menu={{
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: "show-timestamp",
|
||||||
|
label: t("workflow_run.logs.menu.show_timestamps"),
|
||||||
|
icon: <CheckOutlinedIcon className={showTimestamp ? "visible" : "invisible"} />,
|
||||||
|
onClick: () => setShowTimestamp(!showTimestamp),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "show-whitespace",
|
||||||
|
label: t("workflow_run.logs.menu.show_whitespaces"),
|
||||||
|
icon: <CheckOutlinedIcon className={showWhitespace ? "visible" : "invisible"} />,
|
||||||
|
onClick: () => setShowWhitespace(!showWhitespace),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}}
|
||||||
|
trigger={["click"]}
|
||||||
|
>
|
||||||
|
<Button icon={<SettingOutlinedIcon />} ghost />
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Divider className="my-0 bg-stone-800" />
|
||||||
|
|
||||||
<Show
|
<Show
|
||||||
when={!loading || listData.length > 0}
|
when={!loading || listData.length > 0}
|
||||||
fallback={
|
fallback={
|
||||||
@ -137,7 +227,7 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
</Spin>
|
</Spin>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className=" py-2">
|
<div className="py-2">
|
||||||
<Collapse
|
<Collapse
|
||||||
style={{ color: "inherit" }}
|
style={{ color: "inherit" }}
|
||||||
bordered={false}
|
bordered={false}
|
||||||
@ -155,7 +245,7 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
|
|||||||
header: { color: "inherit" },
|
header: { color: "inherit" },
|
||||||
},
|
},
|
||||||
label: group.name,
|
label: group.name,
|
||||||
children: <div className="flex flex-col space-y-1">{group.records.map((record) => renderLogRecord(record))}</div>,
|
children: <div className="flex flex-col space-y-1">{group.records.map((record) => renderRecord(record))}</div>,
|
||||||
};
|
};
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
@ -221,9 +311,6 @@ const WorkflowRunArtifacts = ({ runId }: { runId: string }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
refreshDeps: [runId],
|
refreshDeps: [runId],
|
||||||
onBefore: () => {
|
|
||||||
setTableData([]);
|
|
||||||
},
|
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setTableData(res.items);
|
setTableData(res.items);
|
||||||
},
|
},
|
||||||
|
@ -10,8 +10,6 @@ import AddNode from "./AddNode";
|
|||||||
import WorkflowElement from "../WorkflowElement";
|
import WorkflowElement from "../WorkflowElement";
|
||||||
import { type SharedNodeProps } from "./_SharedNode";
|
import { type SharedNodeProps } from "./_SharedNode";
|
||||||
|
|
||||||
const { useToken } = theme;
|
|
||||||
|
|
||||||
export type BrandNodeProps = SharedNodeProps;
|
export type BrandNodeProps = SharedNodeProps;
|
||||||
|
|
||||||
const BranchNode = ({ node, disabled }: BrandNodeProps) => {
|
const BranchNode = ({ node, disabled }: BrandNodeProps) => {
|
||||||
@ -19,7 +17,7 @@ const BranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
|
|
||||||
const { addBranch } = useWorkflowStore(useZustandShallowSelector(["addBranch"]));
|
const { addBranch } = useWorkflowStore(useZustandShallowSelector(["addBranch"]));
|
||||||
|
|
||||||
const token = useToken();
|
const { token: themeToken } = theme.useToken();
|
||||||
|
|
||||||
const renderBranch = (node: WorkflowNode, branchNodeId?: string, branchIndex?: number) => {
|
const renderBranch = (node: WorkflowNode, branchNodeId?: string, branchIndex?: number) => {
|
||||||
const elements: JSX.Element[] = [];
|
const elements: JSX.Element[] = [];
|
||||||
@ -38,7 +36,7 @@ const BranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
<div
|
<div
|
||||||
className="relative flex gap-x-16 before:absolute before:inset-x-[128px] before:top-0 before:h-[2px] before:bg-stone-200 before:content-[''] after:absolute after:inset-x-[128px] after:bottom-0 after:h-[2px] after:bg-stone-200 after:content-['']"
|
className="relative flex gap-x-16 before:absolute before:inset-x-[128px] before:top-0 before:h-[2px] before:bg-stone-200 before:content-[''] after:absolute after:inset-x-[128px] after:bottom-0 after:h-[2px] after:bg-stone-200 after:content-['']"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
@ -64,13 +62,13 @@ const BranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
<div
|
<div
|
||||||
className="absolute -left-px -top-1 h-2 w-1/2"
|
className="absolute -left-px -top-1 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
className="absolute -bottom-1 -left-px z-50 h-2 w-1/2"
|
className="absolute -bottom-1 -left-px z-50 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
</>
|
</>
|
||||||
@ -80,13 +78,13 @@ const BranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
<div
|
<div
|
||||||
className="absolute -right-px -top-1 h-2 w-1/2"
|
className="absolute -right-px -top-1 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
className="absolute -bottom-1 -right-px z-50 h-2 w-1/2"
|
className="absolute -bottom-1 -right-px z-50 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
</>
|
</>
|
||||||
|
@ -7,12 +7,10 @@ import AddNode from "./AddNode";
|
|||||||
import WorkflowElement from "../WorkflowElement";
|
import WorkflowElement from "../WorkflowElement";
|
||||||
import { type SharedNodeProps } from "./_SharedNode";
|
import { type SharedNodeProps } from "./_SharedNode";
|
||||||
|
|
||||||
const { useToken } = theme;
|
|
||||||
|
|
||||||
export type BrandNodeProps = SharedNodeProps;
|
export type BrandNodeProps = SharedNodeProps;
|
||||||
|
|
||||||
const ExecuteResultBranchNode = ({ node, disabled }: BrandNodeProps) => {
|
const ExecuteResultBranchNode = ({ node, disabled }: BrandNodeProps) => {
|
||||||
const token = useToken();
|
const { token: themeToken } = theme.useToken();
|
||||||
|
|
||||||
const renderBranch = (node: WorkflowNode, branchNodeId?: string, branchIndex?: number) => {
|
const renderBranch = (node: WorkflowNode, branchNodeId?: string, branchIndex?: number) => {
|
||||||
const elements: JSX.Element[] = [];
|
const elements: JSX.Element[] = [];
|
||||||
@ -31,7 +29,7 @@ const ExecuteResultBranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
<div
|
<div
|
||||||
className="relative flex gap-x-16 before:absolute before:inset-x-[128px] before:top-0 before:h-[2px] before:bg-stone-200 before:content-[''] after:absolute after:inset-x-[128px] after:bottom-0 after:h-[2px] after:bg-stone-200 after:content-['']"
|
className="relative flex gap-x-16 before:absolute before:inset-x-[128px] before:top-0 before:h-[2px] before:bg-stone-200 before:content-[''] after:absolute after:inset-x-[128px] after:bottom-0 after:h-[2px] after:bg-stone-200 after:content-['']"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{node.branches?.map((branch, index) => (
|
{node.branches?.map((branch, index) => (
|
||||||
@ -44,13 +42,13 @@ const ExecuteResultBranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
<div
|
<div
|
||||||
className="absolute -left-px -top-1 h-2 w-1/2"
|
className="absolute -left-px -top-1 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
className="absolute -bottom-1 -left-px z-50 h-2 w-1/2"
|
className="absolute -bottom-1 -left-px z-50 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
</>
|
</>
|
||||||
@ -60,13 +58,13 @@ const ExecuteResultBranchNode = ({ node, disabled }: BrandNodeProps) => {
|
|||||||
<div
|
<div
|
||||||
className="absolute -right-px -top-1 h-2 w-1/2"
|
className="absolute -right-px -top-1 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
className="absolute -bottom-1 -right-px z-50 h-2 w-1/2"
|
className="absolute -bottom-1 -right-px z-50 h-2 w-1/2"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: token.token.colorBgContainer,
|
backgroundColor: themeToken.colorBgContainer,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
</>
|
</>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export interface WorkflowLogModel extends Omit<BaseModel, "updated"> {
|
export interface WorkflowLogModel extends Omit<BaseModel, "updated"> {
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
nodeName: string;
|
nodeName: string;
|
||||||
|
timestamp: ReturnType<typeof Date.prototype.getTime>;
|
||||||
level: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
level: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
||||||
message: string;
|
message: string;
|
||||||
data: Record<string, any>;
|
data: Record<string, any>;
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
"workflow_run.props.ended_at": "Ended at",
|
"workflow_run.props.ended_at": "Ended at",
|
||||||
|
|
||||||
"workflow_run.logs": "Logs",
|
"workflow_run.logs": "Logs",
|
||||||
"workflow_run.artifacts": "Artifacts",
|
"workflow_run.logs.menu.show_timestamps": "Show timestamps",
|
||||||
|
"workflow_run.logs.menu.show_whitespaces": "Show whitespaces",
|
||||||
|
|
||||||
|
"workflow_run.artifacts": "Artifacts",
|
||||||
"workflow_run_artifact.props.type": "Type",
|
"workflow_run_artifact.props.type": "Type",
|
||||||
"workflow_run_artifact.props.type.certificate": "Certificate",
|
"workflow_run_artifact.props.type.certificate": "Certificate",
|
||||||
"workflow_run_artifact.props.name": "Name"
|
"workflow_run_artifact.props.name": "Name"
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
"workflow_run.props.ended_at": "完成时间",
|
"workflow_run.props.ended_at": "完成时间",
|
||||||
|
|
||||||
"workflow_run.logs": "日志",
|
"workflow_run.logs": "日志",
|
||||||
"workflow_run.artifacts": "输出产物",
|
"workflow_run.logs.menu.show_timestamps": "显示日期时间",
|
||||||
|
"workflow_run.logs.menu.show_whitespaces": "显示转义换行符",
|
||||||
|
|
||||||
|
"workflow_run.artifacts": "输出产物",
|
||||||
"workflow_run_artifact.props.type": "类型",
|
"workflow_run_artifact.props.type": "类型",
|
||||||
"workflow_run_artifact.props.type.certificate": "证书",
|
"workflow_run_artifact.props.type.certificate": "证书",
|
||||||
"workflow_run_artifact.props.name": "名称"
|
"workflow_run_artifact.props.name": "名称"
|
||||||
|
@ -39,7 +39,7 @@ export const listByWorkflowRunId = async (workflowRunId: string) => {
|
|||||||
const list = await pb.collection(COLLECTION_NAME_CERTIFICATE).getFullList<CertificateModel>({
|
const list = await pb.collection(COLLECTION_NAME_CERTIFICATE).getFullList<CertificateModel>({
|
||||||
batch: 65535,
|
batch: 65535,
|
||||||
filter: pb.filter("workflowRunId={:workflowRunId}", { workflowRunId: workflowRunId }),
|
filter: pb.filter("workflowRunId={:workflowRunId}", { workflowRunId: workflowRunId }),
|
||||||
// sort: "created",
|
sort: "created",
|
||||||
requestKey: null,
|
requestKey: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export const listByWorkflowRunId = async (workflowRunId: string) => {
|
|||||||
const list = await pb.collection(COLLECTION_NAME_WORKFLOW_LOG).getFullList<WorkflowLogModel>({
|
const list = await pb.collection(COLLECTION_NAME_WORKFLOW_LOG).getFullList<WorkflowLogModel>({
|
||||||
batch: 65535,
|
batch: 65535,
|
||||||
filter: pb.filter("runId={:runId}", { runId: workflowRunId }),
|
filter: pb.filter("runId={:runId}", { runId: workflowRunId }),
|
||||||
// sort: "created",
|
sort: "timestamp",
|
||||||
requestKey: null,
|
requestKey: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user