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