mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	实现基本的集群DNS列表、设置、简单数据同步
This commit is contained in:
		@@ -306,6 +306,11 @@ func (this *RPCClient) pickConn() *grpc.ClientConn {
 | 
				
			|||||||
		if len(availableConns) > 0 {
 | 
							if len(availableConns) > 0 {
 | 
				
			||||||
			return availableConns[rands.Int(0, len(availableConns)-1)]
 | 
								return availableConns[rands.Int(0, len(availableConns)-1)]
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 关闭
 | 
				
			||||||
 | 
							for _, conn := range this.conns {
 | 
				
			||||||
 | 
								_ = conn.Close()
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 重新初始化
 | 
						// 重新初始化
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										39
									
								
								internal/web/actions/default/dns/domainOptions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								internal/web/actions/default/dns/domainOptions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					package dns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 域名列表选项
 | 
				
			||||||
 | 
					type DomainOptionsAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *DomainOptionsAction) RunPost(params struct {
 | 
				
			||||||
 | 
						ProviderId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						domainsResp, err := this.RPC().DNSDomainRPC().FindAllEnabledBasicDNSDomainsWithDNSProviderId(this.AdminContext(), &pb.FindAllEnabledBasicDNSDomainsWithDNSProviderIdRequest{
 | 
				
			||||||
 | 
							DnsProviderId: params.ProviderId,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						domainMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, domain := range domainsResp.DnsDomains {
 | 
				
			||||||
 | 
							// 未开启的先跳过
 | 
				
			||||||
 | 
							if !domain.IsOn {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							domainMaps = append(domainMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":   domain.Id,
 | 
				
			||||||
 | 
								"name": domain.Name,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["domains"] = domainMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										30
									
								
								internal/web/actions/default/dns/domains/routesPopup.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								internal/web/actions/default/dns/domains/routesPopup.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					package domains
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RoutesPopupAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *RoutesPopupAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *RoutesPopupAction) RunGet(params struct {
 | 
				
			||||||
 | 
						DomainId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						routesResp, err := this.RPC().DNSDomainRPC().FindAllDNSDomainRoutes(this.AdminContext(), &pb.FindAllDNSDomainRoutesRequest{DnsDomainId: params.DomainId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if len(routesResp.Routes) == 0 {
 | 
				
			||||||
 | 
							routesResp.Routes = []string{}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["routes"] = routesResp.Routes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										33
									
								
								internal/web/actions/default/dns/domains/sync.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								internal/web/actions/default/dns/domains/sync.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package domains
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SyncAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *SyncAction) RunPost(params struct {
 | 
				
			||||||
 | 
						DomainId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// 记录日志
 | 
				
			||||||
 | 
						this.CreateLog(oplogs.LevelInfo, "同步DNS域名数据 %d", params.DomainId)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 执行同步
 | 
				
			||||||
 | 
						resp, err := this.RPC().DNSDomainRPC().SyncDNSDomainData(this.AdminContext(), &pb.SyncDNSDomainDataRequest{DnsDomainId: params.DomainId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if resp.IsOk {
 | 
				
			||||||
 | 
							this.Success()
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							this.Data["shouldFix"] = resp.ShouldFix
 | 
				
			||||||
 | 
							this.Fail(resp.Error)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,6 +1,14 @@
 | 
				
			|||||||
package domains
 | 
					package domains
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type UpdatePopupAction struct {
 | 
					type UpdatePopupAction struct {
 | 
				
			||||||
	actionutils.ParentAction
 | 
						actionutils.ParentAction
 | 
				
			||||||
@@ -10,6 +18,62 @@ func (this *UpdatePopupAction) Init() {
 | 
				
			|||||||
	this.Nav("", "", "")
 | 
						this.Nav("", "", "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *UpdatePopupAction) RunGet(params struct{}) {
 | 
					func (this *UpdatePopupAction) RunGet(params struct {
 | 
				
			||||||
 | 
						DomainId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						domainResp, err := this.RPC().DNSDomainRPC().FindEnabledDNSDomain(this.AdminContext(), &pb.FindEnabledDNSDomainRequest{DnsDomainId: params.DomainId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						domain := domainResp.DnsDomain
 | 
				
			||||||
 | 
						if domain == nil {
 | 
				
			||||||
 | 
							this.NotFound("dnsDomain", params.DomainId)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["domain"] = maps.Map{
 | 
				
			||||||
 | 
							"id":   domain.Id,
 | 
				
			||||||
 | 
							"name": domain.Name,
 | 
				
			||||||
 | 
							"isOn": domain.IsOn,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdatePopupAction) RunPost(params struct {
 | 
				
			||||||
 | 
						DomainId int64
 | 
				
			||||||
 | 
						Name     string
 | 
				
			||||||
 | 
						IsOn     bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
						CSRF *actionutils.CSRF
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 检查DomainId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 记录日志
 | 
				
			||||||
 | 
						this.CreateLog(oplogs.LevelInfo, "修改管理域名到DNS服务商 %d", params.DomainId)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						params.Must.
 | 
				
			||||||
 | 
							Field("name", params.Name).
 | 
				
			||||||
 | 
							Require("请输入域名")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 校验域名
 | 
				
			||||||
 | 
						domain := strings.ToLower(params.Name)
 | 
				
			||||||
 | 
						domain = strings.Replace(domain, " ", "", -1)
 | 
				
			||||||
 | 
						if !domainutils.ValidateDomainFormat(domain) {
 | 
				
			||||||
 | 
							this.Fail("域名格式不正确,请修改后重新提交")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().DNSDomainRPC().UpdateDNSDomain(this.AdminContext(), &pb.UpdateDNSDomainRequest{
 | 
				
			||||||
 | 
							DnsDomainId: params.DomainId,
 | 
				
			||||||
 | 
							Name:        domain,
 | 
				
			||||||
 | 
							IsOn:        params.IsOn,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,10 @@
 | 
				
			|||||||
package dns
 | 
					package dns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type IndexAction struct {
 | 
					type IndexAction struct {
 | 
				
			||||||
	actionutils.ParentAction
 | 
						actionutils.ParentAction
 | 
				
			||||||
@@ -11,5 +15,66 @@ func (this *IndexAction) Init() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *IndexAction) RunGet(params struct{}) {
 | 
					func (this *IndexAction) RunGet(params struct{}) {
 | 
				
			||||||
 | 
						countResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClusters(this.AdminContext(), &pb.CountAllEnabledNodeClustersRequest{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						page := this.NewPage(countResp.Count)
 | 
				
			||||||
 | 
						this.Data["page"] = page.AsHTML()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						clustersResp, err := this.RPC().NodeClusterRPC().ListEnabledNodeClusters(this.AdminContext(), &pb.ListEnabledNodeClustersRequest{
 | 
				
			||||||
 | 
							Offset: page.Offset,
 | 
				
			||||||
 | 
							Size:   page.Size,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						clusterMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, cluster := range clustersResp.Clusters {
 | 
				
			||||||
 | 
							domainId := cluster.DnsDomainId
 | 
				
			||||||
 | 
							domainName := ""
 | 
				
			||||||
 | 
							providerId := int64(0)
 | 
				
			||||||
 | 
							providerName := ""
 | 
				
			||||||
 | 
							providerTypeName := ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if cluster.DnsDomainId > 0 {
 | 
				
			||||||
 | 
								domainResp, err := this.RPC().DNSDomainRPC().FindEnabledBasicDNSDomain(this.AdminContext(), &pb.FindEnabledBasicDNSDomainRequest{DnsDomainId: domainId})
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									this.ErrorPage(err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								domain := domainResp.DnsDomain
 | 
				
			||||||
 | 
								if domain == nil {
 | 
				
			||||||
 | 
									domainId = 0
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									domainName = domain.Name
 | 
				
			||||||
 | 
									providerResp, err := this.RPC().DNSProviderRPC().FindEnabledDNSProvider(this.AdminContext(), &pb.FindEnabledDNSProviderRequest{DnsProviderId: domain.ProviderId})
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										this.ErrorPage(err)
 | 
				
			||||||
 | 
										return
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if providerResp.DnsProvider != nil {
 | 
				
			||||||
 | 
										providerId = providerResp.DnsProvider.Id
 | 
				
			||||||
 | 
										providerName = providerResp.DnsProvider.Name
 | 
				
			||||||
 | 
										providerTypeName = providerResp.DnsProvider.TypeName
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							clusterMaps = append(clusterMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":               cluster.Id,
 | 
				
			||||||
 | 
								"name":             cluster.Name,
 | 
				
			||||||
 | 
								"dnsName":          cluster.DnsName,
 | 
				
			||||||
 | 
								"domainId":         domainId,
 | 
				
			||||||
 | 
								"domainName":       domainName,
 | 
				
			||||||
 | 
								"providerId":       providerId,
 | 
				
			||||||
 | 
								"providerName":     providerName,
 | 
				
			||||||
 | 
								"providerTypeName": providerTypeName,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["clusters"] = clusterMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package dns
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/issues"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/providers"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/providers"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
	"github.com/iwind/TeaGo"
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
@@ -14,6 +15,9 @@ func init() {
 | 
				
			|||||||
			Helper(new(Helper)).
 | 
								Helper(new(Helper)).
 | 
				
			||||||
			Prefix("/dns").
 | 
								Prefix("/dns").
 | 
				
			||||||
			Get("", new(IndexAction)).
 | 
								Get("", new(IndexAction)).
 | 
				
			||||||
 | 
								GetPost("/updateClusterPopup", new(UpdateClusterPopupAction)).
 | 
				
			||||||
 | 
								Post("/providerOptions", new(ProviderOptionsAction)).
 | 
				
			||||||
 | 
								Post("/domainOptions", new(DomainOptionsAction)).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 服务商
 | 
								// 服务商
 | 
				
			||||||
			Prefix("/dns/providers").
 | 
								Prefix("/dns/providers").
 | 
				
			||||||
@@ -31,6 +35,14 @@ func init() {
 | 
				
			|||||||
			GetPost("/createPopup", new(domains.CreatePopupAction)).
 | 
								GetPost("/createPopup", new(domains.CreatePopupAction)).
 | 
				
			||||||
			GetPost("/updatePopup", new(domains.UpdatePopupAction)).
 | 
								GetPost("/updatePopup", new(domains.UpdatePopupAction)).
 | 
				
			||||||
			Post("/delete", new(domains.DeleteAction)).
 | 
								Post("/delete", new(domains.DeleteAction)).
 | 
				
			||||||
 | 
								Post("/sync", new(domains.SyncAction)).
 | 
				
			||||||
 | 
								Get("/routesPopup", new(domains.RoutesPopupAction)).
 | 
				
			||||||
 | 
								EndData().
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 问题修复
 | 
				
			||||||
 | 
								Prefix("/dns/issues").
 | 
				
			||||||
 | 
								Data("teaSubMenu", "issue").
 | 
				
			||||||
 | 
								Get("", new(issues.IndexAction)).
 | 
				
			||||||
			EndData().
 | 
								EndData().
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			EndAll()
 | 
								EndAll()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								internal/web/actions/default/dns/issues/index.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								internal/web/actions/default/dns/issues/index.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					package issues
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct{}) {
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										32
									
								
								internal/web/actions/default/dns/providerOptions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								internal/web/actions/default/dns/providerOptions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					package dns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 服务商选项
 | 
				
			||||||
 | 
					type ProviderOptionsAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *ProviderOptionsAction) RunPost(params struct {
 | 
				
			||||||
 | 
						Type string
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						providersResp, err := this.RPC().DNSProviderRPC().FindAllEnabledDNSProvidersWithType(this.AdminContext(), &pb.FindAllEnabledDNSProvidersWithTypeRequest{ProviderTypeCode: params.Type})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						providerMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, provider := range providersResp.DnsProviders {
 | 
				
			||||||
 | 
							providerMaps = append(providerMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":   provider.Id,
 | 
				
			||||||
 | 
								"name": provider.Name,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["providers"] = providerMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -60,10 +60,15 @@ func (this *ProviderAction) RunGet(params struct {
 | 
				
			|||||||
			dataUpdatedTime = timeutil.FormatTime("Y-m-d H:i:s", domain.DataUpdatedAt)
 | 
								dataUpdatedTime = timeutil.FormatTime("Y-m-d H:i:s", domain.DataUpdatedAt)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		domainMaps = append(domainMaps, maps.Map{
 | 
							domainMaps = append(domainMaps, maps.Map{
 | 
				
			||||||
			"id":              domain.Id,
 | 
								"id":                  domain.Id,
 | 
				
			||||||
			"name":            domain.Name,
 | 
								"name":                domain.Name,
 | 
				
			||||||
			"isOn":            domain.IsOn,
 | 
								"isOn":                domain.IsOn,
 | 
				
			||||||
			"dataUpdatedTime": dataUpdatedTime,
 | 
								"dataUpdatedTime":     dataUpdatedTime,
 | 
				
			||||||
 | 
								"countRoutes":         len(domain.Routes),
 | 
				
			||||||
 | 
								"countServerRecords":  domain.ServerRecords,
 | 
				
			||||||
 | 
								"allServersResolved":  domain.AllServersResolved,
 | 
				
			||||||
 | 
								"countClusterRecords": domain.ClusterRecords,
 | 
				
			||||||
 | 
								"allClustersResolved": domain.AllClustersResolved,
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	this.Data["domains"] = domainMaps
 | 
						this.Data["domains"] = domainMaps
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										103
									
								
								internal/web/actions/default/dns/updateClusterPopup.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								internal/web/actions/default/dns/updateClusterPopup.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,103 @@
 | 
				
			|||||||
 | 
					package dns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 修改集群的DNS设置
 | 
				
			||||||
 | 
					type UpdateClusterPopupAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdateClusterPopupAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdateClusterPopupAction) RunGet(params struct {
 | 
				
			||||||
 | 
						ClusterId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						this.Data["clusterId"] = params.ClusterId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dnsResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterDNS(this.AdminContext(), &pb.FindEnabledNodeClusterDNSRequest{NodeClusterId: params.ClusterId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["dnsName"] = dnsResp.Name
 | 
				
			||||||
 | 
						if dnsResp.Domain != nil {
 | 
				
			||||||
 | 
							this.Data["domainId"] = dnsResp.Domain.Id
 | 
				
			||||||
 | 
							this.Data["domain"] = dnsResp.Domain.Name
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							this.Data["domainId"] = 0
 | 
				
			||||||
 | 
							this.Data["domain"] = ""
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if dnsResp.Provider != nil {
 | 
				
			||||||
 | 
							this.Data["providerType"] = dnsResp.Provider.Type
 | 
				
			||||||
 | 
							this.Data["providerId"] = dnsResp.Provider.Id
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							this.Data["providerType"] = ""
 | 
				
			||||||
 | 
							this.Data["providerId"] = 0
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 所有服务商
 | 
				
			||||||
 | 
						providerTypesResp, err := this.RPC().DNSProviderRPC().FindAllDNSProviderTypes(this.AdminContext(), &pb.FindAllDNSProviderTypesRequest{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						providerTypeMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, providerType := range providerTypesResp.ProviderTypes {
 | 
				
			||||||
 | 
							providerTypeMaps = append(providerTypeMaps, maps.Map{
 | 
				
			||||||
 | 
								"name": providerType.Name,
 | 
				
			||||||
 | 
								"code": providerType.Code,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["providerTypes"] = providerTypeMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdateClusterPopupAction) RunPost(params struct {
 | 
				
			||||||
 | 
						ClusterId int64
 | 
				
			||||||
 | 
						DnsName   string
 | 
				
			||||||
 | 
						DomainId  int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
						CSRF *actionutils.CSRF
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						params.Must.
 | 
				
			||||||
 | 
							Field("dnsName", params.DnsName).
 | 
				
			||||||
 | 
							Require("请输入子域名")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if !domainutils.ValidateDomainFormat(params.DnsName) {
 | 
				
			||||||
 | 
							this.FailField("dnsName", "子域名格式错误")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						checkResp, err := this.RPC().NodeClusterRPC().CheckNodeClusterDNSName(this.AdminContext(), &pb.CheckNodeClusterDNSNameRequest{
 | 
				
			||||||
 | 
							NodeClusterId: params.ClusterId,
 | 
				
			||||||
 | 
							DnsName:       params.DnsName,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if checkResp.IsUsed {
 | 
				
			||||||
 | 
							this.FailField("dnsName", "此子域名已经被占用,请修改后重新提交")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = this.RPC().NodeClusterRPC().UpdateNodeClusterDNS(this.AdminContext(), &pb.UpdateNodeClusterDNSRequest{
 | 
				
			||||||
 | 
							NodeClusterId: params.ClusterId,
 | 
				
			||||||
 | 
							DnsName:       params.DnsName,
 | 
				
			||||||
 | 
							DnsDomainId:   params.DomainId,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -109,6 +109,11 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
 | 
				
			|||||||
			"name": "域名解析",
 | 
								"name": "域名解析",
 | 
				
			||||||
			"icon": "globe",
 | 
								"icon": "globe",
 | 
				
			||||||
			"subItems": []maps.Map{
 | 
								"subItems": []maps.Map{
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"name": "问题修复",
 | 
				
			||||||
 | 
										"url":  "/dns/issues",
 | 
				
			||||||
 | 
										"code": "issue",
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"name": "DNS服务商",
 | 
										"name": "DNS服务商",
 | 
				
			||||||
					"url":  "/dns/providers",
 | 
										"url":  "/dns/providers",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -684,9 +684,6 @@ var.dash {
 | 
				
			|||||||
.swal2-cancel {
 | 
					.swal2-cancel {
 | 
				
			||||||
  margin-left: 2em !important;
 | 
					  margin-left: 2em !important;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
form .fields {
 | 
					 | 
				
			||||||
  margin-bottom: 0 !important;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/** 排序 **/
 | 
					/** 排序 **/
 | 
				
			||||||
.sortable-ghost {
 | 
					.sortable-ghost {
 | 
				
			||||||
  background: #ddd !important;
 | 
					  background: #ddd !important;
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -746,13 +746,6 @@ var.dash {
 | 
				
			|||||||
	margin-left: 2em !important;
 | 
						margin-left: 2em !important;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// fields
 | 
					 | 
				
			||||||
form {
 | 
					 | 
				
			||||||
	.fields {
 | 
					 | 
				
			||||||
		margin-bottom: 0 !important;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** 排序 **/
 | 
					/** 排序 **/
 | 
				
			||||||
.sortable-ghost {
 | 
					.sortable-ghost {
 | 
				
			||||||
	background: #ddd !important;
 | 
						background: #ddd !important;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,4 +9,7 @@
 | 
				
			|||||||
.ui.label.basic {
 | 
					.ui.label.basic {
 | 
				
			||||||
  background-color: white !important;
 | 
					  background-color: white !important;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					form .fields {
 | 
				
			||||||
 | 
					  margin-bottom: 0 !important;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
/*# sourceMappingURL=@layout_override.css.map */
 | 
					/*# sourceMappingURL=@layout_override.css.map */
 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
{"version":3,"sources":["@layout_override.less"],"names":[],"mappings":"AACA,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,QAAO;EACrG,oCAAA;;AAGD,GAAG,OAAO,SAAU,MAAK,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,QAAS,QAAO;EACzF,oCAAA;;AAGD,GAAG,MAAM;EACR,kCAAA","file":"@layout_override.css"}
 | 
					{"version":3,"sources":["@layout_override.less"],"names":[],"mappings":"AACA,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,QAAO;EACrG,oCAAA;;AAGD,GAAG,OAAO,SAAU,MAAK,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,QAAS,QAAO;EACzF,oCAAA;;AAGD,GAAG,MAAM;EACR,kCAAA;;AAID,IACC;EACC,2BAAA","file":"@layout_override.css"}
 | 
				
			||||||
@@ -9,4 +9,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
.ui.label.basic {
 | 
					.ui.label.basic {
 | 
				
			||||||
	background-color: white !important;
 | 
						background-color: white !important;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// fields
 | 
				
			||||||
 | 
					form {
 | 
				
			||||||
 | 
						.fields {
 | 
				
			||||||
 | 
							margin-bottom: 0 !important;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								web/views/@default/dns/domains/routesPopup.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								web/views/@default/dns/domains/routesPopup.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>域名支持的线路</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<table class="ui table definition selectable">
 | 
				
			||||||
 | 
						<tr>
 | 
				
			||||||
 | 
							<td class="title">线路</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<p class="comment" v-if="routes.length == 0">暂时还没有支持的线路。</p>
 | 
				
			||||||
 | 
								<div v-if="routes.length > 0">
 | 
				
			||||||
 | 
									<div class="ui label tiny" v-for="route in routes" style="margin-bottom: 0.5em">{{route}}</div>
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<button class="ui button primary" @click.prevent="close" type="button">确定</button>
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/views/@default/dns/domains/routesPopup.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/views/@default/dns/domains/routesPopup.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.close = NotifyPopup
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										33
									
								
								web/views/@default/dns/domains/updatePopup.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								web/views/@default/dns/domains/updatePopup.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>添加管理域名</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<input type="hidden" name="domainId" :value="domain.id"/>
 | 
				
			||||||
 | 
						<csrf-token></csrf-token>
 | 
				
			||||||
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">域名 *</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="name" maxlength="64" ref="focus" v-model="domain.name"/>
 | 
				
			||||||
 | 
									<p class="comment">在DNS服务商中可以管理的域名。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td colspan="2"><more-options-indicator></more-options-indicator></td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tbody v-show="moreOptionsVisible">
 | 
				
			||||||
 | 
								<tr>
 | 
				
			||||||
 | 
									<td>是否启用</td>
 | 
				
			||||||
 | 
									<td>
 | 
				
			||||||
 | 
										<div class="ui checkbox">
 | 
				
			||||||
 | 
											<input type="checkbox" name="isOn" value="1" v-model="domain.isOn"/>
 | 
				
			||||||
 | 
											<label></label>
 | 
				
			||||||
 | 
										</div>
 | 
				
			||||||
 | 
									</td>
 | 
				
			||||||
 | 
								</tr>
 | 
				
			||||||
 | 
							</tbody>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/views/@default/dns/domains/updatePopup.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/views/@default/dns/domains/updatePopup.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										4
									
								
								web/views/@default/dns/index.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								web/views/@default/dns/index.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					.italic {
 | 
				
			||||||
 | 
					  font-style: italic !important;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					/*# sourceMappingURL=index.css.map */
 | 
				
			||||||
							
								
								
									
										1
									
								
								web/views/@default/dns/index.css.map
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								web/views/@default/dns/index.css.map
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA;EACC,6BAAA","file":"index.css"}
 | 
				
			||||||
@@ -1,3 +1,39 @@
 | 
				
			|||||||
{$layout}
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p class="ui message">此功能暂未开放,敬请期待。</p>
 | 
					<div class="margin"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p class="comment" v-if="clusters.length == 0">暂时还没有集群。</p>
 | 
				
			||||||
 | 
					<table class="ui table selectable" v-if="clusters.length > 0">
 | 
				
			||||||
 | 
						<thead>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<th>集群</th>
 | 
				
			||||||
 | 
								<th>域名解析</th>
 | 
				
			||||||
 | 
								<th>DNS服务商</th>
 | 
				
			||||||
 | 
								<th>DNS服务商账号</th>
 | 
				
			||||||
 | 
								<th class="two op">操作</th>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</thead>
 | 
				
			||||||
 | 
						<tr v-for="cluster in clusters">
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a :href="'/clusters/cluster?clusterId=' + cluster.id">{{cluster.name}}</a>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<span v-if="cluster.dnsName.length > 0 && cluster.domainName.length > 0"><em class="italic">{{cluster.dnsName}}</em>.{{cluster.domainName}}</span>
 | 
				
			||||||
 | 
								<span v-else="" class="disabled">-</span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<span v-if="cluster.providerTypeName.length > 0">{{cluster.providerTypeName}}</span>
 | 
				
			||||||
 | 
								<span v-else class="disabled">-</span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a v-if="cluster.providerName.length > 0" :href="'/dns/providers/provider?providerId=' + cluster.providerId">{{cluster.providerName}}</a>
 | 
				
			||||||
 | 
								<span v-else="" class="disabled">-</span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a href="" @click.prevent="updateCluster(cluster.id)">修改</a>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					<p class="comment">这里列出了所有集群对应的域名设置。</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="page" v-html="page"></div>
 | 
				
			||||||
							
								
								
									
										12
									
								
								web/views/@default/dns/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								web/views/@default/dns/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.updateCluster = function (clusterId) {
 | 
				
			||||||
 | 
							teaweb.popup("/dns/updateClusterPopup?clusterId=" + clusterId, {
 | 
				
			||||||
 | 
								height: "22em",
 | 
				
			||||||
 | 
								callback: function () {
 | 
				
			||||||
 | 
									teaweb.success("保存成功", function () {
 | 
				
			||||||
 | 
										teaweb.reload()
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/views/@default/dns/index.less
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/views/@default/dns/index.less
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					.italic {
 | 
				
			||||||
 | 
						font-style: italic !important;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/views/@default/dns/issues/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/views/@default/dns/issues/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p class="ui message">此功能暂未开放,敬请期待。</p>
 | 
				
			||||||
@@ -39,21 +39,46 @@
 | 
				
			|||||||
	<thead>
 | 
						<thead>
 | 
				
			||||||
		<tr>
 | 
							<tr>
 | 
				
			||||||
			<th>域名</th>
 | 
								<th>域名</th>
 | 
				
			||||||
 | 
								<th>线路</th>
 | 
				
			||||||
 | 
								<th>集群域名</th>
 | 
				
			||||||
 | 
								<th>服务域名</th>
 | 
				
			||||||
			<th>数据更新时间</th>
 | 
								<th>数据更新时间</th>
 | 
				
			||||||
			<th>状态</th>
 | 
								<th>状态</th>
 | 
				
			||||||
			<th class="two op">操作</th>
 | 
								<th class="three op">操作</th>
 | 
				
			||||||
		</tr>
 | 
							</tr>
 | 
				
			||||||
	</thead>
 | 
						</thead>
 | 
				
			||||||
	<tr v-for="domain in domains">
 | 
						<tr v-for="(domain, index) in domains">
 | 
				
			||||||
		<td>{{domain.name}}</td>
 | 
							<td>{{domain.name}}</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a href="" v-if="domain.countRoutes > 0" @click.prevent="showRoutes(domain.id)">{{domain.countRoutes}}个</a>
 | 
				
			||||||
 | 
								<span v-else class="disabled">0个</span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a href="" v-if="domain.countClusterRecords > 0">{{domain.countClusterRecords}}个</a>
 | 
				
			||||||
 | 
								<span v-else class="disabled">0个</span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a href="" v-if="domain.countServerRecords > 0">{{domain.countServerRecords}}个</a>
 | 
				
			||||||
 | 
								<span v-else class="disabled">0个</span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
		<td>
 | 
							<td>
 | 
				
			||||||
			<span v-if="domain.dataUpdatedTime.length > 0">{{domain.dataUpdatedTime}}</span>
 | 
								<span v-if="domain.dataUpdatedTime.length > 0">{{domain.dataUpdatedTime}}</span>
 | 
				
			||||||
			<span v-else class="disabled">尚未更新</span>
 | 
								<span v-else class="disabled">尚未更新</span>
 | 
				
			||||||
		</td>
 | 
							</td>
 | 
				
			||||||
		<td><label-on :v-is-on="domain.isOn"></label-on></td>
 | 
					 | 
				
			||||||
		<td>
 | 
							<td>
 | 
				
			||||||
			<a href="">修改</a>  
 | 
								<div v-if="domain.countRoutes == 0 || !domain.allClustersResolved || !domain.allServersResolved">
 | 
				
			||||||
			<a href="" @click.prevent="deleteDomain(domain)">删除</a>
 | 
									<a href=""  style="border-bottom: 1px #db2828 dashed" title="点击和DNS服务商系统同步" @click.prevent="syncDomain(index,domain)" v-if="!domain.isSyncing"><span class="red">需要同步</span></a>
 | 
				
			||||||
 | 
									<span v-else>正在同步...</span>
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
								<div v-else>
 | 
				
			||||||
 | 
									<label-on :v-is-on="domain.isOn"></label-on>
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
							<td>
 | 
				
			||||||
 | 
								<a href="" @click.prevent="syncDomain(index, domain)" v-if="!domain.isSyncing">同步</a>
 | 
				
			||||||
 | 
								<span v-else>正在同步...</span> 
 | 
				
			||||||
 | 
								<a href="" @click.prevent="updateDomain(domain.id)" v-if="!domain.isSyncing">修改</a>  
 | 
				
			||||||
 | 
								<a href="" @click.prevent="deleteDomain(domain)" v-if="!domain.isSyncing">删除</a>
 | 
				
			||||||
		</td>
 | 
							</td>
 | 
				
			||||||
	</tr>
 | 
						</tr>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
@@ -20,6 +20,16 @@ Tea.context(function () {
 | 
				
			|||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.updateDomain = function (domainId) {
 | 
				
			||||||
 | 
							teaweb.popup("/dns/domains/updatePopup?domainId=" + domainId, {
 | 
				
			||||||
 | 
								callback: function () {
 | 
				
			||||||
 | 
									teaweb.success("保存成功", function () {
 | 
				
			||||||
 | 
										teaweb.reload()
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.deleteDomain = function (domain) {
 | 
						this.deleteDomain = function (domain) {
 | 
				
			||||||
		let that = this
 | 
							let that = this
 | 
				
			||||||
		teaweb.confirm("确定要删除域名\"" + domain.name + "\"吗?", function () {
 | 
							teaweb.confirm("确定要删除域名\"" + domain.name + "\"吗?", function () {
 | 
				
			||||||
@@ -31,4 +41,34 @@ Tea.context(function () {
 | 
				
			|||||||
				.refresh()
 | 
									.refresh()
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.syncDomain = function (index, domain) {
 | 
				
			||||||
 | 
							domain.isSyncing = true
 | 
				
			||||||
 | 
							Vue.set(this.domains, index, domain)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.$post("/dns/domains/sync")
 | 
				
			||||||
 | 
								.params({
 | 
				
			||||||
 | 
									domainId: domain.id
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.success(function () {
 | 
				
			||||||
 | 
									teaweb.success("同步成功", function () {
 | 
				
			||||||
 | 
										teaweb.reload()
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.fail(function (resp) {
 | 
				
			||||||
 | 
									teaweb.warn(resp.message, function () {
 | 
				
			||||||
 | 
										if (resp.data.shouldFix) {
 | 
				
			||||||
 | 
											window.location = "/dns/issues"
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.done(function () {
 | 
				
			||||||
 | 
									domain.isSyncing = false
 | 
				
			||||||
 | 
									Vue.set(this.domains, index, domain)
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.showRoutes = function (domainId) {
 | 
				
			||||||
 | 
							teaweb.popup("/dns/domains/routesPopup?domainId=" + domainId)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
							
								
								
									
										49
									
								
								web/views/@default/dns/updateClusterPopup.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								web/views/@default/dns/updateClusterPopup.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>修改集群DNS设置</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form method="post" class="ui form" data-tea-success="success" data-tea-action="$">
 | 
				
			||||||
 | 
						<input type="hidden" name="clusterId" :value="clusterId"/>
 | 
				
			||||||
 | 
						<csrf-token></csrf-token>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">DNS服务商</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<select name="providerType" class="ui dropdown auto-width" v-model="providerType" @change="changeProviderType">
 | 
				
			||||||
 | 
										<option v-for="providerType in providerTypes" :value="providerType.code">{{providerType.name}}</option>
 | 
				
			||||||
 | 
									</select>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>账号</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<p class="comment" v-if="providers.length == 0">没有账号可选</p>
 | 
				
			||||||
 | 
									<select name="providerId" class="ui dropdown auto-width" v-model="providerId" v-show="providers.length > 0">
 | 
				
			||||||
 | 
										<option v-for="provider in providers" :value="provider.id">{{provider.name}}</option>
 | 
				
			||||||
 | 
									</select>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr v-show="providerId > 0">
 | 
				
			||||||
 | 
								<td>域名</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<p class="comment" v-if="domains.length == 0">没有域名可选</p>
 | 
				
			||||||
 | 
									<select name="domainId" class="ui dropdown auto-width" v-model="domainId" v-show="domains.length > 0">
 | 
				
			||||||
 | 
										<option v-for="domain in domains" :value="domain.id">{{domain.name}}</option>
 | 
				
			||||||
 | 
									</select>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>子域名</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<div class="ui input right labeled">
 | 
				
			||||||
 | 
										<input type="text" name="dnsName" v-model="dnsName" maxlength="64" size="20" style="width:10em"/>
 | 
				
			||||||
 | 
										<span class="ui label">.<span v-if="domain.length == 0">主域名</span><span v-else>{{domain}}</span></span>
 | 
				
			||||||
 | 
									</div>
 | 
				
			||||||
 | 
									<p class="comment">子域名和主域名共同组成集群的域名。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
							
								
								
									
										80
									
								
								web/views/@default/dns/updateClusterPopup.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								web/views/@default/dns/updateClusterPopup.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.$delay(function () {
 | 
				
			||||||
 | 
							this.changeProviderType()
 | 
				
			||||||
 | 
							this.changeProvider()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.$watch("providerId", function () {
 | 
				
			||||||
 | 
								this.changeProvider()
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							this.$watch("domainId", function () {
 | 
				
			||||||
 | 
								this.changeDomain()
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 初始化的内容
 | 
				
			||||||
 | 
						// this.domainId = 0
 | 
				
			||||||
 | 
						// this.domain = ""
 | 
				
			||||||
 | 
						// this.providerId = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (this.providerType == "") {
 | 
				
			||||||
 | 
							this.providerType = this.providerTypes[0].code
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.providers = []
 | 
				
			||||||
 | 
						this.domains = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.changeProviderType = function () {
 | 
				
			||||||
 | 
							this.$post(".providerOptions")
 | 
				
			||||||
 | 
								.params({
 | 
				
			||||||
 | 
									type: this.providerType
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.success(function (resp) {
 | 
				
			||||||
 | 
									this.providers = resp.data.providers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									// 检查providerId
 | 
				
			||||||
 | 
									if (this.providers.length == 0) {
 | 
				
			||||||
 | 
										this.providerId = 0
 | 
				
			||||||
 | 
										return
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									let that = this
 | 
				
			||||||
 | 
									if (this.providers.$find(function (k, v) {
 | 
				
			||||||
 | 
										return v.id == that.providerId
 | 
				
			||||||
 | 
									}) == null) {
 | 
				
			||||||
 | 
										this.providerId = this.providers[0].id
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									this.changeProvider()
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.changeProvider = function () {
 | 
				
			||||||
 | 
							this.$post(".domainOptions")
 | 
				
			||||||
 | 
								.params({
 | 
				
			||||||
 | 
									providerId: this.providerId
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.success(function (resp) {
 | 
				
			||||||
 | 
									this.domains = resp.data.domains
 | 
				
			||||||
 | 
									this.changeDomain()
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.changeDomain = function () {
 | 
				
			||||||
 | 
							if (this.domains.length == 0) {
 | 
				
			||||||
 | 
								this.domainId = 0
 | 
				
			||||||
 | 
								this.domain = ""
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							let domainId = this.domainId
 | 
				
			||||||
 | 
							let domainInfo = this.domains.$find(function (k, v) {
 | 
				
			||||||
 | 
								return v.id == domainId
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							if (domainInfo == null) {
 | 
				
			||||||
 | 
								// 默认选取第一个
 | 
				
			||||||
 | 
								this.domainId = this.domains[0].id
 | 
				
			||||||
 | 
								this.domain = this.domains[0].name
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								this.domain = domainInfo.name
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
		Reference in New Issue
	
	Block a user