diff --git a/internal/domain/workflow_run_log.go b/internal/domain/workflow_run_log.go index fa77a9c9..91a40963 100644 --- a/internal/domain/workflow_run_log.go +++ b/internal/domain/workflow_run_log.go @@ -20,3 +20,14 @@ type WorkflowRunLog struct { Succeed bool `json:"succeed"` Error string `json:"error"` } + +type RunLogs []RunLog + +func (r RunLogs) Error() string { + for _, log := range r { + if log.Error != "" { + return log.Error + } + } + return "" +} diff --git a/internal/workflow/node-processor/apply_node.go b/internal/workflow/node-processor/apply_node.go index 8411f575..44257d4c 100644 --- a/internal/workflow/node-processor/apply_node.go +++ b/internal/workflow/node-processor/apply_node.go @@ -2,6 +2,7 @@ package nodeprocessor import ( "context" + "strings" "time" "github.com/usual2970/certimate/internal/applicant" @@ -95,7 +96,7 @@ func (a *applyNode) Run(ctx context.Context) error { } certificateRecord := &domain.Certificate{ - SAN: cert.Subject.CommonName, + SAN: strings.Join(cert.DNSNames, ";"), Certificate: certificate.Certificate, PrivateKey: certificate.PrivateKey, IssuerCertificate: certificate.IssuerCertificate, diff --git a/internal/workflow/node-processor/workflow_processor.go b/internal/workflow/node-processor/workflow_processor.go index 4602254f..96cfc7f4 100644 --- a/internal/workflow/node-processor/workflow_processor.go +++ b/internal/workflow/node-processor/workflow_processor.go @@ -33,7 +33,7 @@ func (w *workflowProcessor) runNode(ctx context.Context, node *domain.WorkflowNo if current.Type == domain.WorkflowNodeTypeBranch { for _, branch := range current.Branches { if err := w.runNode(ctx, &branch); err != nil { - continue + return err } } } diff --git a/internal/workflow/service.go b/internal/workflow/service.go index 446381d2..629cd841 100644 --- a/internal/workflow/service.go +++ b/internal/workflow/service.go @@ -57,11 +57,18 @@ func (s *WorkflowService) Run(ctx context.Context, req *domain.WorkflowRunReq) e } // 保存执行日志 - + logs := processor.Log(ctx) + runLogs := domain.RunLogs(logs) + runErr := runLogs.Error() + succeed := true + if runErr != "" { + succeed = false + } log := &domain.WorkflowRunLog{ Workflow: workflow.Id, Log: processor.Log(ctx), - Succeed: true, + Error: runErr, + Succeed: succeed, } if err := s.repo.SaveRunLog(ctx, log); err != nil { app.GetApp().Logger().Error("failed to save run log", "err", err) diff --git a/ui/src/components/certificate/CertificateDetail.tsx b/ui/src/components/certificate/CertificateDetail.tsx new file mode 100644 index 00000000..ff270489 --- /dev/null +++ b/ui/src/components/certificate/CertificateDetail.tsx @@ -0,0 +1,63 @@ +import { Sheet, SheetContent, SheetHeader, SheetTitle } from "../ui/sheet"; + +import { Certificate } from "@/domain/certificate"; +import { Textarea } from "../ui/textarea"; +import { Button } from "../ui/button"; +import { Label } from "../ui/label"; +import { CustomFile, saveFiles2ZIP } from "@/lib/file"; + +type WorkflowLogDetailProps = { + open: boolean; + onOpenChange: (open: boolean) => void; + certificate?: Certificate; +}; +const CertificateDetail = ({ open, onOpenChange, certificate }: WorkflowLogDetailProps) => { + const handleDownloadClick = async () => { + const zipName = `${certificate?.id}-${certificate?.san}.zip`; + const files: CustomFile[] = [ + { + name: `${certificate?.san}.pem`, + content: certificate?.certificate ? certificate?.certificate : "", + }, + { + name: `${certificate?.san}.key`, + content: certificate?.privateKey ? certificate?.privateKey : "", + }, + ]; + + await saveFiles2ZIP(zipName, files); + }; + + return ( + + + + + + +
+
+ +
+
+ +