From e454bdd98235da3027b37c5ba6bc8753686b5394 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 14 Sep 2021 11:36:08 +0800 Subject: [PATCH] =?UTF-8?q?IP=E9=98=88=E5=80=BC=E5=A2=9E=E5=8A=A0=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=88=86=E7=BB=84=E5=92=8C=E9=9B=86=E7=BE=A4=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=BB=9F=E8=AE=A1=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/clusters/cluster/node/install.go | 23 ++++------ .../clusters/cluster/node/nodeutils/utils.go | 18 ++++++-- .../clusters/clusterutils/cluster_helper.go | 1 + internal/web/actions/default/ui/components.go | 11 +++++ .../common/network-addresses-box.js | 2 +- .../node/node-ip-address-thresholds-box.js | 37 +++------------ .../node/node-ip-address-thresholds-view.js | 27 +---------- .../clusters/cluster/groups/index.html | 2 +- .../clusters/cluster/node/@node_menu.html | 10 ++--- .../@default/clusters/cluster/nodes.html | 4 +- .../clusters/ip-addrs/addr/update.html | 45 +++++++++---------- 11 files changed, 70 insertions(+), 110 deletions(-) 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", {
-
+
[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}} [{{group.name}}   ] diff --git a/web/public/js/components/node/node-ip-address-thresholds-view.js b/web/public/js/components/node/node-ip-address-thresholds-view.js index b12f1e00..c229ec32 100644 --- a/web/public/js/components/node/node-ip-address-thresholds-view.js +++ b/web/public/js/components/node/node-ip-address-thresholds-view.js @@ -18,32 +18,7 @@ Vue.component("node-ip-address-thresholds-view", { return { thresholds: thresholds, - 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": "%" - }, - ], + allItems: window.IP_ADDR_THRESHOLD_ITEMS, allOperators: [ { "name": "小于等于", diff --git a/web/views/@default/clusters/cluster/groups/index.html b/web/views/@default/clusters/cluster/groups/index.html index 8d43aa6f..9ed963d8 100644 --- a/web/views/@default/clusters/cluster/groups/index.html +++ b/web/views/@default/clusters/cluster/groups/index.html @@ -22,7 +22,7 @@ {{group.name}} - {{group.countNodes}} + {{group.countNodes}} 0 diff --git a/web/views/@default/clusters/cluster/node/@node_menu.html b/web/views/@default/clusters/cluster/node/@node_menu.html index b0f31116..8c51a3c6 100644 --- a/web/views/@default/clusters/cluster/node/@node_menu.html +++ b/web/views/@default/clusters/cluster/node/@node_menu.html @@ -1,10 +1,10 @@ - 节点列表 - | + {{currentClusterName}} » +   {{node.group.name}} » "{{node.name}}"节点详情 - "{{node.name}}" 节点看板 - 节点详情 + v-if="!teaIsPlus" style="padding-left: 0">"{{node.name}}"节点详情 + "{{node.name}}" 节点看板 + 节点详情 运行日志 安装节点 修改设置 diff --git a/web/views/@default/clusters/cluster/nodes.html b/web/views/@default/clusters/cluster/nodes.html index cfeb4e3a..9c3428b1 100644 --- a/web/views/@default/clusters/cluster/nodes.html +++ b/web/views/@default/clusters/cluster/nodes.html @@ -68,10 +68,10 @@ {{node.name}}
- 区域:{{node.region.name}} + 区域:{{node.region.name}}
- 分组:{{node.group.name}} + 分组:{{node.group.name}}
diff --git a/web/views/@default/clusters/ip-addrs/addr/update.html b/web/views/@default/clusters/ip-addrs/addr/update.html index f1b442ef..c01ba3ac 100644 --- a/web/views/@default/clusters/ip-addrs/addr/update.html +++ b/web/views/@default/clusters/ip-addrs/addr/update.html @@ -22,32 +22,27 @@ - + 是否启用 + +
+ + +
+

选中表示当前IP有效。

+ + + + 名称 + + + + + + 上线阈值 + + + - - - 是否启用 - -
- - -
-

选中表示当前IP有效。

- - - - 名称 - - - - - - 上线阈值 - - - - - \ No newline at end of file