diff --git a/internal/web/actions/default/clusters/cluster/node/install.go b/internal/web/actions/default/clusters/cluster/node/install.go index 78936350..66b9f716 100644 --- a/internal/web/actions/default/clusters/cluster/node/install.go +++ b/internal/web/actions/default/clusters/cluster/node/install.go @@ -3,6 +3,7 @@ package node import ( "github.com/TeaOSLab/EdgeAdmin/internal/oplogs" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" @@ -25,16 +26,11 @@ func (this *InstallAction) RunGet(params struct { this.Data["nodeId"] = params.NodeId // 节点 - nodeResp, err := this.RPC().NodeRPC().FindEnabledNode(this.AdminContext(), &pb.FindEnabledNodeRequest{NodeId: params.NodeId}) + node, err := nodeutils.InitNodeInfo(this.Parent(), params.NodeId) if err != nil { this.ErrorPage(err) return } - node := nodeResp.Node - if node == nil { - this.WriteString("找不到要操作的节点") - return - } // 安装信息 if node.InstallStatus != nil { @@ -84,15 +80,12 @@ func (this *InstallAction) RunGet(params struct { } this.Data["apiEndpoints"] = "\"" + strings.Join(apiEndpoints, "\", \"") + "\"" - this.Data["node"] = maps.Map{ - "id": node.Id, - "name": node.Name, - "installDir": node.InstallDir, - "isInstalled": node.IsInstalled, - "uniqueId": node.UniqueId, - "secret": node.Secret, - "cluster": clusterMap, - } + var nodeMap = this.Data["node"].(maps.Map) + nodeMap["installDir"] = node.InstallDir + nodeMap["isInstalled"] = node.IsInstalled + nodeMap["uniqueId"] = node.UniqueId + nodeMap["secret"] = node.Secret + nodeMap["cluster"] = clusterMap this.Show() } 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 068b5ccd..1ff30a63 100644 --- a/internal/web/actions/default/clusters/cluster/node/nodeutils/utils.go +++ b/internal/web/actions/default/clusters/cluster/node/nodeutils/utils.go @@ -22,11 +22,21 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod return nil, errors.New("node '" + strconv.FormatInt(nodeId, 10) + "' not found") } var node = nodeResp.Node + + var groupMap maps.Map + if node.NodeGroup != nil { + groupMap = maps.Map{ + "id": node.NodeGroup.Id, + "name": node.NodeGroup.Name, + } + } + parentAction.Data["node"] = maps.Map{ - "id": node.Id, - "name": node.Name, - "isOn": node.IsOn, - "isUp": node.IsUp, + "id": node.Id, + "name": node.Name, + "isOn": node.IsOn, + "isUp": node.IsUp, + "group": groupMap, } var clusterId int64 = 0 if node.NodeCluster != nil { diff --git a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go index be4928f5..702cf13d 100644 --- a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go @@ -45,6 +45,7 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext action.WriteString("can not find cluster") return } + action.Data["currentClusterName"] = cluster.Name clusterInfo, err := dao.SharedNodeClusterDAO.FindEnabledNodeClusterConfigInfo(ctx, clusterId) if err != nil { diff --git a/internal/web/actions/default/ui/components.go b/internal/web/actions/default/ui/components.go index 234e505a..3efd92cf 100644 --- a/internal/web/actions/default/ui/components.go +++ b/internal/web/actions/default/ui/components.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/Tea" @@ -102,6 +103,16 @@ func (this *ComponentsAction) RunGet(params struct{}) { buffer.Write([]byte{'\n', '\n'}) } + // IP地址阈值 + ipAddrThresholdItemsJSON, err := json.Marshal(nodeconfigs.FindAllIPAddressThresholdItems()) + if err != nil { + logs.Println("ComponentsAction marshal ip addr threshold items failed: " + err.Error()) + } else { + buffer.WriteString("window.IP_ADDR_THRESHOLD_ITEMS = ") + buffer.Write(ipAddrThresholdItemsJSON) + buffer.Write([]byte{'\n', '\n'}) + } + componentsData = buffer.Bytes() // ETag diff --git a/web/public/js/components/common/network-addresses-box.js b/web/public/js/components/common/network-addresses-box.js index b66901c3..6c84a352 100644 --- a/web/public/js/components/common/network-addresses-box.js +++ b/web/public/js/components/common/network-addresses-box.js @@ -66,7 +66,7 @@ Vue.component("network-addresses-box", { updateAddr: function (index, addr) { let that = this window.UPDATING_ADDR = addr - teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol, { + teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol + "&from=" + this.from, { height: "16em", callback: function (resp) { var addr = resp.data.address diff --git a/web/public/js/components/node/node-ip-address-thresholds-box.js b/web/public/js/components/node/node-ip-address-thresholds-box.js index 088161b9..94f60f3f 100644 --- a/web/public/js/components/node/node-ip-address-thresholds-box.js +++ b/web/public/js/components/node/node-ip-address-thresholds-box.js @@ -27,37 +27,12 @@ Vue.component("node-ip-address-thresholds-box", { isAddingItem: false, isAddingAction: false, - itemCode: "avgRequests", + itemCode: "nodeAvgRequests", itemReportGroups: [], itemOperator: "lte", itemValue: "", - itemDuration: 5, - allItems: [ - { - "name": "平均请求数", - "code": "avgRequests", - "description": "在单位时间内接收到的平均请求数。", - "unit": "个" - }, - { - "name": "平均下行流量", - "code": "avgTrafficOut", - "description": "在单位时间内发送的下行流量。", - "unit": "M" - }, - { - "name": "平均上行流量", - "code": "avgTrafficIn", - "description": "在单位时间内接收的上行流量。", - "unit": "M" - }, - { - "name": "连通性", - "code": "connectivity", - "description": "通过区域监控得到的连通性数值,取值在0和100之间。", - "unit": "%" - }, - ], + itemDuration: "5", + allItems: window.IP_ADDR_THRESHOLD_ITEMS, allOperators: [ { "name": "小于等于", @@ -165,10 +140,10 @@ Vue.component("node-ip-address-thresholds-box", { cancelItem: function () { this.isAddingItem = false - this.itemCode = "avgRequests" + this.itemCode = "nodeAvgRequests" this.itmeOperator = "lte" this.itemValue = "" - this.itemDuration = "1" + this.itemDuration = "5" this.itemReportGroups = [] }, confirmItem: function () { @@ -393,7 +368,7 @@ Vue.component("node-ip-address-thresholds-box", {
选中表示当前IP有效。
+选中表示当前IP有效。
-