diff --git a/packages/ui/certd-client/src/components/cron-editor/index.vue b/packages/ui/certd-client/src/components/cron-editor/index.vue index 0540a6d0..3b2956a2 100644 --- a/packages/ui/certd-client/src/components/cron-editor/index.vue +++ b/packages/ui/certd-client/src/components/cron-editor/index.vue @@ -16,6 +16,7 @@ import parser from "cron-parser"; import { computed, ref } from "vue"; import dayjs from "dayjs"; +import { getCronNextTimes } from "/@/components/cron-editor/utils"; defineOptions({ name: "CronEditor", }); @@ -84,10 +85,10 @@ const nextTime = computed(() => { if (props.modelValue == null) { return "请先设置正确的cron表达式"; } + try { - const interval = parser.parseExpression(props.modelValue); - const next = interval.next().getTime(); - return dayjs(next).format("YYYY-MM-DD HH:mm:ss"); + const nextTimes = getCronNextTimes(props.modelValue, 2); + return nextTimes.join(","); } catch (e) { console.log(e); return "请先设置正确的cron表达式"; diff --git a/packages/ui/certd-client/src/components/cron-editor/utils.ts b/packages/ui/certd-client/src/components/cron-editor/utils.ts new file mode 100644 index 00000000..7a2be77e --- /dev/null +++ b/packages/ui/certd-client/src/components/cron-editor/utils.ts @@ -0,0 +1,15 @@ +import parser from "cron-parser"; +import dayjs from "dayjs"; + +export function getCronNextTimes(cron: string, count: number = 1) { + if (cron == null) { + return []; + } + const nextTimes = []; + const interval = parser.parseExpression(cron); + for (let i = 0; i < count; i++) { + const next = interval.next().getTime(); + nextTimes.push(dayjs(next).format("YYYY-MM-DD HH:mm:ss")); + } + return nextTimes; +} diff --git a/packages/ui/certd-client/src/components/editable.vue b/packages/ui/certd-client/src/components/editable.vue index 7f6ae803..71de7608 100644 --- a/packages/ui/certd-client/src/components/editable.vue +++ b/packages/ui/certd-client/src/components/editable.vue @@ -76,7 +76,7 @@ export default { .text-editable { flex: 1; line-height: 34px; - + overflow: hidden; span.fs-iconify { display: inline-flex; justify-content: center; diff --git a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx index 21c09f75..50c5f064 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -5,17 +5,15 @@ import { useRouter } from "vue-router"; import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, useUi } from "@fast-crud/fast-crud"; import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status"; import { Modal, notification } from "ant-design-vue"; -import { env } from "/@/utils/util.env"; import { useUserStore } from "/@/store/user"; import dayjs from "dayjs"; import { useSettingStore } from "/@/store/settings"; import { cloneDeep } from "lodash-es"; -import { useModal } from "/@/use/use-modal"; -import CertView from "./cert-view.vue"; import { eachStages } from "./utils"; import { setRunnableIds, useCertPipelineCreator } from "/@/views/certd/pipeline/certd-form/use"; import { useCertUpload } from "/@/views/certd/pipeline/cert-upload/use"; import GroupSelector from "/@/views/certd/pipeline/group/group-selector.vue"; +import { useCertViewer } from "/@/views/certd/pipeline/use"; export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys } }: CreateCrudOptionsProps): CreateCrudOptionsRet { const router = useRouter(); @@ -61,59 +59,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys return res; }; - const model = useModal(); - const viewCert = async (row: any) => { - const cert = await api.GetCert(row.id); - if (!cert) { - notification.error({ message: "请先运行一次流水线" }); - return; - } - - model.success({ - title: "查看证书", - maskClosable: true, - okText: "关闭", - width: 800, - content: () => { - return ; - }, - }); - }; - - const downloadCert = async (row: any) => { - const files = await api.GetFiles(row.id); - model.success({ - title: "点击链接下载", - maskClosable: true, - okText: "关闭", - content: () => { - const children = []; - for (const file of files) { - const downloadUrl = `${env.API}/pi/history/download?pipelineId=${row.id}&fileId=${file.id}`; - children.push( -
-
- - - {file.filename} - -
-
- ); - } - - if (children.length === 0) { - return
暂无文件下载
; - } - - return ( -
-
{children}
-
- ); - }, - }); - }; + const { viewCert, downloadCert } = useCertViewer(); const userStore = useUserStore(); const settingStore = useSettingStore(); @@ -208,6 +154,10 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys }, table: { scroll: { x: 1500 }, + remove: { + confirmTitle: "确定要删除吗?", + confirmMessage: "将删除该流水线相关的所有数据,包括执行历史、证书文件、证书仓库记录等", + }, }, tabs: { name: "groupId", @@ -281,7 +231,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys type: "link", icon: "ph:certificate", async click({ row }) { - await viewCert(row); + await viewCert(row.id); }, }, download: { @@ -291,7 +241,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys tooltip: { title: "下载证书" }, icon: "ant-design:download-outlined", async click({ row }) { - await downloadCert(row); + await downloadCert(row.id); }, }, remove: { diff --git a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue index c3beb6b1..ec53d976 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue @@ -34,6 +34,8 @@ const pipelineOptions: PipelineOptions = { stages: [], triggers: [], ...JSON.parse(detail.pipeline.content || "{}"), + type: detail.pipeline.type, + from: detail.pipeline.from, }, } as PipelineDetail; }, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue index 0f549b5e..285ea3ee 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue @@ -1,18 +1,28 @@