mirror of https://github.com/certd/certd
perf: 阿里云waf cname站点选择支持翻页及域名查询
parent
3fb3cee423
commit
4cf98584da
|
@ -3,7 +3,7 @@ import { IContext } from "../core/index.js";
|
|||
export type UserContext = IContext;
|
||||
export type PipelineContext = IContext;
|
||||
|
||||
export type PageReq = {
|
||||
export type PageSearch = {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
searchKey?: string;
|
||||
|
@ -17,3 +17,26 @@ export type PageRes = {
|
|||
total?: string;
|
||||
list: any[];
|
||||
};
|
||||
|
||||
export class Pager {
|
||||
offset: number;
|
||||
limit: number;
|
||||
constructor(req: PageSearch) {
|
||||
this.offset = req.offset ?? 0;
|
||||
this.limit = req.limit || 50;
|
||||
}
|
||||
|
||||
getPageNo() {
|
||||
const size = this.limit;
|
||||
const offset = this.offset;
|
||||
let page = Math.floor(offset / size);
|
||||
if (offset % size === 0) {
|
||||
page++;
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
setPageNo(pageNo: number) {
|
||||
this.offset = (pageNo - 1) * (this.limit ?? 50);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||
|
||||
const checkStatusDict = dict({
|
||||
data: [
|
||||
{ label: t("checkStatus.success"), value: "ok", color: "green" },
|
||||
{ label: t("checkStatus.checking"), value: "checking", color: "blue" },
|
||||
{ label: t("checkStatus.error"), value: "error", color: "red" },
|
||||
{ label: t("certd.checkStatus.success"), value: "ok", color: "green" },
|
||||
{ label: t("certd.checkStatus.checking"), value: "checking", color: "blue" },
|
||||
{ label: t("certd.checkStatus.error"), value: "error", color: "red" },
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {AbstractTaskPlugin, IsTaskPlugin, PageReq, pluginGroups, RunStrategy, TaskInput} from '@certd/pipeline';
|
||||
import {AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput} from '@certd/pipeline';
|
||||
import {CertInfo} from '@certd/plugin-cert';
|
||||
import {
|
||||
AliyunAccess,
|
||||
|
@ -347,7 +347,7 @@ export class AliyunDeployCertToSLB extends AbstractTaskPlugin {
|
|||
});
|
||||
}
|
||||
|
||||
async onGetExtensionDomainList(data: PageReq) {
|
||||
async onGetExtensionDomainList(data: PageSearch) {
|
||||
if (!this.accessId) {
|
||||
throw new Error('请先选择Access授权');
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, Pager,PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertApplyPluginNames, CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
import {
|
||||
AliyunAccess,
|
||||
|
@ -7,7 +7,6 @@ import {
|
|||
createCertDomainGetterInputDefine,
|
||||
createRemoteSelectInputDefine
|
||||
} from "@certd/plugin-lib";
|
||||
import {PageReq} from "@certd/lib-server";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'AliyunDeployCertToWaf',
|
||||
|
@ -83,9 +82,10 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin {
|
|||
createRemoteSelectInputDefine({
|
||||
title: 'CNAME站点',
|
||||
helper: '请选择要部署证书的CNAME站点',
|
||||
typeName: 'AliyunDeployCertToWaf',
|
||||
action: AliyunDeployCertToWaf.prototype.onGetCnameList.name,
|
||||
watches: ['accessId', 'regionId'],
|
||||
pager:true,
|
||||
search:true,
|
||||
})
|
||||
)
|
||||
cnameDomains!: string[];
|
||||
|
@ -169,19 +169,26 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
async onGetCnameList(data: PageReq) {
|
||||
async onGetCnameList(data: PageSearch) {
|
||||
if (!this.accessId) {
|
||||
throw new Error('请选择Access授权');
|
||||
}
|
||||
const access = await this.getAccess<AliyunAccess>(this.accessId);
|
||||
const client = await this.getWafClient(access);
|
||||
|
||||
|
||||
const pager = new Pager(data)
|
||||
|
||||
const instanceId = await this.getInstanceId(client);
|
||||
const params = {
|
||||
const params:any = {
|
||||
RegionId: this.regionId,
|
||||
InstanceId: instanceId,
|
||||
PageSize: 50,
|
||||
PageSize: pager.limit,
|
||||
PageNumber: pager.getPageNo(),
|
||||
};
|
||||
if (data.searchKey){
|
||||
params.Domain = data.searchKey
|
||||
}
|
||||
|
||||
const res = await client.request('DescribeDomains', params);
|
||||
if (!res?.Domains || res?.Domains.length === 0) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AbstractTaskPlugin, IsTaskPlugin, PageReq, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { FarcdnAccess } from "../access.js";
|
||||
|
@ -78,7 +78,7 @@ export class FarcdnRefreshCert extends AbstractTaskPlugin {
|
|||
this.logger.info("部署完成");
|
||||
}
|
||||
|
||||
async onGetCertList(data:PageReq = {}) {
|
||||
async onGetCertList(data:PageSearch = {}) {
|
||||
const access = await this.getAccess<FarcdnAccess>(this.accessId);
|
||||
|
||||
const res = await access.getSSLCertList({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AbstractTaskPlugin, IsTaskPlugin, PageReq, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { RainyunAccess } from "../access.js";
|
||||
|
@ -78,7 +78,7 @@ export class RainyunRefreshCert extends AbstractTaskPlugin {
|
|||
this.logger.info("部署完成");
|
||||
}
|
||||
|
||||
async onGetCertList(req: PageReq = {}) {
|
||||
async onGetCertList(req: PageSearch = {}) {
|
||||
const access = await this.getAccess<RainyunAccess>(this.accessId);
|
||||
|
||||
const offset = req.offset ?? 0;
|
||||
|
|
Loading…
Reference in New Issue