diff --git a/ui/src/i18n/locales/en/nls.certificate.json b/ui/src/i18n/locales/en/nls.certificate.json index 743e5efd..37bf01ef 100644 --- a/ui/src/i18n/locales/en/nls.certificate.json +++ b/ui/src/i18n/locales/en/nls.certificate.json @@ -9,6 +9,7 @@ "certificate.props.expiry.expired": "Expired", "certificate.props.expiry.text.expire": "Expire", "certificate.props.workflow": "Workflow", + "certificate.props.source": "Source", "certificate.props.created": "Created", "certificate.props.certificate": "Certificate", "certificate.props.private.key": "Private Key", @@ -16,4 +17,3 @@ "certificate.action.view": "View Certificate", "certificate.action.download": "Download Certificate" } - diff --git a/ui/src/i18n/locales/en/nls.common.json b/ui/src/i18n/locales/en/nls.common.json index fd5aa42b..22051c9d 100644 --- a/ui/src/i18n/locales/en/nls.common.json +++ b/ui/src/i18n/locales/en/nls.common.json @@ -1,8 +1,9 @@ { + "common.add": "Add", "common.save": "Save", "common.save.succeeded.message": "Save Successful", "common.save.failed.message": "Save Failed", - "common.add": "Add", + "common.view": "View", "common.edit": "Edit", "common.copy": "Copy", "common.download": "Download", @@ -24,8 +25,9 @@ "common.text.dns": "Domain Name Server", "common.text.dns.empty": "No DNS", "common.text.ca": "Certificate Authority", - "common.text.provider": "Provider", "common.text.name": "Name", + "common.text.provider": "Provider", + "common.text.workflow": "Workflow", "common.text.created_at": "Created At", "common.text.updated_at": "Updated At", "common.text.operations": "Operations", diff --git a/ui/src/i18n/locales/zh/nls.certificate.json b/ui/src/i18n/locales/zh/nls.certificate.json index 79598856..249578fd 100644 --- a/ui/src/i18n/locales/zh/nls.certificate.json +++ b/ui/src/i18n/locales/zh/nls.certificate.json @@ -1,5 +1,5 @@ { - "certificate.page.title": "证书", + "certificate.page.title": "证书管理", "certificate.nodata": "暂无证书,添加工作流去生成证书吧😀", @@ -9,6 +9,7 @@ "certificate.props.expiry.expired": "已到期", "certificate.props.expiry.text.expire": "到期", "certificate.props.workflow": "所属工作流", + "certificate.props.source": "来源", "certificate.props.created": "颁发时间", "certificate.props.certificate": "证书", "certificate.props.private.key": "私钥", @@ -16,4 +17,3 @@ "certificate.action.view": "查看证书", "certificate.action.download": "下载证书" } - diff --git a/ui/src/i18n/locales/zh/nls.common.json b/ui/src/i18n/locales/zh/nls.common.json index 760edc0d..0d66a3ba 100644 --- a/ui/src/i18n/locales/zh/nls.common.json +++ b/ui/src/i18n/locales/zh/nls.common.json @@ -3,6 +3,7 @@ "common.save": "保存", "common.save.succeeded.message": "保存成功", "common.save.failed.message": "保存失败", + "common.view": "查看", "common.edit": "编辑", "common.copy": "复制", "common.download": "下载", @@ -26,6 +27,7 @@ "common.text.ca": "CA(证书颁发机构)", "common.text.name": "名称", "common.text.provider": "服务商", + "common.text.workflow": "工作流", "common.text.created_at": "创建时间", "common.text.updated_at": "更新时间", "common.text.operations": "操作", diff --git a/ui/src/pages/DashboardLayout.tsx b/ui/src/pages/DashboardLayout.tsx index 74f4759c..f577bcb4 100644 --- a/ui/src/pages/DashboardLayout.tsx +++ b/ui/src/pages/DashboardLayout.tsx @@ -66,8 +66,8 @@ export default function Dashboard() { {t("certificate.page.title")} @@ -114,8 +114,8 @@ export default function Dashboard() { {t("certificate.page.title")} diff --git a/ui/src/pages/certificate/index.tsx b/ui/src/pages/certificate/index.tsx deleted file mode 100644 index a9b332c5..00000000 --- a/ui/src/pages/certificate/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import CertificateList from "@/components/certificate/CertificateList"; -import { useTranslation } from "react-i18next"; - -const Certificate = () => { - const { t } = useTranslation(); - return ( -
-
{t("certificate.page.title")}
- - -
- ); -}; - -export default Certificate; diff --git a/ui/src/pages/certificates/CertificateList.tsx b/ui/src/pages/certificates/CertificateList.tsx new file mode 100644 index 00000000..fb1d67e3 --- /dev/null +++ b/ui/src/pages/certificates/CertificateList.tsx @@ -0,0 +1,176 @@ +import { useEffect, useState } from "react"; +import { useNavigate, useSearchParams } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import { Button, Space, Table, Tooltip, Typography, type TableProps } from "antd"; +import { PageHeader } from "@ant-design/pro-components"; +import { Eye as EyeIcon } from "lucide-react"; + +import { Certificate as CertificateType } from "@/domain/certificate"; +import { list as listCertificate, type CertificateListReq } from "@/repository/certificate"; +import { diffDays, getLeftDays } from "@/lib/time"; + +const CertificateList = () => { + const { t } = useTranslation(); + + const navigate = useNavigate(); + const [searchParams] = useSearchParams(); + + const [loading, setLoading] = useState(false); + + const tableColumns: TableProps["columns"] = [ + { + key: "$index", + align: "center", + title: "", + width: 50, + render: (_, __, index) => (page - 1) * pageSize + index + 1, + }, + { + key: "name", + title: t("common.text.domain"), + render: (_, record) => {record.san}, + }, + { + key: "expiry", + title: t("certificate.props.expiry"), + render: (_, record) => { + const leftDays = getLeftDays(record.expireAt); + const allDays = diffDays(record.expireAt, record.created); + return ( + + {leftDays > 0 ? ( + + {leftDays} / {allDays} {t("certificate.props.expiry.days")} + + ) : ( + {t("certificate.props.expiry.expired")} + )} + + + {new Date(record.expireAt).toLocaleString().split(" ")[0]} {t("certificate.props.expiry.text.expire")} + + + ); + }, + }, + { + key: "source", + title: t("certificate.props.source"), + render: (_, record) => { + const workflowId = record.workflow; + return workflowId ? ( + + {t("common.text.workflow")} + { + navigate(`/workflow/detail?id=${workflowId}`); + }} + > + {record.expand?.workflow?.name ?? ""} + + + ) : ( + <>TODO: 手动上传 + ); + }, + }, + { + key: "createdAt", + title: t("common.text.created_at"), + ellipsis: true, + render: (_, record) => { + return new Date(record.created!).toLocaleString(); + }, + }, + { + key: "updatedAt", + title: t("common.text.updated_at"), + ellipsis: true, + render: (_, record) => { + return new Date(record.updated!).toLocaleString(); + }, + }, + { + key: "$operations", + align: "end", + width: 100, + render: (_, record) => ( + + +