选择DNS线路时增加搜索/节点如果没有设置DNS线路就使用默认线路

This commit is contained in:
刘祥超
2021-08-25 17:16:14 +08:00
parent 8c352813c4
commit 0dad0b10e6
8 changed files with 67 additions and 14 deletions

View File

@@ -40,6 +40,7 @@ func (this *ClusterAction) RunGet(params struct {
this.ErrorPage(err)
return
}
var defaultRoute = dnsResp.DefaultRoute
domainName := ""
dnsMap := maps.Map{
"dnsName": dnsResp.Name,
@@ -106,6 +107,26 @@ func (this *ClusterAction) RunGet(params struct {
})
}
} else {
// 默认线路
var isResolved = false
if len(defaultRoute) > 0 {
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,
@@ -115,7 +136,7 @@ func (this *ClusterAction) RunGet(params struct {
"code": "",
},
"clusterId": node.NodeClusterId,
"isResolved": false,
"isResolved": isResolved,
})
}
}

View File

@@ -12,9 +12,6 @@ Vue.component("node-clusters-labels", {
if (labelSize == null) {
labelSize = "small"
}
if (labelSize == "tiny") {
labelSize += " olive"
}
return {
cluster: cluster,
secondaryClusters: secondaryClusters,
@@ -22,7 +19,7 @@ Vue.component("node-clusters-labels", {
}
},
template: `<div>
<a v-if="cluster != null" :href="'/clusters/cluster?clusterId=' + cluster.id" class="ui label basic" :class="labelSize" title="主集群" style="margin-bottom: 0.3em;">{{cluster.name}}</a>
<a v-for="c in secondaryClusters" :href="'/clusters/cluster?clusterId=' + c.id" class="ui label basic" :class="labelSize" title="从集群" style="margin-bottom: 0.3em;"><span class="grey" style="text-decoration: none">{{c.name}}</span></a>
<a v-if="cluster != null" :href="'/clusters/cluster?clusterId=' + cluster.id" class="ui label basic grey" :class="labelSize" title="主集群" style="margin-bottom: 0.3em;">{{cluster.name}}</a>
<a v-for="c in secondaryClusters" :href="'/clusters/cluster?clusterId=' + c.id" class="ui label basic grey" :class="labelSize" title="从集群" style="margin-bottom: 0.3em;"><span class="grey" style="text-decoration: none">{{c.name}}</span></a>
</div>`
})

View File

@@ -11,12 +11,21 @@ Vue.component("dns-route-selector", {
return v.code + "@" + v.domainId
}),
isAdding: false,
routeCode: ""
routeCode: "",
keyword: "",
searchingRoutes: this.vAllRoutes.$copy()
}
},
methods: {
add: function () {
this.isAdding = true
this.keyword = ""
this.routeCode = ""
let that = this
setTimeout(function () {
that.$refs.keywordRef.focus()
}, 200)
},
cancel: function () {
this.isAdding = false
@@ -50,6 +59,23 @@ Vue.component("dns-route-selector", {
})
}
},
watch: {
keyword: function (keyword) {
if (keyword.length == 0) {
this.searchingRoutes = this.vAllRoutes.$copy()
this.routeCode = ""
return
}
this.searchingRoutes = this.vAllRoutes.filter(function (route) {
return teaweb.match(route.name, keyword)
})
if (this.searchingRoutes.length > 0) {
this.routeCode = this.searchingRoutes[0].code + "@" + this.searchingRoutes[0].domainId
} else {
this.routeCode = ""
}
}
},
template: `<div>
<input type="hidden" name="dnsRoutesJSON" :value="JSON.stringify(routeCodes)"/>
<div v-if="routes.length > 0">
@@ -62,16 +88,20 @@ Vue.component("dns-route-selector", {
<div v-if="isAdding">
<div class="ui fields inline">
<div class="ui field">
<select class="ui dropdown auto-width" v-model="routeCode">
<option value="">[请选择]</option>
<option v-for="route in vAllRoutes" :value="route.code + '@' + route.domainId">{{route.name}}{{route.domainName}}</option>
<select class="ui dropdown" style="width: 18em" v-model="routeCode">
<option value="" v-if="keyword.length == 0">[请选择]</option>
<option v-for="route in searchingRoutes" :value="route.code + '@' + route.domainId">{{route.name}}{{route.domainName}}</option>
</select>
</div>
<div class="ui field">
<input type="text" placeholder="搜索..." size="10" v-model="keyword" ref="keywordRef"/>
</div>
<div class="ui field">
<button class="ui button tiny" type="button" @click.prevent="confirm">确定</button>
</div>
<div class="ui field">
<a href="" @click.prevent="cancel()"><i class="icon remove"></i></a>
<a href="" @click.prevent="cancel()"><i class="icon remove small"></i></a>
</div>
</div>
</div>

View File

@@ -5,7 +5,7 @@
top: 10em;
}
.row {
line-height: 4;
line-height: 2;
}
.step.active {
font-weight: bold;

View File

@@ -140,11 +140,13 @@
<!-- 手动安装 -->
<div v-if="installMethod == 'manual'">
<div class="row">在边缘节点安装目录下,复制<code-label>configs/api.template.yaml</code-label><code-label>configs/api.yaml</code-label>,然后修改文件里面的内容为以下内容:</div>
<div class="row">上传边缘节点程序到服务器并解压,然后在边缘节点安装目录下,复制<code-label>configs/api.template.yaml</code-label><code-label>configs/api.yaml</code-label>,然后修改文件里面的内容为以下内容:</div>
<div class="margin"></div>
<source-code-box id="rpc-code" type="text/yaml">rpc:
endpoints: [ {{apiEndpoints}} ]
nodeId: "{{node.uniqueId}}"
secret: "{{node.secret}}"</source-code-box>
<div class="margin"></div>
<div class="row">然后再使用<code-label>bin/edge-node start</code-label>命令启动节点。</div>
<div>
<div class="ui divider"></div>

View File

@@ -7,7 +7,7 @@
}
.row {
line-height: 4;
line-height: 2;
}
.step.active {

View File

@@ -12,6 +12,7 @@ Tea.context(function () {
this.updateNode = function (clusterId, nodeId) {
teaweb.popup("/dns/issues/updateNodePopup?clusterId=" + clusterId + "&nodeId=" + nodeId, {
width: "46em",
height: "26em",
callback: function () {
teaweb.success("保存成功", function () {

View File

@@ -20,6 +20,8 @@ Tea.context(function () {
this.updateNode = function (clusterId, nodeId) {
let that = this
teaweb.popup("/dns/issues/updateNodePopup?clusterId=" + clusterId + "&nodeId=" + nodeId, {
width: "46em",
height: "26em",
callback: function () {
teaweb.success("保存成功", function () {
that.reload()