mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-02 20:00:26 +08:00
IP阈值增加节点分组和集群相关统计项目
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
"group": groupMap,
|
||||
}
|
||||
var clusterId int64 = 0
|
||||
if node.NodeCluster != nil {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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", {
|
||||
<td style="background: white">
|
||||
<!-- 已经添加的项目 -->
|
||||
<div>
|
||||
<div v-for="(item, index) in addingThreshold.items" class="ui label basic small" style="margin-bottom: 0.5em; font-weight: normal">
|
||||
<div v-for="(item, index) in addingThreshold.items" class="ui label basic small" style="margin-bottom: 0.5em;">
|
||||
[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}}
|
||||
<!-- 连通性 -->
|
||||
<span v-if="item.item == 'connectivity' && item.options != null && item.options.groups != null && item.options.groups.length > 0">[<span v-for="(group, groupIndex) in item.options.groups">{{group.name}} <span v-if="groupIndex != item.options.groups.length - 1"> </span></span>]</span>
|
||||
|
||||
@@ -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": "小于等于",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
|
||||
<td>{{group.name}}</td>
|
||||
<td class="center">
|
||||
<span v-if="group.countNodes > 0">{{group.countNodes}}</span>
|
||||
<a :href="'/clusters/cluster/nodes?clusterId=' + clusterId + '&groupId=' + group.id" v-if="group.countNodes > 0">{{group.countNodes}}</a>
|
||||
<span v-else class="disabled">0</span>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<second-menu>
|
||||
<menu-item :href="'/clusters/cluster/nodes?clusterId=' + clusterId">节点列表</menu-item>
|
||||
<span class="item disabled">|</span>
|
||||
<a :href="'/clusters/cluster/nodes?clusterId=' + clusterId" class="item" style="padding-right: 0">{{currentClusterName}} »</a>
|
||||
<a :href="'/clusters/cluster/nodes?clusterId=' + clusterId + '&groupId=' + node.group.id" v-if="node.group != null" class="item" style="padding-left: 0"> {{node.group.name}} »</a>
|
||||
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id" code="node"
|
||||
v-if="!teaIsPlus">"{{node.name}}"节点详情</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/boards?clusterId=' + clusterId + '&nodeId=' + node.id" code="board" v-if="teaIsPlus">"{{node.name}}" 节点看板</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/detail?clusterId=' + clusterId + '&nodeId=' + node.id" code="node" v-if="teaIsPlus">节点详情</menu-item>
|
||||
v-if="!teaIsPlus" style="padding-left: 0">"{{node.name}}"节点详情</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/boards?clusterId=' + clusterId + '&nodeId=' + node.id" code="board" v-if="teaIsPlus" style="padding-left: 0">"{{node.name}}" 节点看板</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/detail?clusterId=' + clusterId + '&nodeId=' + node.id" code="node" v-if="teaIsPlus" style="padding-left: 0">节点详情</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + node.id" code="log">运行日志</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" code="install">安装节点</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + node.id" code="update">修改设置</menu-item>
|
||||
|
||||
@@ -68,10 +68,10 @@
|
||||
<tr v-for="node in nodes">
|
||||
<td><a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</a>
|
||||
<div style="margin-top: 0.5em" v-if="node.region != null">
|
||||
<tiny-basic-label class="olive">区域:{{node.region.name}}</tiny-basic-label>
|
||||
<span class="ui label tiny grey basic">区域:{{node.region.name}}</span>
|
||||
</div>
|
||||
<div style="margin-top: 0.5em" v-if="node.group != null">
|
||||
<tiny-basic-label class="olive">分组:{{node.group.name}}</tiny-basic-label>
|
||||
<span class="ui label tiny grey basic">分组:{{node.group.name}}</span>
|
||||
</div>
|
||||
<div style="margin-top: 0.5em">
|
||||
<node-clusters-labels :v-primary-cluster="node.cluster" :v-secondary-clusters="node.secondaryClusters" size="tiny"></node-clusters-labels>
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
<p class="comment">是否为可以公开访问的IP,如果选中,也会作为DNS解析记录的值使用。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
<tbody v-show="moreOptionsVisible">
|
||||
<tr>
|
||||
<td>是否启用</td>
|
||||
<td>
|
||||
@@ -47,7 +43,6 @@
|
||||
<node-ip-address-thresholds-box :v-thresholds="addr.thresholds"></node-ip-address-thresholds-box>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
Reference in New Issue
Block a user