节点IP地址可以设置专属集群

This commit is contained in:
GoEdgeLab
2023-03-01 11:38:21 +08:00
parent 1faed99e5b
commit 1e596a216f
13 changed files with 265 additions and 33 deletions

View File

@@ -89,7 +89,7 @@ func (this *DetailAction) RunGet(params struct {
return return
} }
var ipAddresses = ipAddressesResp.NodeIPAddresses var ipAddresses = ipAddressesResp.NodeIPAddresses
ipAddressMaps := []maps.Map{} var ipAddressMaps = []maps.Map{}
for _, addr := range ipAddressesResp.NodeIPAddresses { for _, addr := range ipAddressesResp.NodeIPAddresses {
thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id) thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id)
if err != nil { if err != nil {
@@ -103,6 +103,15 @@ func (this *DetailAction) RunGet(params struct {
addr.Ip = addr.BackupIP addr.Ip = addr.BackupIP
} }
// 专属集群
var addrClusterMaps = []maps.Map{}
for _, addrCluster := range addr.NodeClusters {
addrClusterMaps = append(addrClusterMaps, maps.Map{
"id": addrCluster.Id,
"name": addrCluster.Name,
})
}
ipAddressMaps = append(ipAddressMaps, maps.Map{ ipAddressMaps = append(ipAddressMaps, maps.Map{
"id": addr.Id, "id": addr.Id,
"name": addr.Name, "name": addr.Name,
@@ -111,6 +120,7 @@ func (this *DetailAction) RunGet(params struct {
"canAccess": addr.CanAccess, "canAccess": addr.CanAccess,
"isOn": addr.IsOn, "isOn": addr.IsOn,
"isUp": addr.IsUp, "isUp": addr.IsUp,
"clusters": addrClusterMaps,
"thresholds": thresholds, "thresholds": thresholds,
}) })
} }
@@ -152,6 +162,20 @@ func (this *DetailAction) RunGet(params struct {
if !addr.CanAccess || !addr.IsUp || !addr.IsOn { if !addr.CanAccess || !addr.IsUp || !addr.IsOn {
continue continue
} }
// 过滤集群
if len(addr.NodeClusters) > 0 {
var inCluster = false
for _, addrCluster := range addr.NodeClusters {
if addrCluster.Id == cluster.Id {
inCluster = true
}
}
if !inCluster {
continue
}
}
for _, route := range dnsInfo.Routes { for _, route := range dnsInfo.Routes {
var recordType = "A" var recordType = "A"
if utils.IsIPv6(addr.Ip) { if utils.IsIPv6(addr.Ip) {
@@ -162,6 +186,7 @@ func (this *DetailAction) RunGet(params struct {
"type": recordType, "type": recordType,
"route": route.Name, "route": route.Name,
"value": addr.Ip, "value": addr.Ip,
"clusterName": cluster.Name,
}) })
} }
} }
@@ -179,8 +204,8 @@ func (this *DetailAction) RunGet(params struct {
} }
} }
grantMap := maps.Map{} var grantMap = maps.Map{}
grantId := loginParams.GetInt64("grantId") var grantId = loginParams.GetInt64("grantId")
if grantId > 0 { if grantId > 0 {
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: grantId}) grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: grantId})
if err != nil { if err != nil {

View File

@@ -64,12 +64,22 @@ func (this *UpdateAction) RunGet(params struct {
} }
var ipAddressMaps = []maps.Map{} var ipAddressMaps = []maps.Map{}
for _, addr := range ipAddressesResp.NodeIPAddresses { for _, addr := range ipAddressesResp.NodeIPAddresses {
// 阈值
thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id) thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id)
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
// 专属集群
var clusterMaps = []maps.Map{}
for _, addrCluster := range addr.NodeClusters {
clusterMaps = append(clusterMaps, maps.Map{
"id": addrCluster.Id,
"name": addrCluster.Name,
})
}
ipAddressMaps = append(ipAddressMaps, maps.Map{ ipAddressMaps = append(ipAddressMaps, maps.Map{
"id": addr.Id, "id": addr.Id,
"name": addr.Name, "name": addr.Name,
@@ -78,6 +88,7 @@ func (this *UpdateAction) RunGet(params struct {
"isOn": addr.IsOn, "isOn": addr.IsOn,
"isUp": addr.IsUp, "isUp": addr.IsUp,
"thresholds": thresholds, "thresholds": thresholds,
"clusters": clusterMaps,
}) })
} }

View File

@@ -68,7 +68,7 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
actionutils.SetTabbar(action, tabbar) actionutils.SetTabbar(action, tabbar)
// 左侧菜单 // 左侧菜单
secondMenuItem := action.Data.GetString("secondMenuItem") var secondMenuItem = action.Data.GetString("secondMenuItem")
switch selectedTabbar { switch selectedTabbar {
case "setting": case "setting":
var menuItems = this.createSettingMenu(cluster, clusterInfo, secondMenuItem) var menuItems = this.createSettingMenu(cluster, clusterInfo, secondMenuItem)

View File

@@ -5,6 +5,7 @@ import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/utils" "github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
@@ -20,8 +21,18 @@ func (this *CreatePopupAction) Init() {
} }
func (this *CreatePopupAction) RunGet(params struct { func (this *CreatePopupAction) RunGet(params struct {
NodeId int64
SupportThresholds bool SupportThresholds bool
}) { }) {
// 专属集群
clusterMaps, err := ipaddressutils.FindNodeClusterMapsWithNodeId(this.Parent(), params.NodeId)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["clusters"] = clusterMaps
// 阈值
this.Data["supportThresholds"] = params.SupportThresholds this.Data["supportThresholds"] = params.SupportThresholds
this.Show() this.Show()
@@ -33,6 +44,7 @@ func (this *CreatePopupAction) RunPost(params struct {
Name string Name string
IsUp bool IsUp bool
ThresholdsJSON []byte ThresholdsJSON []byte
ClusterIds []int64
Must *actions.Must Must *actions.Must
}) { }) {
@@ -57,6 +69,14 @@ func (this *CreatePopupAction) RunPost(params struct {
_ = json.Unmarshal(params.ThresholdsJSON, &thresholds) _ = json.Unmarshal(params.ThresholdsJSON, &thresholds)
} }
// 专属集群
// 目前只考虑CDN边缘集群
clusterMaps, err := ipaddressutils.FindNodeClusterMaps(this.Parent(), params.ClusterIds)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["ipAddress"] = maps.Map{ this.Data["ipAddress"] = maps.Map{
"name": params.Name, "name": params.Name,
"canAccess": params.CanAccess, "canAccess": params.CanAccess,
@@ -65,6 +85,7 @@ func (this *CreatePopupAction) RunPost(params struct {
"isOn": true, "isOn": true,
"isUp": params.IsUp, "isUp": params.IsUp,
"thresholds": thresholds, "thresholds": thresholds,
"clusters": clusterMaps,
} }
this.Success() this.Success()
} }

View File

@@ -11,14 +11,28 @@ import (
// UpdateNodeIPAddresses 保存一组IP地址 // UpdateNodeIPAddresses 保存一组IP地址
func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64, role nodeconfigs.NodeRole, ipAddressesJSON []byte) error { func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64, role nodeconfigs.NodeRole, ipAddressesJSON []byte) error {
addresses := []maps.Map{} var addresses = []maps.Map{}
err := json.Unmarshal(ipAddressesJSON, &addresses) err := json.Unmarshal(ipAddressesJSON, &addresses)
if err != nil { if err != nil {
return err return err
} }
for _, addr := range addresses { for _, addr := range addresses {
var resultAddrIds = []int64{} var resultAddrIds = []int64{}
addrId := addr.GetInt64("id") var addrId = addr.GetInt64("id")
// 专属集群
var addrClusterIds = []int64{}
var addrClusters = addr.GetSlice("clusters")
if len(addrClusters) > 0 {
for _, addrCluster := range addrClusters {
var m = maps.NewMap(addrCluster)
var clusterId = m.GetInt64("id")
if clusterId > 0 {
addrClusterIds = append(addrClusterIds, clusterId)
}
}
}
if addrId > 0 { if addrId > 0 {
resultAddrIds = append(resultAddrIds, addrId) resultAddrIds = append(resultAddrIds, addrId)
@@ -36,6 +50,7 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
CanAccess: addr.GetBool("canAccess"), CanAccess: addr.GetBool("canAccess"),
IsOn: isOn, IsOn: isOn,
IsUp: addr.GetBool("isUp"), IsUp: addr.GetBool("isUp"),
ClusterIds: addrClusterIds,
}) })
if err != nil { if err != nil {
return err return err
@@ -53,6 +68,7 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
Ip: result[0], Ip: result[0],
CanAccess: addr.GetBool("canAccess"), CanAccess: addr.GetBool("canAccess"),
IsUp: addr.GetBool("isUp"), IsUp: addr.GetBool("isUp"),
NodeClusterIds: addrClusterIds,
}) })
if err != nil { if err != nil {
return err return err
@@ -69,6 +85,7 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
CanAccess: addr.GetBool("canAccess"), CanAccess: addr.GetBool("canAccess"),
IsUp: addr.GetBool("isUp"), IsUp: addr.GetBool("isUp"),
GroupValue: ipStrings, GroupValue: ipStrings,
NodeClusterIds: addrClusterIds,
}) })
if err != nil { if err != nil {
return err return err
@@ -140,3 +157,53 @@ func InitNodeIPAddressThresholds(parentAction *actionutils.ParentAction, addrId
} }
return thresholds, nil return thresholds, nil
} }
// FindNodeClusterMapsWithNodeId 根据节点读取集群信息
func FindNodeClusterMapsWithNodeId(parentAction *actionutils.ParentAction, nodeId int64) ([]maps.Map, error) {
var clusterMaps = []maps.Map{}
if nodeId > 0 { // CDN边缘节点
nodeResp, err := parentAction.RPC().NodeRPC().FindEnabledNode(parentAction.AdminContext(), &pb.FindEnabledNodeRequest{NodeId: nodeId})
if err != nil {
return nil, err
}
var node = nodeResp.Node
if node != nil {
var clusters = []*pb.NodeCluster{}
if node.NodeCluster != nil {
clusters = append(clusters, nodeResp.Node.NodeCluster)
}
if len(node.SecondaryNodeClusters) > 0 {
clusters = append(clusters, node.SecondaryNodeClusters...)
}
for _, cluster := range clusters {
clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.Id,
"name": cluster.Name,
"isChecked": false,
})
}
}
}
return clusterMaps, nil
}
// FindNodeClusterMaps 根据一组集群ID读取集群信息
func FindNodeClusterMaps(parentAction *actionutils.ParentAction, clusterIds []int64) ([]maps.Map, error) {
var clusterMaps = []maps.Map{}
if len(clusterIds) > 0 {
for _, clusterId := range clusterIds {
clusterResp, err := parentAction.RPC().NodeClusterRPC().FindEnabledNodeCluster(parentAction.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
if err != nil {
return nil, err
}
var cluster = clusterResp.NodeCluster
if cluster != nil {
clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.Id,
"name": cluster.Name,
})
}
}
}
return clusterMaps, nil
}

View File

@@ -5,6 +5,7 @@ import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/utils" "github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
@@ -21,9 +22,18 @@ func (this *UpdatePopupAction) Init() {
} }
func (this *UpdatePopupAction) RunGet(params struct { func (this *UpdatePopupAction) RunGet(params struct {
NodeId int64
AddressId int64 AddressId int64
SupportThresholds bool SupportThresholds bool
}) { }) {
// 专属集群
clusterMaps, err := ipaddressutils.FindNodeClusterMapsWithNodeId(this.Parent(), params.NodeId)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["clusters"] = clusterMaps
this.Data["supportThresholds"] = params.SupportThresholds this.Data["supportThresholds"] = params.SupportThresholds
this.Show() this.Show()
@@ -37,6 +47,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
IsOn bool IsOn bool
IsUp bool IsUp bool
ThresholdsJSON []byte ThresholdsJSON []byte
ClusterIds []int64
Must *actions.Must Must *actions.Must
}) { }) {
@@ -81,6 +92,14 @@ func (this *UpdatePopupAction) RunPost(params struct {
_ = json.Unmarshal(params.ThresholdsJSON, &thresholds) _ = json.Unmarshal(params.ThresholdsJSON, &thresholds)
} }
// 专属集群
// 目前只考虑CDN边缘集群
clusterMaps, err := ipaddressutils.FindNodeClusterMaps(this.Parent(), params.ClusterIds)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["ipAddress"] = maps.Map{ this.Data["ipAddress"] = maps.Map{
"name": params.Name, "name": params.Name,
"ip": params.IP, "ip": params.IP,
@@ -89,6 +108,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
"isOn": params.IsOn, "isOn": params.IsOn,
"isUp": isUp, "isUp": isUp,
"thresholds": thresholds, "thresholds": thresholds,
"clusters": clusterMaps,
} }
this.Success() this.Success()

View File

@@ -0,0 +1,53 @@
Vue.component("node-ip-address-clusters-selector", {
props: ["vClusters"],
mounted: function () {
this.checkClusters()
},
data: function () {
let clusters = this.vClusters
if (clusters == null) {
clusters = []
}
return {
clusters: clusters,
hasCheckedCluster: false,
clustersVisible: false
}
},
methods: {
checkClusters: function () {
let that = this
let b = false
this.clusters.forEach(function (cluster) {
if (cluster.isChecked) {
b = true
}
})
this.hasCheckedCluster = b
return b
},
changeCluster: function (cluster) {
cluster.isChecked = !cluster.isChecked
this.checkClusters()
},
showClusters: function () {
this.clustersVisible = !this.clustersVisible
}
},
template: `<div>
<span v-if="!hasCheckedCluster">默认用于所有集群 &nbsp; <a href="" @click.prevent="showClusters">修改 <i class="icon angle" :class="{down: !clustersVisible, up:clustersVisible}"></i></a></span>
<div v-if="hasCheckedCluster">
<span v-for="cluster in clusters" class="ui label basic small" v-if="cluster.isChecked">{{cluster.name}}</span> &nbsp; <a href="" @click.prevent="showClusters">修改 <i class="icon angle" :class="{down: !clustersVisible, up:clustersVisible}"></i></a>
<p class="comment">当前IP仅在所选集群中有效。</p>
</div>
<div v-show="clustersVisible">
<div class="ui divider"></div>
<checkbox v-for="cluster in clusters" :v-value="cluster.id" :value="cluster.isChecked ? cluster.id : 0" style="margin-right: 1em" @input="changeCluster(cluster)" name="clusterIds">
{{cluster.name}}
</checkbox>
</div>
</div>`
})

View File

@@ -1,10 +1,16 @@
// 节点IP地址管理标签形式 // 节点IP地址管理标签形式
Vue.component("node-ip-addresses-box", { Vue.component("node-ip-addresses-box", {
props: ["v-ip-addresses", "role"], props: ["v-ip-addresses", "role", "v-node-id"],
data: function () { data: function () {
let nodeId = this.vNodeId
if (nodeId == null) {
nodeId = 0
}
return { return {
ipAddresses: (this.vIpAddresses == null) ? [] : this.vIpAddresses, ipAddresses: (this.vIpAddresses == null) ? [] : this.vIpAddresses,
supportThresholds: this.role != "ns" supportThresholds: this.role != "ns",
nodeId: nodeId
} }
}, },
methods: { methods: {
@@ -13,7 +19,7 @@ Vue.component("node-ip-addresses-box", {
window.UPDATING_NODE_IP_ADDRESS = null window.UPDATING_NODE_IP_ADDRESS = null
let that = this; let that = this;
teaweb.popup("/nodes/ipAddresses/createPopup?supportThresholds=" + (this.supportThresholds ? 1 : 0), { teaweb.popup("/nodes/ipAddresses/createPopup?nodeId=" + this.nodeId + "&supportThresholds=" + (this.supportThresholds ? 1 : 0), {
callback: function (resp) { callback: function (resp) {
that.ipAddresses.push(resp.data.ipAddress); that.ipAddresses.push(resp.data.ipAddress);
}, },
@@ -24,10 +30,10 @@ Vue.component("node-ip-addresses-box", {
// 修改地址 // 修改地址
updateIPAddress: function (index, address) { updateIPAddress: function (index, address) {
window.UPDATING_NODE_IP_ADDRESS = address window.UPDATING_NODE_IP_ADDRESS = teaweb.clone(address)
let that = this; let that = this;
teaweb.popup("/nodes/ipAddresses/updatePopup?supportThresholds=" + (this.supportThresholds ? 1 : 0), { teaweb.popup("/nodes/ipAddresses/updatePopup?nodeId=" + this.nodeId + "&supportThresholds=" + (this.supportThresholds ? 1 : 0), {
callback: function (resp) { callback: function (resp) {
Vue.set(that.ipAddresses, index, resp.data.ipAddress); Vue.set(that.ipAddresses, index, resp.data.ipAddress);
}, },
@@ -58,6 +64,11 @@ Vue.component("node-ip-addresses-box", {
<span class="small red" v-if="!address.isUp" title="已下线">[down]</span> <span class="small red" v-if="!address.isUp" title="已下线">[down]</span>
<span class="small" v-if="address.thresholds != null && address.thresholds.length > 0">[{{address.thresholds.length}}个阈值]</span> <span class="small" v-if="address.thresholds != null && address.thresholds.length > 0">[{{address.thresholds.length}}个阈值]</span>
&nbsp; &nbsp;
<span v-if="address.clusters != null && address.clusters.length > 0">
&nbsp; <span class="small grey">专属集群:[</span><span v-for="(cluster, index) in address.clusters" class="small grey">{{cluster.name}}<span v-if="index < address.clusters.length - 1"></span></span><span class="small grey">]</span>
&nbsp;
</span>
<a href="" title="修改" @click.prevent="updateIPAddress(index, address)"><i class="icon pencil small"></i></a> <a href="" title="修改" @click.prevent="updateIPAddress(index, address)"><i class="icon pencil small"></i></a>
<a href="" title="删除" @click.prevent="removeIPAddress(index)"><i class="icon remove"></i></a> <a href="" title="删除" @click.prevent="removeIPAddress(index)"><i class="icon remove"></i></a>
</div> </div>

View File

@@ -22,7 +22,7 @@
<td> <td>
<div v-if="node.ipAddresses.length > 0"> <div v-if="node.ipAddresses.length > 0">
<div> <div>
<div v-for="(address, index) in node.ipAddresses" class="ui label tiny basic"> <div v-for="(address, index) in node.ipAddresses" class="ui label small basic">
<span v-if="address.ip.indexOf(':') > -1" class="grey">[IPv6]</span> {{address.ip}} <span v-if="address.ip.indexOf(':') > -1" class="grey">[IPv6]</span> {{address.ip}}
<span class="small red" v-if="address.originIP != null && address.originIP.length > 0 && address.originIP != address.ip">(原:{{address.originIP}}</span> <span class="small red" v-if="address.originIP != null && address.originIP.length > 0 && address.originIP != address.ip">(原:{{address.originIP}}</span>
<span class="small grey" v-if="address.name.length > 0">{{address.name}}<span v-if="!address.canAccess">,不可访问</span></span> <span class="small grey" v-if="address.name.length > 0">{{address.name}}<span v-if="!address.canAccess">,不可访问</span></span>
@@ -30,6 +30,10 @@
<span class="small red" v-if="!address.isOn">[off]</span> <span class="small red" v-if="!address.isOn">[off]</span>
<span class="small red" v-if="!address.isUp">[down]</span> <span class="small red" v-if="!address.isUp">[down]</span>
<span class="small" v-if="address.thresholds != null && address.thresholds.length > 0">[阈值]</span> <span class="small" v-if="address.thresholds != null && address.thresholds.length > 0">[阈值]</span>
<span v-if="address.clusters.length > 0">
&nbsp; <span class="small grey">专属集群:[</span><span v-for="(cluster, index) in address.clusters" class="small grey">{{cluster.name}}<span v-if="index < address.clusters.length - 1"></span></span><span class="small grey">]</span>
</span>
</div> </div>
</div> </div>
</div> </div>
@@ -51,6 +55,7 @@
<table class="ui table celled"> <table class="ui table celled">
<thead class="full-width"> <thead class="full-width">
<tr> <tr>
<th>集群</th>
<th>记录名</th> <th>记录名</th>
<th>记录类型</th> <th>记录类型</th>
<th>线路</th> <th>线路</th>
@@ -59,6 +64,7 @@
</thead> </thead>
<tr v-for="record in node.records"> <tr v-for="record in node.records">
<td>{{record.clusterName}}</td>
<td>{{record.name}}</td> <td>{{record.name}}</td>
<td>{{record.type}}</td> <td>{{record.type}}</td>
<td> <td>

View File

@@ -26,7 +26,7 @@
<tr> <tr>
<td>IP地址 *</td> <td>IP地址 *</td>
<td> <td>
<node-ip-addresses-box :v-ip-addresses="ipAddresses"></node-ip-addresses-box> <node-ip-addresses-box :v-ip-addresses="ipAddresses" :v-node-id="node.id"></node-ip-addresses-box>
<p class="comment">用于访问节点和域名解析等。</p> <p class="comment">用于访问节点和域名解析等。</p>
</td> </td>
</tr> </tr>

View File

@@ -12,7 +12,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>是否可以访问</td> <td>允许公开访问</td>
<td> <td>
<div class="ui checkbox"> <div class="ui checkbox">
<input type="checkbox" name="canAccess" value="1" checked="checked"/> <input type="checkbox" name="canAccess" value="1" checked="checked"/>
@@ -46,6 +46,10 @@
<node-ip-address-thresholds-box></node-ip-address-thresholds-box> <node-ip-address-thresholds-box></node-ip-address-thresholds-box>
</td> </td>
</tr> </tr>
<tr v-show="clusters != null && clusters.length > 0">
<td>专属集群</td>
<td><node-ip-address-clusters-selector :v-clusters="clusters"></node-ip-address-clusters-selector></td>
</tr>
</tbody> </tbody>
</table> </table>
<submit-btn></submit-btn> <submit-btn></submit-btn>

View File

@@ -14,7 +14,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>是否可以访问</td> <td>允许公开访问</td>
<td> <td>
<div class="ui checkbox"> <div class="ui checkbox">
<input type="checkbox" name="canAccess" value="1" v-model="address.canAccess"/> <input type="checkbox" name="canAccess" value="1" v-model="address.canAccess"/>
@@ -28,7 +28,7 @@
</tr> </tr>
<tbody v-show="moreOptionsVisible"> <tbody v-show="moreOptionsVisible">
<tr> <tr>
<td>是否启用</td> <td>启用当前IP</td>
<td> <td>
<div class="ui checkbox"> <div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="address.isOn"/> <input type="checkbox" name="isOn" value="1" v-model="address.isOn"/>
@@ -58,6 +58,10 @@
<node-ip-address-thresholds-box :v-thresholds="address.thresholds"></node-ip-address-thresholds-box> <node-ip-address-thresholds-box :v-thresholds="address.thresholds"></node-ip-address-thresholds-box>
</td> </td>
</tr> </tr>
<tr v-show="clusters != null && clusters.length > 0">
<td>专属集群</td>
<td><node-ip-address-clusters-selector :v-clusters="clusters"></node-ip-address-clusters-selector></td>
</tr>
</tbody> </tbody>
</table> </table>
<submit-btn></submit-btn> <submit-btn></submit-btn>

View File

@@ -4,5 +4,15 @@ Tea.context(function () {
this.address = window.parent.UPDATING_NODE_IP_ADDRESS this.address = window.parent.UPDATING_NODE_IP_ADDRESS
if (this.address != null) { if (this.address != null) {
this.address.isUp = (this.address.isUp ? 1 : 0) this.address.isUp = (this.address.isUp ? 1 : 0)
// 专属集群
if (this.address.clusters != null) {
let selectedClusterIds = this.address.clusters.map(function (cluster) {
return cluster.id
})
this.clusters.forEach(function (cluster) {
cluster.isChecked = selectedClusterIds.$contains(cluster.id)
})
}
} }
}) })