diff --git a/internal/web/actions/default/dns/clusters/cluster.go b/internal/web/actions/default/dns/clusters/cluster.go index c9344a6e..300ca285 100644 --- a/internal/web/actions/default/dns/clusters/cluster.go +++ b/internal/web/actions/default/dns/clusters/cluster.go @@ -25,7 +25,7 @@ func (this *ClusterAction) RunGet(params struct { this.ErrorPage(err) return } - cluster := clusterResp.NodeCluster + var cluster = clusterResp.NodeCluster if cluster == nil { this.NotFound("nodeCluster", params.ClusterId) return @@ -42,7 +42,7 @@ func (this *ClusterAction) RunGet(params struct { return } var defaultRoute = dnsResp.DefaultRoute - domainName := "" + var domainName = "" var dnsMap = maps.Map{ "dnsName": dnsResp.Name, "domainId": 0, @@ -70,19 +70,42 @@ func (this *ClusterAction) RunGet(params struct { this.Data["dnsInfo"] = dnsMap - // 节点DNS解析记录 - nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{NodeClusterId: params.ClusterId}) + // 未安装的节点 + notInstalledNodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{ + NodeClusterId: params.ClusterId, + IsInstalled: false, + }) if err != nil { this.ErrorPage(err) return } - var nodeMaps = []maps.Map{} + var allNodes = notInstalledNodesResp.Nodes + + // 节点DNS解析记录 + nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{ + NodeClusterId: params.ClusterId, + IsInstalled: true, + }) + if err != nil { + this.ErrorPage(err) + return + } + var installedNodeIdsMap = map[int64]bool{} for _, node := range nodesResp.Nodes { + installedNodeIdsMap[node.Id] = true + } + + allNodes = append(allNodes, nodesResp.Nodes...) + + var nodeMaps = []maps.Map{} + for _, node := range allNodes { + var isInstalled = installedNodeIdsMap[node.Id] + if len(node.Routes) > 0 { for _, route := range node.Routes { // 检查是否已解析 var isResolved = false - if cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 { + if isInstalled && cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 { var recordType = "A" if utils.IsIPv6(node.IpAddr) { recordType = "AAAA" @@ -110,14 +133,15 @@ func (this *ClusterAction) RunGet(params struct { "name": route.Name, "code": route.Code, }, - "clusterId": node.NodeClusterId, - "isResolved": isResolved, + "clusterId": node.NodeClusterId, + "isResolved": isResolved, + "isInstalled": isInstalled, }) } } else { // 默认线路 var isResolved = false - if len(defaultRoute) > 0 { + if isInstalled && len(defaultRoute) > 0 { var recordType = "A" if utils.IsIPv6(node.IpAddr) { recordType = "AAAA" @@ -144,8 +168,9 @@ func (this *ClusterAction) RunGet(params struct { "name": "", "code": "", }, - "clusterId": node.NodeClusterId, - "isResolved": isResolved, + "clusterId": node.NodeClusterId, + "isResolved": isResolved, + "isInstalled": isInstalled, }) } } diff --git a/internal/web/actions/default/dns/domains/nodesPopup.go b/internal/web/actions/default/dns/domains/nodesPopup.go index 8bfdc276..c277c51f 100644 --- a/internal/web/actions/default/dns/domains/nodesPopup.go +++ b/internal/web/actions/default/dns/domains/nodesPopup.go @@ -18,6 +18,8 @@ func (this *NodesPopupAction) Init() { func (this *NodesPopupAction) RunGet(params struct { DomainId int64 }) { + this.Data["domainId"] = params.DomainId + // 域名信息 domainResp, err := this.RPC().DNSDomainRPC().FindBasicDNSDomain(this.AdminContext(), &pb.FindBasicDNSDomainRequest{ DnsDomainId: params.DomainId, @@ -26,7 +28,7 @@ func (this *NodesPopupAction) RunGet(params struct { this.ErrorPage(err) return } - domain := domainResp.DnsDomain + var domain = domainResp.DnsDomain if domain == nil { this.NotFound("dnsDomain", params.DomainId) return @@ -35,7 +37,7 @@ func (this *NodesPopupAction) RunGet(params struct { this.Data["domain"] = domain.Name // 集群 - clusterMaps := []maps.Map{} + var clusterMaps = []maps.Map{} clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithDNSDomainId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithDNSDomainIdRequest{DnsDomainId: params.DomainId}) if err != nil { this.ErrorPage(err) @@ -43,18 +45,24 @@ func (this *NodesPopupAction) RunGet(params struct { } for _, cluster := range clustersResp.NodeClusters { + // 默认值 + var defaultRoute = cluster.DnsDefaultRoute + // 节点DNS解析记录 - nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{NodeClusterId: cluster.Id}) + nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{ + NodeClusterId: cluster.Id, + IsInstalled: true, + }) if err != nil { this.ErrorPage(err) return } - nodeMaps := []maps.Map{} + var nodeMaps = []maps.Map{} for _, node := range nodesResp.Nodes { if len(node.Routes) > 0 { for _, route := range node.Routes { // 检查是否有域名解析记录 - isOk := false + var isResolved = false if len(route.Name) > 0 && len(node.IpAddr) > 0 && len(cluster.DnsName) > 0 { var recordType = "A" if utils.IsIPv6(node.IpAddr) { @@ -71,7 +79,7 @@ func (this *NodesPopupAction) RunGet(params struct { this.ErrorPage(err) return } - isOk = checkResp.IsOk + isResolved = checkResp.IsOk } nodeMaps = append(nodeMaps, maps.Map{ @@ -83,10 +91,30 @@ func (this *NodesPopupAction) RunGet(params struct { "code": route.Code, }, "clusterId": node.NodeClusterId, - "isOk": isOk, + "isOk": isResolved, }) } } else { + // 默认线路 + var isResolved = false + if len(defaultRoute) > 0 { + var recordType = "A" + if utils.IsIPv6(node.IpAddr) { + recordType = "AAAA" + } + checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{ + DnsDomainId: cluster.DnsDomainId, + Name: cluster.DnsName, + Type: recordType, + Route: defaultRoute, + Value: node.IpAddr, + }) + if err != nil { + this.ErrorPage(err) + return + } + isResolved = checkResp.IsOk + } nodeMaps = append(nodeMaps, maps.Map{ "id": node.Id, "name": node.Name, @@ -96,7 +124,7 @@ func (this *NodesPopupAction) RunGet(params struct { "code": "", }, "clusterId": node.NodeClusterId, - "isOk": false, + "isOk": isResolved, }) } } diff --git a/internal/web/actions/default/dns/domains/serversPopup.go b/internal/web/actions/default/dns/domains/serversPopup.go index afabe526..d0e88ecd 100644 --- a/internal/web/actions/default/dns/domains/serversPopup.go +++ b/internal/web/actions/default/dns/domains/serversPopup.go @@ -17,6 +17,8 @@ func (this *ServersPopupAction) Init() { func (this *ServersPopupAction) RunGet(params struct { DomainId int64 }) { + this.Data["domainId"] = params.DomainId + // 域名信息 domainResp, err := this.RPC().DNSDomainRPC().FindBasicDNSDomain(this.AdminContext(), &pb.FindBasicDNSDomainRequest{ DnsDomainId: params.DomainId, @@ -25,7 +27,7 @@ func (this *ServersPopupAction) RunGet(params struct { this.ErrorPage(err) return } - domain := domainResp.DnsDomain + var domain = domainResp.DnsDomain if domain == nil { this.NotFound("dnsDomain", params.DomainId) return @@ -34,7 +36,7 @@ func (this *ServersPopupAction) RunGet(params struct { this.Data["domain"] = domain.Name // 服务信息 - clusterMaps := []maps.Map{} + var clusterMaps = []maps.Map{} clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithDNSDomainId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithDNSDomainIdRequest{DnsDomainId: params.DomainId}) if err != nil { this.ErrorPage(err) @@ -46,9 +48,9 @@ func (this *ServersPopupAction) RunGet(params struct { this.ErrorPage(err) return } - serverMaps := []maps.Map{} + var serverMaps = []maps.Map{} for _, server := range serversResp.Servers { - isOk := false + var isOk = false if len(cluster.DnsName) > 0 && len(server.DnsName) > 0 { checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{ DnsDomainId: params.DomainId, diff --git a/web/public/js/components/common/links.js b/web/public/js/components/common/links.js index 5873e075..ae808f51 100644 --- a/web/public/js/components/common/links.js +++ b/web/public/js/components/common/links.js @@ -24,6 +24,10 @@ Vue.component("link-red", { methods: { clickPrevent: function () { emitClick(this, arguments) + + if (this.vHref.length > 0) { + window.location = this.vHref + } } }, template: `` diff --git a/web/views/@default/clusters/cluster/node/detail.html b/web/views/@default/clusters/cluster/node/detail.html index 72971741..538e0282 100644 --- a/web/views/@default/clusters/cluster/node/detail.html +++ b/web/views/@default/clusters/cluster/node/detail.html @@ -77,6 +77,7 @@

通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。

当前集群DNS已设置不解析Ln节点,所以当前节点不会加入DNS解析;如需加入,请修改"集群设置" -- "DNS设置" -- "更多选项" -- "包含Ln节点"。

+

当前节点尚未完成安装,DNS解析记录将不会生效,[点此安装]

diff --git a/web/views/@default/clusters/cluster/node/install.html b/web/views/@default/clusters/cluster/node/install.html index 77681db3..5e250495 100644 --- a/web/views/@default/clusters/cluster/node/install.html +++ b/web/views/@default/clusters/cluster/node/install.html @@ -4,6 +4,11 @@
+
+ 在当前节点完成安装前,相关DNS解析记录将不会生效,已完成安装 +
+
+

方法1:通过SSH自动安装

- [修改为已安装状态] +
+ [修改当前节点为已安装状态]
diff --git a/web/views/@default/clusters/cluster/node/install.js b/web/views/@default/clusters/cluster/node/install.js index c9518945..ff56e20d 100644 --- a/web/views/@default/clusters/cluster/node/install.js +++ b/web/views/@default/clusters/cluster/node/install.js @@ -20,7 +20,8 @@ Tea.context(function () { // 设置节点安装状态 this.updateNodeIsInstalled = function (isInstalled) { - teaweb.confirm("确定要将当前节点修改为未安装状态?", function () { + let msg = isInstalled ? "html:确定要将当前节点修改为已安装状态?" : "html:确定要将当前节点修改为未安装状态?" + teaweb.confirm(msg, function () { this.$post("/clusters/cluster/node/updateInstallStatus") .params({ nodeId: this.nodeId, diff --git a/web/views/@default/dns/clusters/cluster.html b/web/views/@default/dns/clusters/cluster.html index 6d18ed50..3f100f45 100644 --- a/web/views/@default/dns/clusters/cluster.html +++ b/web/views/@default/dns/clusters/cluster.html @@ -164,8 +164,11 @@ 没有设置 - 已解析 - 未解析 + + 已解析 + 未解析 + + 未安装 修改 diff --git a/web/views/@default/dns/domains/nodesPopup.html b/web/views/@default/dns/domains/nodesPopup.html index 688731b8..c399a142 100644 --- a/web/views/@default/dns/domains/nodesPopup.html +++ b/web/views/@default/dns/domains/nodesPopup.html @@ -1,7 +1,8 @@ {$layout "layout_popup"}

使用域名"{{domain}}"的节点

-
+ +
diff --git a/web/views/@default/dns/domains/serversPopup.html b/web/views/@default/dns/domains/serversPopup.html index cbb6b498..0e86eba9 100644 --- a/web/views/@default/dns/domains/serversPopup.html +++ b/web/views/@default/dns/domains/serversPopup.html @@ -1,7 +1,8 @@ {$layout "layout_popup"} -

使用域名"{{domain}}"的节点

- +

使用域名"{{domain}}"的服务

+ +
diff --git a/web/views/@default/dns/providers/provider.js b/web/views/@default/dns/providers/provider.js index 096ed20f..bfdc4f15 100644 --- a/web/views/@default/dns/providers/provider.js +++ b/web/views/@default/dns/providers/provider.js @@ -127,7 +127,10 @@ Tea.context(function () { } this.viewServers = function (domainId) { - teaweb.popup("/dns/domains/serversPopup?domainId=" + domainId) + teaweb.popup("/dns/domains/serversPopup?domainId=" + domainId, { + width: "50em", + height: "30em" + }) } this.alertDown = function () {