mirror of https://github.com/certd/certd
perf: 流水线创建时支持添加到证书监控
parent
3a8931feef
commit
59ba408070
|
|
@ -230,6 +230,9 @@ export default {
|
|||
notificationWhen: "Notification Timing",
|
||||
notificationHelper: "Get real-time alerts when the task fails",
|
||||
groupIdTitle: "Pipeline Group",
|
||||
|
||||
addToMonitorEnabled: "Add to Cert Monitor",
|
||||
addToMonitorDomains: "Add to Monitor Domains",
|
||||
},
|
||||
notificationDefault: "Use Default Notification",
|
||||
monitor: {
|
||||
|
|
|
|||
|
|
@ -234,6 +234,8 @@ export default {
|
|||
notificationWhen: "通知时机",
|
||||
notificationHelper: "任务执行失败实时提醒",
|
||||
groupIdTitle: "流水线分组",
|
||||
addToMonitorEnabled: "添加到证书监控",
|
||||
addToMonitorDomains: "添加到监控域名",
|
||||
},
|
||||
notificationDefault: "使用默认通知",
|
||||
monitor: {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import { useRouter } from "vue-router";
|
|||
import { compute, CreateCrudOptionsRet, dict, useFormWrapper } from "@fast-crud/fast-crud";
|
||||
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
|
||||
import { useReference } from "/@/use/use-refrence";
|
||||
import { ref } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import * as api from "../api";
|
||||
import { PluginGroup, usePluginStore } from "/@/store/plugin";
|
||||
import { createNotificationApi } from "/@/views/certd/notification/api";
|
||||
import GroupSelector from "../group/group-selector.vue";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
|
||||
export function fillPipelineByDefaultForm(pipeline: any, form: any) {
|
||||
const triggers = [];
|
||||
|
|
@ -78,6 +79,7 @@ export function useCertPipelineCreator() {
|
|||
const { openCrudFormDialog } = useFormWrapper();
|
||||
|
||||
const pluginStore = usePluginStore();
|
||||
const settingStore = useSettingStore();
|
||||
const router = useRouter();
|
||||
|
||||
function createCrudOptions(certPlugins: any[], getFormData: any, doSubmit: any): CreateCrudOptionsRet {
|
||||
|
|
@ -251,7 +253,48 @@ export function useCertPipelineCreator() {
|
|||
name: GroupSelector,
|
||||
vModel: "modelValue",
|
||||
},
|
||||
order: 9999,
|
||||
order: 888,
|
||||
},
|
||||
},
|
||||
addToMonitorEnabled: {
|
||||
title: t("certd.pipelineForm.addToMonitorEnabled"),
|
||||
type: "switch",
|
||||
form: {
|
||||
show: computed(() => {
|
||||
return settingStore.isPlus && settingStore.sysPublic?.certDomainAddToMonitorEnabled;
|
||||
}),
|
||||
value: false,
|
||||
component: {
|
||||
name: "a-switch",
|
||||
vModel: "checked",
|
||||
},
|
||||
col: {
|
||||
span: 24,
|
||||
},
|
||||
order: 999,
|
||||
valueChange({ value, form }) {
|
||||
if (value) {
|
||||
form.addToMonitorDomains = form.domains.join("\n").replaceAll("*", "www");
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
addToMonitorDomains: {
|
||||
title: t("certd.pipelineForm.addToMonitorDomains"),
|
||||
type: "text",
|
||||
form: {
|
||||
show: compute(({ form }) => {
|
||||
return form.addToMonitorEnabled;
|
||||
}),
|
||||
component: {
|
||||
name: "a-textarea",
|
||||
vModel: "value",
|
||||
},
|
||||
col: {
|
||||
span: 24,
|
||||
},
|
||||
helper: t("certd.domainList.helper"),
|
||||
order: 999,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -330,6 +373,8 @@ export function useCertPipelineCreator() {
|
|||
keepHistoryCount: 30,
|
||||
type: "cert",
|
||||
groupId,
|
||||
addToMonitorEnabled: form.addToMonitorEnabled,
|
||||
addToMonitorDomains: form.addToMonitorDomains,
|
||||
});
|
||||
if (form.email) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { PipelineService } from '../../../modules/pipeline/service/pipeline-serv
|
|||
import { PipelineEntity } from '../../../modules/pipeline/entity/pipeline.js';
|
||||
import { HistoryService } from '../../../modules/pipeline/service/history-service.js';
|
||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
||||
import { SiteInfoService } from '../../../modules/monitor/index.js';
|
||||
import { isPlus } from '@certd/plus-core';
|
||||
|
||||
/**
|
||||
* 证书
|
||||
|
|
@ -20,6 +22,9 @@ export class PipelineController extends CrudController<PipelineService> {
|
|||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Inject()
|
||||
siteInfoService: SiteInfoService;
|
||||
|
||||
getService() {
|
||||
return this.service;
|
||||
}
|
||||
|
|
@ -74,13 +79,24 @@ export class PipelineController extends CrudController<PipelineService> {
|
|||
}
|
||||
|
||||
@Post('/save', { summary: Constants.per.authOnly })
|
||||
async save(@Body(ALL) bean: PipelineEntity) {
|
||||
async save(@Body(ALL) bean: {addToMonitorEnabled: boolean, addToMonitorDomains: string} & PipelineEntity) {
|
||||
if (bean.id > 0) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), bean.id);
|
||||
} else {
|
||||
bean.userId = this.getUserId();
|
||||
}
|
||||
await this.service.save(bean);
|
||||
//是否增加证书监控
|
||||
if (bean.addToMonitorEnabled && bean.addToMonitorDomains) {
|
||||
const sysPublicSettings = await this.sysSettingsService.getPublicSettings();
|
||||
if (isPlus() && sysPublicSettings.certDomainAddToMonitorEnabled) {
|
||||
//增加证书监控
|
||||
await this.siteInfoService.doImport({
|
||||
text: bean.addToMonitorDomains,
|
||||
userId: this.getUserId(),
|
||||
});
|
||||
}
|
||||
}
|
||||
return this.ok(bean.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue