diff --git a/internal/web/actions/default/clusters/cluster/node/detail.go b/internal/web/actions/default/clusters/cluster/node/detail.go index db6ebd24..91e01c2f 100644 --- a/internal/web/actions/default/clusters/cluster/node/detail.go +++ b/internal/web/actions/default/clusters/cluster/node/detail.go @@ -33,7 +33,7 @@ func (this *DetailAction) RunGet(params struct { this.ErrorPage(err) return } - node := nodeResp.Node + var node = nodeResp.Node if node == nil { this.WriteString("找不到要操作的节点") return @@ -197,7 +197,7 @@ func (this *DetailAction) RunGet(params struct { } // 运行状态 - status := &nodeconfigs.NodeStatus{} + var status = &nodeconfigs.NodeStatus{} if len(node.StatusJSON) > 0 { err = json.Unmarshal(node.StatusJSON, &status) if err != nil { @@ -285,6 +285,8 @@ func (this *DetailAction) RunGet(params struct { "isOn": node.IsOn, "records": recordMaps, "routes": routeMaps, + "level": node.Level, + "levelInfo": nodeconfigs.FindNodeLevel(int(node.Level)), "status": maps.Map{ "isActive": status.IsActive, diff --git a/internal/web/actions/default/clusters/cluster/node/nodeutils/utils.go b/internal/web/actions/default/clusters/cluster/node/nodeutils/utils.go index 3b2a295d..4b2f1882 100644 --- a/internal/web/actions/default/clusters/cluster/node/nodeutils/utils.go +++ b/internal/web/actions/default/clusters/cluster/node/nodeutils/utils.go @@ -38,6 +38,7 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod "isOn": node.IsOn, "isUp": node.IsUp, "group": groupMap, + "level": node.Level, } var clusterId int64 = 0 if node.NodeCluster != nil { diff --git a/internal/web/actions/default/clusters/cluster/node/update.go b/internal/web/actions/default/clusters/cluster/node/update.go index 265ffd91..60ca4f18 100644 --- a/internal/web/actions/default/clusters/cluster/node/update.go +++ b/internal/web/actions/default/clusters/cluster/node/update.go @@ -37,7 +37,7 @@ func (this *UpdateAction) RunGet(params struct { this.ErrorPage(err) return } - node := nodeResp.Node + var node = nodeResp.Node if node == nil { this.WriteString("找不到要操作的节点") return @@ -97,7 +97,7 @@ func (this *UpdateAction) RunGet(params struct { } } - var m = maps.Map{ + var nodeMap = maps.Map{ "id": node.Id, "name": node.Name, "ipAddresses": ipAddressMaps, @@ -105,15 +105,16 @@ func (this *UpdateAction) RunGet(params struct { "isOn": node.IsOn, "group": groupMap, "region": regionMap, + "level": node.Level, } if node.NodeCluster != nil { - m["primaryCluster"] = maps.Map{ + nodeMap["primaryCluster"] = maps.Map{ "id": node.NodeCluster.Id, "name": node.NodeCluster.Name, } } else { - m["primaryCluster"] = nil + nodeMap["primaryCluster"] = nil } if len(node.SecondaryNodeClusters) > 0 { @@ -124,12 +125,12 @@ func (this *UpdateAction) RunGet(params struct { "name": cluster.Name, }) } - m["secondaryClusters"] = secondaryClusterMaps + nodeMap["secondaryClusters"] = secondaryClusterMaps } else { - m["secondaryClusters"] = []interface{}{} + nodeMap["secondaryClusters"] = []interface{}{} } - this.Data["node"] = m + this.Data["node"] = nodeMap this.Show() } @@ -144,11 +145,12 @@ func (this *UpdateAction) RunPost(params struct { PrimaryClusterId int64 SecondaryClusterIds []byte IsOn bool + Level int32 Must *actions.Must }) { // 创建日志 - defer this.CreateLog(oplogs.LevelInfo, "修改节点 %d", params.NodeId) + defer this.CreateLog(oplogs.LevelInfo, "修改节点 %d 基本信息", params.NodeId) if params.NodeId <= 0 { this.Fail("要操作的节点不存在") @@ -194,6 +196,7 @@ func (this *UpdateAction) RunPost(params struct { NodeClusterId: params.PrimaryClusterId, SecondaryNodeClusterIds: secondaryClusterIds, IsOn: params.IsOn, + Level: params.Level, }) if err != nil { this.ErrorPage(err) diff --git a/internal/web/actions/default/clusters/cluster/nodes.go b/internal/web/actions/default/clusters/cluster/nodes.go index b71a763e..cc861fb3 100644 --- a/internal/web/actions/default/clusters/cluster/nodes.go +++ b/internal/web/actions/default/clusters/cluster/nodes.go @@ -3,6 +3,7 @@ package cluster import ( "encoding/json" "fmt" + teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" @@ -29,6 +30,7 @@ func (this *NodesAction) RunGet(params struct { InstalledState int ActiveState int Keyword string + Level int32 CpuOrder string MemoryOrder string @@ -40,6 +42,7 @@ func (this *NodesAction) RunGet(params struct { this.Data["installState"] = params.InstalledState this.Data["activeState"] = params.ActiveState this.Data["keyword"] = params.Keyword + this.Data["level"] = params.Level // 集群是否已经设置了线路 clusterDNSResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterDNS(this.AdminContext(), &pb.FindEnabledNodeClusterDNSRequest{NodeClusterId: params.ClusterId}) @@ -63,6 +66,7 @@ func (this *NodesAction) RunGet(params struct { NodeClusterId: params.ClusterId, NodeGroupId: params.GroupId, NodeRegionId: params.RegionId, + Level: params.Level, InstallState: types.Int32(params.InstalledState), ActiveState: types.Int32(params.ActiveState), Keyword: params.Keyword, @@ -81,6 +85,7 @@ func (this *NodesAction) RunGet(params struct { NodeClusterId: params.ClusterId, NodeGroupId: params.GroupId, NodeRegionId: params.RegionId, + Level: params.Level, InstallState: types.Int32(params.InstalledState), ActiveState: types.Int32(params.ActiveState), Keyword: params.Keyword, @@ -210,6 +215,7 @@ func (this *NodesAction) RunGet(params struct { "group": groupMap, "region": regionMap, "dnsRouteNames": dnsRouteNames, + "level": node.Level, }) } this.Data["nodes"] = nodeMaps @@ -257,6 +263,12 @@ func (this *NodesAction) RunGet(params struct { } this.Data["regions"] = regionMaps + // 级别 + this.Data["levels"] = []maps.Map{} + if teaconst.IsPlus { + this.Data["levels"] = nodeconfigs.FindAllNodeLevels() + } + // 记录最近访问 _, err = this.RPC().LatestItemRPC().IncreaseLatestItem(this.AdminContext(), &pb.IncreaseLatestItemRequest{ ItemType: "cluster", diff --git a/web/public/js/components/node/node-level-selector.js b/web/public/js/components/node/node-level-selector.js new file mode 100644 index 00000000..39d936a8 --- /dev/null +++ b/web/public/js/components/node/node-level-selector.js @@ -0,0 +1,31 @@ +// 节点级别选择器 +Vue.component("node-level-selector", { + props: ["v-node-level"], + data: function () { + let levelCode = this.vNodeLevel + if (levelCode == null || levelCode < 1) { + levelCode = 1 + } + return { + levels: [ + { + name: "边缘节点", + code: 1, + description: "普通的边缘节点。" + }, + { + name: "L2节点", + code: 2, + description: "特殊的边缘节点,同时负责同组上一级节点的回源。" + } + ], + levelCode: levelCode + } + }, + template: `
{{levels[levelCode - 1].description}}
+每行一个节点IP。
-设置区域后才能根据区域进行流量统计和计费。
-仅用来筛选服务。
+用来筛选节点,同时可以在分组中设置二级缓存节点。
设置区域后可以根据区域进行流量统计和计费。
+当前节点对应的DNS线路,可用线路是根据集群设置的域名获取的,注意DNS服务商可能对这些线路有其他限制。
-设置区域后才能根据区域进行流量统计和计费。
-仅用来筛选服务。
+用来筛选节点,同时可以在分组中设置二级缓存节点。
设置区域后可以根据区域进行流量统计和计费。
+用于访问节点和域名解析等。
-设置区域后才能根据区域进行流量统计和计费。
-仅用来筛选服务。
+用来筛选节点,同时可以在分组中设置二级缓存节点。
+设置区域后可以根据区域进行流量统计和计费。