集群设置--DNS设置页显示DNS账号名

This commit is contained in:
GoEdgeLab
2022-09-17 10:59:18 +08:00
parent b08f1ce7d2
commit 3212e687cb
4 changed files with 43 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
) )
type IndexAction struct { type IndexAction struct {
@@ -41,10 +42,23 @@ func (this *IndexAction) RunGet(params struct {
this.Data["dnsName"] = dnsInfoResp.Name this.Data["dnsName"] = dnsInfoResp.Name
this.Data["nodesAutoSync"] = dnsInfoResp.NodesAutoSync this.Data["nodesAutoSync"] = dnsInfoResp.NodesAutoSync
this.Data["serversAutoSync"] = dnsInfoResp.ServersAutoSync this.Data["serversAutoSync"] = dnsInfoResp.ServersAutoSync
var domainProviderMap = maps.Map{
"id": 0,
"name": "",
}
if dnsInfoResp.Domain != nil { if dnsInfoResp.Domain != nil {
this.Data["domainId"] = dnsInfoResp.Domain.Id this.Data["domainId"] = dnsInfoResp.Domain.Id
this.Data["domainName"] = dnsInfoResp.Domain.Name this.Data["domainName"] = dnsInfoResp.Domain.Name
if dnsInfoResp.Provider != nil {
domainProviderMap = maps.Map{
"id": dnsInfoResp.Provider.Id,
"name": dnsInfoResp.Provider.Name,
}
}
} }
this.Data["domainProvider"] = domainProviderMap
if len(dnsInfoResp.CnameRecords) == 0 { if len(dnsInfoResp.CnameRecords) == 0 {
this.Data["cnameRecords"] = []string{} this.Data["cnameRecords"] = []string{}

View File

@@ -30,7 +30,7 @@ func (this *SelectPopupAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
domain := domainResp.DnsDomain var domain = domainResp.DnsDomain
if domain != nil { if domain != nil {
this.Data["domainId"] = domain.Id this.Data["domainId"] = domain.Id
this.Data["domainName"] = domain.Name this.Data["domainName"] = domain.Name
@@ -53,7 +53,7 @@ func (this *SelectPopupAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
providerTypeMaps := []maps.Map{} var providerTypeMaps = []maps.Map{}
for _, providerType := range providerTypesResp.ProviderTypes { for _, providerType := range providerTypesResp.ProviderTypes {
providerTypeMaps = append(providerTypeMaps, maps.Map{ providerTypeMaps = append(providerTypeMaps, maps.Map{
"name": providerType.Name, "name": providerType.Name,
@@ -73,6 +73,7 @@ func (this *SelectPopupAction) RunPost(params struct {
}) { }) {
this.Data["domainId"] = params.DomainId this.Data["domainId"] = params.DomainId
this.Data["domainName"] = "" this.Data["domainName"] = ""
this.Data["providerName"] = ""
if params.DomainId > 0 { if params.DomainId > 0 {
domainResp, err := this.RPC().DNSDomainRPC().FindEnabledDNSDomain(this.AdminContext(), &pb.FindEnabledDNSDomainRequest{DnsDomainId: params.DomainId}) domainResp, err := this.RPC().DNSDomainRPC().FindEnabledDNSDomain(this.AdminContext(), &pb.FindEnabledDNSDomainRequest{DnsDomainId: params.DomainId})
@@ -82,6 +83,19 @@ func (this *SelectPopupAction) RunPost(params struct {
} }
if domainResp.DnsDomain != nil { if domainResp.DnsDomain != nil {
this.Data["domainName"] = domainResp.DnsDomain.Name this.Data["domainName"] = domainResp.DnsDomain.Name
// 服务商名称
var providerId = domainResp.DnsDomain.ProviderId
if providerId > 0 {
providerResp, err := this.RPC().DNSProviderRPC().FindEnabledDNSProvider(this.AdminContext(), &pb.FindEnabledDNSProviderRequest{DnsProviderId: providerId})
if err != nil {
this.ErrorPage(err)
return
}
if providerResp.DnsProvider != nil {
this.Data["providerName"] = providerResp.DnsProvider.Name
}
}
} else { } else {
this.Data["domainId"] = 0 this.Data["domainId"] = 0
} }

View File

@@ -1,5 +1,5 @@
Vue.component("dns-domain-selector", { Vue.component("dns-domain-selector", {
props: ["v-domain-id", "v-domain-name"], props: ["v-domain-id", "v-domain-name", "v-provider-name"],
data: function () { data: function () {
let domainId = this.vDomainId let domainId = this.vDomainId
if (domainId == null) { if (domainId == null) {
@@ -9,9 +9,16 @@ Vue.component("dns-domain-selector", {
if (domainName == null) { if (domainName == null) {
domainName = "" domainName = ""
} }
let providerName = this.vProviderName
if (providerName == null) {
providerName = ""
}
return { return {
domainId: domainId, domainId: domainId,
domainName: domainName domainName: domainName,
providerName: providerName
} }
}, },
methods: { methods: {
@@ -21,6 +28,7 @@ Vue.component("dns-domain-selector", {
callback: function (resp) { callback: function (resp) {
that.domainId = resp.data.domainId that.domainId = resp.data.domainId
that.domainName = resp.data.domainName that.domainName = resp.data.domainName
that.providerName = resp.data.providerName
that.change() that.change()
} }
}) })
@@ -36,6 +44,7 @@ Vue.component("dns-domain-selector", {
callback: function (resp) { callback: function (resp) {
that.domainId = resp.data.domainId that.domainId = resp.data.domainId
that.domainName = resp.data.domainName that.domainName = resp.data.domainName
that.providerName = resp.data.providerName
that.change() that.change()
} }
}) })
@@ -51,7 +60,7 @@ Vue.component("dns-domain-selector", {
<input type="hidden" name="dnsDomainId" :value="domainId"/> <input type="hidden" name="dnsDomainId" :value="domainId"/>
<div v-if="domainName.length > 0"> <div v-if="domainName.length > 0">
<span class="ui label small basic"> <span class="ui label small basic">
{{domainName}} <span v-if="providerName != null && providerName.length > 0">{{providerName}} &raquo; </span> {{domainName}}
<a href="" @click.prevent="update"><i class="icon pencil small"></i></a> <a href="" @click.prevent="update"><i class="icon pencil small"></i></a>
<a href="" @click.prevent="remove()"><i class="icon remove"></i></a> <a href="" @click.prevent="remove()"><i class="icon remove"></i></a>
</span> </span>

View File

@@ -12,7 +12,7 @@
<tr v-if="hasDomains"> <tr v-if="hasDomains">
<td>选择主域名 *</td> <td>选择主域名 *</td>
<td> <td>
<dns-domain-selector :v-domain-id="domainId" :v-domain-name="domainName" @change="changeDomain"></dns-domain-selector> <dns-domain-selector :v-domain-id="domainId" :v-domain-name="domainName" :v-provider-name="domainProvider.name" @change="changeDomain"></dns-domain-selector>
<p class="comment">用于生成集群节点和网站服务的DNS解析记录<span v-if="domainId > 0">,修改后将自动删除旧域名中的相关记录</span></p> <p class="comment">用于生成集群节点和网站服务的DNS解析记录<span v-if="domainId > 0">,修改后将自动删除旧域名中的相关记录</span></p>
</td> </td>
</tr> </tr>