mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-02-19 00:07:01 +08:00
feat: 证书增加编辑功能 (#4901)
This commit is contained in:
parent
736914f443
commit
43ebf6eef9
9 changed files with 202 additions and 70 deletions
|
|
@ -32,8 +32,9 @@ type WebsiteSSLRenew struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteSSLApply struct {
|
type WebsiteSSLApply struct {
|
||||||
ID uint `json:"ID" validate:"required"`
|
ID uint `json:"ID" validate:"required"`
|
||||||
SkipDNSCheck bool `json:"SkipDNSCheck"`
|
SkipDNSCheck bool `json:"skipDNSCheck"`
|
||||||
|
Nameservers []string `json:"nameservers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteAcmeAccountCreate struct {
|
type WebsiteAcmeAccountCreate struct {
|
||||||
|
|
@ -66,9 +67,18 @@ type WebsiteBatchDelReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteSSLUpdate struct {
|
type WebsiteSSLUpdate struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
AutoRenew bool `json:"autoRenew"`
|
AutoRenew bool `json:"autoRenew"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
PrimaryDomain string `json:"primaryDomain" validate:"required"`
|
||||||
|
OtherDomains string `json:"otherDomains"`
|
||||||
|
Provider string `json:"provider" validate:"required"`
|
||||||
|
AcmeAccountID uint `json:"acmeAccountId" validate:"required"`
|
||||||
|
DnsAccountID uint `json:"dnsAccountId"`
|
||||||
|
KeyType string `json:"keyType"`
|
||||||
|
Apply bool `json:"apply"`
|
||||||
|
PushDir bool `json:"pushDir"`
|
||||||
|
Dir string `json:"dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteSSLUpload struct {
|
type WebsiteSSLUpload struct {
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,24 @@ import (
|
||||||
|
|
||||||
type WebsiteSSL struct {
|
type WebsiteSSL struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
PrimaryDomain string `gorm:"type:varchar(256);not null" json:"primaryDomain"`
|
PrimaryDomain string `json:"primaryDomain"`
|
||||||
PrivateKey string `gorm:"type:longtext;not null" json:"privateKey"`
|
PrivateKey string `json:"privateKey"`
|
||||||
Pem string `gorm:"type:longtext;not null" json:"pem"`
|
Pem string `json:"pem"`
|
||||||
Domains string `gorm:"type:varchar(256);not null" json:"domains"`
|
Domains string `json:"domains"`
|
||||||
CertURL string `gorm:"type:varchar(256);not null" json:"certURL"`
|
CertURL string `json:"certURL"`
|
||||||
Type string `gorm:"type:varchar(64);not null" json:"type"`
|
Type string `json:"type"`
|
||||||
Provider string `gorm:"type:varchar(64);not null" json:"provider"`
|
Provider string `json:"provider"`
|
||||||
Organization string `gorm:"type:varchar(64);not null" json:"organization"`
|
Organization string `json:"organization"`
|
||||||
DnsAccountID uint `gorm:"type:integer;not null" json:"dnsAccountId"`
|
DnsAccountID uint `json:"dnsAccountId"`
|
||||||
AcmeAccountID uint `gorm:"type:integer;not null" json:"acmeAccountId"`
|
AcmeAccountID uint `gorm:"column:acme_account_id" json:"acmeAccountId" `
|
||||||
CaID uint `gorm:"type:integer;not null;default:0" json:"caId"`
|
CaID uint `json:"caId"`
|
||||||
AutoRenew bool `gorm:"type:varchar(64);not null" json:"autoRenew"`
|
AutoRenew bool `json:"autoRenew"`
|
||||||
ExpireDate time.Time `json:"expireDate"`
|
ExpireDate time.Time `json:"expireDate"`
|
||||||
StartDate time.Time `json:"startDate"`
|
StartDate time.Time `json:"startDate"`
|
||||||
Status string `gorm:"not null;default:ready" json:"status"`
|
Status string `json:"status"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
KeyType string `gorm:"not null;default:2048" json:"keyType"`
|
KeyType string `json:"keyType"`
|
||||||
PushDir bool `gorm:"not null;default:0" json:"pushDir"`
|
PushDir bool `json:"pushDir"`
|
||||||
Dir string `json:"dir"`
|
Dir string `json:"dir"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ type ISSLRepo interface {
|
||||||
Create(ctx context.Context, ssl *model.WebsiteSSL) error
|
Create(ctx context.Context, ssl *model.WebsiteSSL) error
|
||||||
Save(ssl *model.WebsiteSSL) error
|
Save(ssl *model.WebsiteSSL) error
|
||||||
DeleteBy(opts ...DBOption) error
|
DeleteBy(opts ...DBOption) error
|
||||||
|
SaveByMap(ssl *model.WebsiteSSL, params map[string]interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteSSLRepo struct {
|
type WebsiteSSLRepo struct {
|
||||||
|
|
@ -82,7 +83,15 @@ func (w WebsiteSSLRepo) Create(ctx context.Context, ssl *model.WebsiteSSL) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) Save(ssl *model.WebsiteSSL) error {
|
func (w WebsiteSSLRepo) Save(ssl *model.WebsiteSSL) error {
|
||||||
return getDb().Save(&ssl).Error
|
return getDb().Model(&model.WebsiteSSL{BaseModel: model.BaseModel{
|
||||||
|
ID: ssl.ID,
|
||||||
|
}}).Save(&ssl).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WebsiteSSLRepo) SaveByMap(ssl *model.WebsiteSSL, params map[string]interface{}) error {
|
||||||
|
return getDb().Model(&model.WebsiteSSL{BaseModel: model.BaseModel{
|
||||||
|
ID: ssl.ID,
|
||||||
|
}}).Updates(params).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) DeleteBy(opts ...DBOption) error {
|
func (w WebsiteSSLRepo) DeleteBy(opts ...DBOption) error {
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,7 @@ func (w WebsiteCAService) ObtainSSL(req request.WebsiteCAObtain) (*model.Website
|
||||||
websiteSSL.StartDate = cert.NotBefore
|
websiteSSL.StartDate = cert.NotBefore
|
||||||
websiteSSL.Type = cert.Issuer.CommonName
|
websiteSSL.Type = cert.Issuer.CommonName
|
||||||
websiteSSL.Organization = rootCsr.Subject.Organization[0]
|
websiteSSL.Organization = rootCsr.Subject.Organization[0]
|
||||||
|
websiteSSL.Status = constant.SSLReady
|
||||||
|
|
||||||
if req.Renew {
|
if req.Renew {
|
||||||
if err := websiteSSLRepo.Save(websiteSSL); err != nil {
|
if err := websiteSSLRepo.Save(websiteSSL); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ func (w WebsiteSSLService) ObtainSSL(apply request.WebsiteSSLApply) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = client.UseDns(ssl.DnsType(dnsAccount.Type), dnsAccount.Authorization, apply.SkipDNSCheck); err != nil {
|
if err = client.UseDns(ssl.DnsType(dnsAccount.Type), dnsAccount.Authorization, apply.SkipDNSCheck, apply.Nameservers); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case constant.Http:
|
case constant.Http:
|
||||||
|
|
@ -368,9 +368,49 @@ func (w WebsiteSSLService) Update(update request.WebsiteSSLUpdate) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
websiteSSL.AutoRenew = update.AutoRenew
|
updateParams := make(map[string]interface{})
|
||||||
websiteSSL.Description = update.Description
|
updateParams["primary_domain"] = update.PrimaryDomain
|
||||||
return websiteSSLRepo.Save(websiteSSL)
|
updateParams["description"] = update.Description
|
||||||
|
updateParams["provider"] = update.Provider
|
||||||
|
updateParams["key_type"] = update.KeyType
|
||||||
|
updateParams["push_dir"] = update.PushDir
|
||||||
|
|
||||||
|
acmeAccount, err := websiteAcmeRepo.GetFirst(commonRepo.WithByID(update.AcmeAccountID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateParams["acme_account_id"] = acmeAccount.ID
|
||||||
|
|
||||||
|
if update.PushDir {
|
||||||
|
if !files.NewFileOp().Stat(update.Dir) {
|
||||||
|
return buserr.New(constant.ErrLinkPathNotFound)
|
||||||
|
}
|
||||||
|
updateParams["dir"] = update.Dir
|
||||||
|
}
|
||||||
|
var domains []string
|
||||||
|
if update.OtherDomains != "" {
|
||||||
|
otherDomainArray := strings.Split(update.OtherDomains, "\n")
|
||||||
|
for _, domain := range otherDomainArray {
|
||||||
|
if !common.IsValidDomain(domain) {
|
||||||
|
return buserr.WithName("ErrDomainFormat", domain)
|
||||||
|
}
|
||||||
|
domains = append(domains, domain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateParams["domains"] = strings.Join(domains, ",")
|
||||||
|
if update.Provider == constant.DNSAccount || update.Provider == constant.Http {
|
||||||
|
updateParams["auto_renew"] = update.AutoRenew
|
||||||
|
} else {
|
||||||
|
updateParams["auto_renew"] = false
|
||||||
|
}
|
||||||
|
if update.Provider == constant.DNSAccount {
|
||||||
|
dnsAccount, err := websiteDnsRepo.GetFirst(commonRepo.WithByID(update.DnsAccountID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateParams["dns_account_id"] = dnsAccount.ID
|
||||||
|
}
|
||||||
|
return websiteSSLRepo.SaveByMap(websiteSSL, updateParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLService) Upload(req request.WebsiteSSLUpload) error {
|
func (w WebsiteSSLService) Upload(req request.WebsiteSSLUpload) error {
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ type DNSParam struct {
|
||||||
SecretID string `json:"secretID"`
|
SecretID string `json:"secretID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool) error {
|
func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool, nameservers []string) error {
|
||||||
var (
|
var (
|
||||||
param DNSParam
|
param DNSParam
|
||||||
p challenge.Provider
|
p challenge.Provider
|
||||||
|
|
@ -99,15 +99,15 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool) e
|
||||||
case DnsPod:
|
case DnsPod:
|
||||||
dnsPodConfig := dnspod.NewDefaultConfig()
|
dnsPodConfig := dnspod.NewDefaultConfig()
|
||||||
dnsPodConfig.LoginToken = param.ID + "," + param.Token
|
dnsPodConfig.LoginToken = param.ID + "," + param.Token
|
||||||
dnsPodConfig.PropagationTimeout = 60 * time.Minute
|
dnsPodConfig.PropagationTimeout = 15 * time.Minute
|
||||||
dnsPodConfig.PollingInterval = 5 * time.Second
|
dnsPodConfig.PollingInterval = 10 * time.Second
|
||||||
dnsPodConfig.TTL = 3600
|
dnsPodConfig.TTL = 3600
|
||||||
p, err = dnspod.NewDNSProviderConfig(dnsPodConfig)
|
p, err = dnspod.NewDNSProviderConfig(dnsPodConfig)
|
||||||
case AliYun:
|
case AliYun:
|
||||||
alidnsConfig := alidns.NewDefaultConfig()
|
alidnsConfig := alidns.NewDefaultConfig()
|
||||||
alidnsConfig.SecretKey = param.SecretKey
|
alidnsConfig.SecretKey = param.SecretKey
|
||||||
alidnsConfig.APIKey = param.AccessKey
|
alidnsConfig.APIKey = param.AccessKey
|
||||||
alidnsConfig.PropagationTimeout = 60 * time.Minute
|
alidnsConfig.PropagationTimeout = 15 * time.Minute
|
||||||
alidnsConfig.PollingInterval = 5 * time.Second
|
alidnsConfig.PollingInterval = 5 * time.Second
|
||||||
alidnsConfig.TTL = 3600
|
alidnsConfig.TTL = 3600
|
||||||
p, err = alidns.NewDNSProviderConfig(alidnsConfig)
|
p, err = alidns.NewDNSProviderConfig(alidnsConfig)
|
||||||
|
|
@ -115,58 +115,61 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool) e
|
||||||
cloudflareConfig := cloudflare.NewDefaultConfig()
|
cloudflareConfig := cloudflare.NewDefaultConfig()
|
||||||
cloudflareConfig.AuthEmail = param.Email
|
cloudflareConfig.AuthEmail = param.Email
|
||||||
cloudflareConfig.AuthToken = param.APIkey
|
cloudflareConfig.AuthToken = param.APIkey
|
||||||
cloudflareConfig.PropagationTimeout = 60 * time.Minute
|
cloudflareConfig.PropagationTimeout = 15 * time.Minute
|
||||||
cloudflareConfig.PollingInterval = 5 * time.Second
|
cloudflareConfig.PollingInterval = 10 * time.Second
|
||||||
cloudflareConfig.TTL = 3600
|
cloudflareConfig.TTL = 3600
|
||||||
p, err = cloudflare.NewDNSProviderConfig(cloudflareConfig)
|
p, err = cloudflare.NewDNSProviderConfig(cloudflareConfig)
|
||||||
case NameCheap:
|
case NameCheap:
|
||||||
namecheapConfig := namecheap.NewDefaultConfig()
|
namecheapConfig := namecheap.NewDefaultConfig()
|
||||||
namecheapConfig.APIKey = param.APIkey
|
namecheapConfig.APIKey = param.APIkey
|
||||||
namecheapConfig.APIUser = param.APIUser
|
namecheapConfig.APIUser = param.APIUser
|
||||||
namecheapConfig.PropagationTimeout = 60 * time.Minute
|
namecheapConfig.PropagationTimeout = 15 * time.Minute
|
||||||
namecheapConfig.PollingInterval = 5 * time.Second
|
namecheapConfig.PollingInterval = 5 * time.Second
|
||||||
namecheapConfig.TTL = 3600
|
namecheapConfig.TTL = 3600
|
||||||
p, err = namecheap.NewDNSProviderConfig(namecheapConfig)
|
p, err = namecheap.NewDNSProviderConfig(namecheapConfig)
|
||||||
case NameSilo:
|
case NameSilo:
|
||||||
nameSiloConfig := namesilo.NewDefaultConfig()
|
nameSiloConfig := namesilo.NewDefaultConfig()
|
||||||
nameSiloConfig.APIKey = param.APIkey
|
nameSiloConfig.APIKey = param.APIkey
|
||||||
nameSiloConfig.PropagationTimeout = 60 * time.Minute
|
nameSiloConfig.PropagationTimeout = 15 * time.Minute
|
||||||
nameSiloConfig.PollingInterval = 5 * time.Second
|
nameSiloConfig.PollingInterval = 10 * time.Second
|
||||||
nameSiloConfig.TTL = 3600
|
nameSiloConfig.TTL = 3600
|
||||||
p, err = namesilo.NewDNSProviderConfig(nameSiloConfig)
|
p, err = namesilo.NewDNSProviderConfig(nameSiloConfig)
|
||||||
case Godaddy:
|
case Godaddy:
|
||||||
godaddyConfig := godaddy.NewDefaultConfig()
|
godaddyConfig := godaddy.NewDefaultConfig()
|
||||||
godaddyConfig.APIKey = param.APIkey
|
godaddyConfig.APIKey = param.APIkey
|
||||||
godaddyConfig.APISecret = param.APISecret
|
godaddyConfig.APISecret = param.APISecret
|
||||||
godaddyConfig.PropagationTimeout = 60 * time.Minute
|
godaddyConfig.PropagationTimeout = 15 * time.Minute
|
||||||
godaddyConfig.PollingInterval = 5 * time.Second
|
godaddyConfig.PollingInterval = 10 * time.Second
|
||||||
godaddyConfig.TTL = 3600
|
godaddyConfig.TTL = 3600
|
||||||
p, err = godaddy.NewDNSProviderConfig(godaddyConfig)
|
p, err = godaddy.NewDNSProviderConfig(godaddyConfig)
|
||||||
case NameCom:
|
case NameCom:
|
||||||
nameComConfig := namedotcom.NewDefaultConfig()
|
nameComConfig := namedotcom.NewDefaultConfig()
|
||||||
nameComConfig.APIToken = param.Token
|
nameComConfig.APIToken = param.Token
|
||||||
nameComConfig.Username = param.APIUser
|
nameComConfig.Username = param.APIUser
|
||||||
nameComConfig.PropagationTimeout = 30 * time.Minute
|
nameComConfig.PropagationTimeout = 15 * time.Minute
|
||||||
nameComConfig.PollingInterval = 30 * time.Second
|
nameComConfig.PollingInterval = 10 * time.Second
|
||||||
nameComConfig.TTL = 3600
|
nameComConfig.TTL = 3600
|
||||||
p, err = namedotcom.NewDNSProviderConfig(nameComConfig)
|
p, err = namedotcom.NewDNSProviderConfig(nameComConfig)
|
||||||
case TencentCloud:
|
case TencentCloud:
|
||||||
tencentCloudConfig := tencentcloud.NewDefaultConfig()
|
tencentCloudConfig := tencentcloud.NewDefaultConfig()
|
||||||
tencentCloudConfig.SecretID = param.SecretID
|
tencentCloudConfig.SecretID = param.SecretID
|
||||||
tencentCloudConfig.SecretKey = param.SecretKey
|
tencentCloudConfig.SecretKey = param.SecretKey
|
||||||
tencentCloudConfig.PropagationTimeout = 30 * time.Minute
|
tencentCloudConfig.PropagationTimeout = 15 * time.Minute
|
||||||
tencentCloudConfig.PollingInterval = 30 * time.Second
|
tencentCloudConfig.PollingInterval = 10 * time.Second
|
||||||
tencentCloudConfig.TTL = 3600
|
tencentCloudConfig.TTL = 3600
|
||||||
p, err = tencentcloud.NewDNSProviderConfig(tencentCloudConfig)
|
p, err = tencentcloud.NewDNSProviderConfig(tencentCloudConfig)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if skipDNSCheck {
|
|
||||||
return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(10*time.Minute), dns01.DisableCompletePropagationRequirement())
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(10*time.Minute))
|
return c.Client.Challenge.SetDNS01Provider(p,
|
||||||
|
dns01.CondOption(len(nameservers) > 0,
|
||||||
|
dns01.AddRecursiveNameservers(nameservers)),
|
||||||
|
dns01.CondOption(skipDNSCheck,
|
||||||
|
dns01.DisableCompletePropagationRequirement()),
|
||||||
|
dns01.AddDNSTimeout(10*time.Minute),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AcmeClient) UseManualDns() error {
|
func (c *AcmeClient) UseManualDns() error {
|
||||||
|
|
|
||||||
|
|
@ -165,10 +165,14 @@ export namespace Website {
|
||||||
provider: string;
|
provider: string;
|
||||||
websites?: Website.Website[];
|
websites?: Website.Website[];
|
||||||
autoRenew: boolean;
|
autoRenew: boolean;
|
||||||
acmeAccountId?: number;
|
acmeAccountId: number;
|
||||||
status: string;
|
status: string;
|
||||||
domains: string;
|
domains: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
dnsAccountId?: number;
|
||||||
|
pushDir: boolean;
|
||||||
|
dir: string;
|
||||||
|
keyType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SSLDTO extends SSL {
|
export interface SSLDTO extends SSL {
|
||||||
|
|
@ -198,6 +202,14 @@ export namespace Website {
|
||||||
id: number;
|
id: number;
|
||||||
autoRenew: boolean;
|
autoRenew: boolean;
|
||||||
description: string;
|
description: string;
|
||||||
|
primaryDomain: string;
|
||||||
|
otherDomains: string;
|
||||||
|
acmeAccountId: number;
|
||||||
|
provider: string;
|
||||||
|
dnsAccountId?: number;
|
||||||
|
keyType: string;
|
||||||
|
pushDir: boolean;
|
||||||
|
dir: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AcmeAccount extends CommonModel {
|
export interface AcmeAccount extends CommonModel {
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
import { Website } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { CreateSSL, ListWebsites, SearchAcmeAccount, SearchDnsAccount } from '@/api/modules/website';
|
import { CreateSSL, ListWebsites, SearchAcmeAccount, SearchDnsAccount, UpdateSSL } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { FormInstance } from 'element-plus';
|
import { FormInstance } from 'element-plus';
|
||||||
|
|
@ -182,6 +182,7 @@ const rules = ref({
|
||||||
const websiteID = ref();
|
const websiteID = ref();
|
||||||
|
|
||||||
const initData = () => ({
|
const initData = () => ({
|
||||||
|
id: 0,
|
||||||
primaryDomain: '',
|
primaryDomain: '',
|
||||||
otherDomains: '',
|
otherDomains: '',
|
||||||
provider: 'dnsAccount',
|
provider: 'dnsAccount',
|
||||||
|
|
@ -196,8 +197,8 @@ const initData = () => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const ssl = ref(initData());
|
const ssl = ref(initData());
|
||||||
|
const operate = ref('create');
|
||||||
const dnsResolve = ref<Website.DNSResolve[]>([]);
|
const dnsResolve = ref<Website.DNSResolve[]>([]);
|
||||||
|
|
||||||
const em = defineEmits(['close', 'submit']);
|
const em = defineEmits(['close', 'submit']);
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
@ -211,8 +212,26 @@ const resetForm = () => {
|
||||||
websiteID.value = undefined;
|
websiteID.value = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const acceptParams = () => {
|
const acceptParams = (op: string, websiteSSL: Website.SSLDTO) => {
|
||||||
resetForm();
|
operate.value = op;
|
||||||
|
if (op == 'create') {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
if (op == 'edit') {
|
||||||
|
console.log(websiteSSL);
|
||||||
|
ssl.value.acmeAccountId = websiteSSL.acmeAccountId;
|
||||||
|
if (websiteSSL.dnsAccountId > 0) {
|
||||||
|
ssl.value.dnsAccountId = websiteSSL.dnsAccountId;
|
||||||
|
}
|
||||||
|
ssl.value.primaryDomain = websiteSSL.primaryDomain;
|
||||||
|
ssl.value.pushDir = websiteSSL.pushDir;
|
||||||
|
ssl.value.dir = websiteSSL.dir;
|
||||||
|
ssl.value.otherDomains = websiteSSL.domains;
|
||||||
|
ssl.value.autoRenew = websiteSSL.autoRenew;
|
||||||
|
ssl.value.description = websiteSSL.description;
|
||||||
|
ssl.value.id = websiteSSL.id;
|
||||||
|
ssl.value.provider = websiteSSL.provider;
|
||||||
|
}
|
||||||
ssl.value.websiteId = Number(id.value);
|
ssl.value.websiteId = Number(id.value);
|
||||||
getAcmeAccounts();
|
getAcmeAccounts();
|
||||||
getDnsAccounts();
|
getDnsAccounts();
|
||||||
|
|
@ -227,7 +246,7 @@ const getPath = (dir: string) => {
|
||||||
const getAcmeAccounts = async () => {
|
const getAcmeAccounts = async () => {
|
||||||
const res = await SearchAcmeAccount(acmeReq);
|
const res = await SearchAcmeAccount(acmeReq);
|
||||||
acmeAccounts.value = res.data.items || [];
|
acmeAccounts.value = res.data.items || [];
|
||||||
if (acmeAccounts.value.length > 0) {
|
if (acmeAccounts.value.length > 0 && ssl.value.acmeAccountId == undefined) {
|
||||||
ssl.value.acmeAccountId = res.data.items[0].id;
|
ssl.value.acmeAccountId = res.data.items[0].id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -235,7 +254,7 @@ const getAcmeAccounts = async () => {
|
||||||
const getDnsAccounts = async () => {
|
const getDnsAccounts = async () => {
|
||||||
const res = await SearchDnsAccount(dnsReq);
|
const res = await SearchDnsAccount(dnsReq);
|
||||||
dnsAccounts.value = res.data.items || [];
|
dnsAccounts.value = res.data.items || [];
|
||||||
if (dnsAccounts.value.length > 0) {
|
if (dnsAccounts.value.length > 0 && ssl.value.dnsAccountId == undefined) {
|
||||||
ssl.value.dnsAccountId = res.data.items[0].id;
|
ssl.value.dnsAccountId = res.data.items[0].id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -273,17 +292,42 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
CreateSSL(ssl.value)
|
if (operate.value == 'create') {
|
||||||
.then((res: any) => {
|
CreateSSL(ssl.value)
|
||||||
if (ssl.value.provider != 'dnsManual') {
|
.then((res: any) => {
|
||||||
em('submit', res.data.id);
|
if (ssl.value.provider != 'dnsManual') {
|
||||||
}
|
em('submit', res.data.id);
|
||||||
handleClose();
|
}
|
||||||
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
|
handleClose();
|
||||||
})
|
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
|
||||||
.finally(() => {
|
})
|
||||||
loading.value = false;
|
.finally(() => {
|
||||||
});
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (operate.value == 'edit') {
|
||||||
|
const sslUpdate = {
|
||||||
|
id: ssl.value.id,
|
||||||
|
primaryDomain: ssl.value.primaryDomain,
|
||||||
|
otherDomains: ssl.value.otherDomains,
|
||||||
|
acmeAccountId: ssl.value.acmeAccountId,
|
||||||
|
dnsAccountId: ssl.value.dnsAccountId,
|
||||||
|
autoRenew: ssl.value.autoRenew,
|
||||||
|
keyType: ssl.value.keyType,
|
||||||
|
pushDir: ssl.value.pushDir,
|
||||||
|
dir: ssl.value.dir,
|
||||||
|
description: ssl.value.description,
|
||||||
|
provider: ssl.value.provider,
|
||||||
|
};
|
||||||
|
UpdateSSL(sslUpdate)
|
||||||
|
.then(() => {
|
||||||
|
handleClose();
|
||||||
|
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,11 +138,11 @@
|
||||||
/>
|
/>
|
||||||
</ComplexTable>
|
</ComplexTable>
|
||||||
</template>
|
</template>
|
||||||
<DnsAccount ref="dnsAccountRef"></DnsAccount>
|
<DnsAccount ref="dnsAccountRef" />
|
||||||
<AcmeAccount ref="acmeAccountRef"></AcmeAccount>
|
<AcmeAccount ref="acmeAccountRef" />
|
||||||
<Create ref="sslCreateRef" @close="search()" @submit="openLog"></Create>
|
<Create ref="sslCreateRef" @close="search()" @submit="openLog" />
|
||||||
<Detail ref="detailRef"></Detail>
|
<Detail ref="detailRef" />
|
||||||
<SSLUpload ref="sslUploadRef" @close="search()"></SSLUpload>
|
<SSLUpload ref="sslUploadRef" @close="search()" />
|
||||||
<Apply ref="applyRef" @search="search" @submit="openLog" />
|
<Apply ref="applyRef" @search="search" @submit="openLog" />
|
||||||
<OpDialog ref="opRef" @search="search" @cancel="search" />
|
<OpDialog ref="opRef" @search="search" @cancel="search" />
|
||||||
<Log ref="logRef" @close="search()" />
|
<Log ref="logRef" @close="search()" />
|
||||||
|
|
@ -189,8 +189,8 @@ const sslUploadRef = ref();
|
||||||
const applyRef = ref();
|
const applyRef = ref();
|
||||||
const logRef = ref();
|
const logRef = ref();
|
||||||
const caRef = ref();
|
const caRef = ref();
|
||||||
let selects = ref<any>([]);
|
|
||||||
const obtainRef = ref();
|
const obtainRef = ref();
|
||||||
|
let selects = ref<any>([]);
|
||||||
|
|
||||||
const routerButton = [
|
const routerButton = [
|
||||||
{
|
{
|
||||||
|
|
@ -234,6 +234,15 @@ const buttons = [
|
||||||
return row.provider == 'manual';
|
return row.provider == 'manual';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: i18n.global.t('commons.button.edit'),
|
||||||
|
click: function (row: Website.SSLDTO) {
|
||||||
|
onEdit(row);
|
||||||
|
},
|
||||||
|
disabled: function (row: Website.SSLDTO) {
|
||||||
|
return row.provider == 'selfSigned';
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('file.download'),
|
label: i18n.global.t('file.download'),
|
||||||
click: function (row: Website.SSLDTO) {
|
click: function (row: Website.SSLDTO) {
|
||||||
|
|
@ -292,7 +301,7 @@ const updateDesc = (row: Website.SSLDTO, bulr: Function) => {
|
||||||
|
|
||||||
const updateConfig = (row: Website.SSLDTO) => {
|
const updateConfig = (row: Website.SSLDTO) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
UpdateSSL({ id: row.id, autoRenew: row.autoRenew, description: row.description })
|
UpdateSSL(row)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||||
})
|
})
|
||||||
|
|
@ -308,8 +317,12 @@ const openDnsAccount = () => {
|
||||||
dnsAccountRef.value.acceptParams();
|
dnsAccountRef.value.acceptParams();
|
||||||
};
|
};
|
||||||
const openSSL = () => {
|
const openSSL = () => {
|
||||||
sslCreateRef.value.acceptParams();
|
sslCreateRef.value.acceptParams('create');
|
||||||
};
|
};
|
||||||
|
const onEdit = (row: Website.SSL) => {
|
||||||
|
sslCreateRef.value.acceptParams('edit', row);
|
||||||
|
};
|
||||||
|
|
||||||
const openUpload = () => {
|
const openUpload = () => {
|
||||||
sslUploadRef.value.acceptParams();
|
sslUploadRef.value.acceptParams();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue