diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go
index c1bf36db..0641e3c0 100644
--- a/internal/rpc/rpc_client.go
+++ b/internal/rpc/rpc_client.go
@@ -103,6 +103,10 @@ func (this *RPCClient) NodeIPAddressLogRPC() pb.NodeIPAddressLogServiceClient {
return pb.NewNodeIPAddressLogServiceClient(this.pickConn())
}
+func (this *RPCClient) NodeIPAddressThresholdRPC() pb.NodeIPAddressThresholdServiceClient {
+ return pb.NewNodeIPAddressThresholdServiceClient(this.pickConn())
+}
+
func (this *RPCClient) NodeValueRPC() pb.NodeValueServiceClient {
return pb.NewNodeValueServiceClient(this.pickConn())
}
diff --git a/internal/web/actions/default/clusters/cluster/createNode.go b/internal/web/actions/default/clusters/cluster/createNode.go
index 012d163e..e5f9049e 100644
--- a/internal/web/actions/default/clusters/cluster/createNode.go
+++ b/internal/web/actions/default/clusters/cluster/createNode.go
@@ -167,32 +167,48 @@ func (this *CreateNodeAction) RunPost(params struct {
nodeId := createResp.NodeId
// IP地址
- for _, address := range ipAddresses {
- addressId := address.GetInt64("id")
- if addressId > 0 {
+ for _, addr := range ipAddresses {
+ addrId := addr.GetInt64("id")
+ if addrId > 0 {
_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
- NodeIPAddressId: addressId,
+ NodeIPAddressId: addrId,
NodeId: nodeId,
})
- } else {
- var thresholdsJSON = []byte{}
- var thresholds = address.GetSlice("thresholds")
- if len(thresholds) > 0 {
- thresholdsJSON, _ = json.Marshal(thresholds)
+ if err != nil {
+ this.ErrorPage(err)
+ return
}
-
- _, err = this.RPC().NodeIPAddressRPC().CreateNodeIPAddress(this.AdminContext(), &pb.CreateNodeIPAddressRequest{
- NodeId: nodeId,
- Role: nodeconfigs.NodeRoleNode,
- Name: address.GetString("name"),
- Ip: address.GetString("ip"),
- CanAccess: address.GetBool("canAccess"),
- ThresholdsJSON: thresholdsJSON,
+ } else {
+ createResp, err := this.RPC().NodeIPAddressRPC().CreateNodeIPAddress(this.AdminContext(), &pb.CreateNodeIPAddressRequest{
+ NodeId: nodeId,
+ Role: nodeconfigs.NodeRoleNode,
+ Name: addr.GetString("name"),
+ Ip: addr.GetString("ip"),
+ CanAccess: addr.GetBool("canAccess"),
})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ addrId = createResp.NodeIPAddressId
}
- if err != nil {
- this.ErrorPage(err)
- return
+
+ // 阈值
+ var thresholds = addr.GetSlice("thresholds")
+ if len(thresholds) > 0 {
+ thresholdsJSON, err := json.Marshal(thresholds)
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ _, err = this.RPC().NodeIPAddressThresholdRPC().UpdateAllNodeIPAddressThresholds(this.AdminContext(), &pb.UpdateAllNodeIPAddressThresholdsRequest{
+ NodeIPAddressId: addrId,
+ NodeIPAddressThresholdsJSON: thresholdsJSON,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
}
}
diff --git a/internal/web/actions/default/clusters/cluster/node/detail.go b/internal/web/actions/default/clusters/cluster/node/detail.go
index 49a9a418..47cf053a 100644
--- a/internal/web/actions/default/clusters/cluster/node/detail.go
+++ b/internal/web/actions/default/clusters/cluster/node/detail.go
@@ -7,6 +7,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
@@ -79,14 +80,12 @@ func (this *DetailAction) RunGet(params struct {
var ipAddresses = ipAddressesResp.Addresses
ipAddressMaps := []maps.Map{}
for _, addr := range ipAddressesResp.Addresses {
- var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
- if len(addr.ThresholdsJSON) > 0 {
- err = json.Unmarshal(addr.ThresholdsJSON, &thresholds)
- if err != nil {
- this.ErrorPage(err)
- return
- }
+ thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id)
+ if err != nil {
+ this.ErrorPage(err)
+ return
}
+
ipAddressMaps = append(ipAddressMaps, maps.Map{
"id": addr.Id,
"name": addr.Name,
diff --git a/internal/web/actions/default/clusters/cluster/node/update.go b/internal/web/actions/default/clusters/cluster/node/update.go
index 7a8ccd97..aa29bc94 100644
--- a/internal/web/actions/default/clusters/cluster/node/update.go
+++ b/internal/web/actions/default/clusters/cluster/node/update.go
@@ -57,13 +57,10 @@ func (this *UpdateAction) RunGet(params struct {
}
ipAddressMaps := []maps.Map{}
for _, addr := range ipAddressesResp.Addresses {
- var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
- if len(addr.ThresholdsJSON) > 0 {
- err = json.Unmarshal(addr.ThresholdsJSON, &thresholds)
- if err != nil {
- this.ErrorPage(err)
- return
- }
+ thresholds, err := ipaddressutils.InitNodeIPAddressThresholds(this.Parent(), addr.Id)
+ if err != nil {
+ this.ErrorPage(err)
+ return
}
ipAddressMaps = append(ipAddressMaps, maps.Map{
diff --git a/internal/web/actions/default/nodes/ipAddresses/createPopup.go b/internal/web/actions/default/nodes/ipAddresses/createPopup.go
index bd54bb6d..54644dee 100644
--- a/internal/web/actions/default/nodes/ipAddresses/createPopup.go
+++ b/internal/web/actions/default/nodes/ipAddresses/createPopup.go
@@ -30,19 +30,21 @@ func (this *CreatePopupAction) RunPost(params struct {
IP string `alias:"ip"`
CanAccess bool
Name string
+ IsUp bool
ThresholdsJSON []byte
Must *actions.Must
}) {
- ip := net.ParseIP(params.IP)
- if len(ip) == 0 {
- this.Fail("请输入正确的IP")
- }
-
params.Must.
Field("ip", params.IP).
Require("请输入IP地址")
+ ip := net.ParseIP(params.IP)
+ if len(ip) == 0 {
+ this.FailField("ip", "请输入正确的IP")
+ }
+
+ // 阈值设置
var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
if teaconst.IsPlus && len(params.ThresholdsJSON) > 0 {
_ = json.Unmarshal(params.ThresholdsJSON, &thresholds)
@@ -54,7 +56,7 @@ func (this *CreatePopupAction) RunPost(params struct {
"ip": params.IP,
"id": 0,
"isOn": true,
- "isUp": true,
+ "isUp": params.IsUp,
"thresholds": thresholds,
}
this.Success()
diff --git a/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go b/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go
index e3c0f2a5..b76b96d9 100644
--- a/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go
+++ b/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go
@@ -16,12 +16,6 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
return err
}
for _, addr := range addresses {
- var thresholdsJSON = []byte{}
- var thresholds = addr.GetSlice("thresholds")
- if len(thresholds) > 0 {
- thresholdsJSON, _ = json.Marshal(thresholds)
- }
-
addrId := addr.GetInt64("id")
if addrId > 0 {
var isOn = false
@@ -37,19 +31,34 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
Name: addr.GetString("name"),
CanAccess: addr.GetBool("canAccess"),
IsOn: isOn,
- ThresholdsJSON: thresholdsJSON,
})
if err != nil {
return err
}
} else {
- _, err = parentAction.RPC().NodeIPAddressRPC().CreateNodeIPAddress(parentAction.AdminContext(), &pb.CreateNodeIPAddressRequest{
- NodeId: nodeId,
- Role: role,
- Name: addr.GetString("name"),
- Ip: addr.GetString("ip"),
- CanAccess: addr.GetBool("canAccess"),
- ThresholdsJSON: thresholdsJSON,
+ createResp, err := parentAction.RPC().NodeIPAddressRPC().CreateNodeIPAddress(parentAction.AdminContext(), &pb.CreateNodeIPAddressRequest{
+ NodeId: nodeId,
+ Role: role,
+ Name: addr.GetString("name"),
+ Ip: addr.GetString("ip"),
+ CanAccess: addr.GetBool("canAccess"),
+ })
+ if err != nil {
+ return err
+ }
+ addrId = createResp.NodeIPAddressId
+ }
+
+ // 保存阈值
+ var thresholds = addr.GetSlice("thresholds")
+ if len(thresholds) > 0 {
+ thresholdsJSON, err := json.Marshal(thresholds)
+ if err != nil {
+ return err
+ }
+ _, err = parentAction.RPC().NodeIPAddressThresholdRPC().UpdateAllNodeIPAddressThresholds(parentAction.AdminContext(), &pb.UpdateAllNodeIPAddressThresholdsRequest{
+ NodeIPAddressId: addrId,
+ NodeIPAddressThresholdsJSON: thresholdsJSON,
})
if err != nil {
return err
@@ -58,3 +67,35 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
}
return nil
}
+
+// InitNodeIPAddressThresholds 初始化IP阈值
+func InitNodeIPAddressThresholds(parentAction *actionutils.ParentAction, addrId int64) ([]*nodeconfigs.NodeValueThresholdConfig, error) {
+ thresholdsResp, err := parentAction.RPC().NodeIPAddressThresholdRPC().FindAllEnabledNodeIPAddressThresholds(parentAction.AdminContext(), &pb.FindAllEnabledNodeIPAddressThresholdsRequest{NodeIPAddressId: addrId})
+ if err != nil {
+ return nil, err
+ }
+ var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
+ if len(thresholdsResp.NodeIPAddressThresholds) > 0 {
+ for _, pbThreshold := range thresholdsResp.NodeIPAddressThresholds {
+ var threshold = &nodeconfigs.NodeValueThresholdConfig{
+ Id: pbThreshold.Id,
+ Items: []*nodeconfigs.NodeValueThresholdItemConfig{},
+ Actions: []*nodeconfigs.NodeValueThresholdActionConfig{},
+ }
+ if len(pbThreshold.ItemsJSON) > 0 {
+ err = json.Unmarshal(pbThreshold.ItemsJSON, &threshold.Items)
+ if err != nil {
+ return nil, err
+ }
+ }
+ if len(pbThreshold.ActionsJSON) > 0 {
+ err = json.Unmarshal(pbThreshold.ActionsJSON, &threshold.Actions)
+ if err != nil {
+ return nil, err
+ }
+ }
+ thresholds = append(thresholds, threshold)
+ }
+ }
+ return thresholds, nil
+}
diff --git a/internal/web/actions/default/nodes/ipAddresses/updatePopup.go b/internal/web/actions/default/nodes/ipAddresses/updatePopup.go
index 51a5b39a..66f6ac0a 100644
--- a/internal/web/actions/default/nodes/ipAddresses/updatePopup.go
+++ b/internal/web/actions/default/nodes/ipAddresses/updatePopup.go
@@ -34,6 +34,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
Name string
CanAccess bool
IsOn bool
+ IsUp bool
ThresholdsJSON []byte
Must *actions.Must
@@ -43,7 +44,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
Require("请输入IP地址")
// 获取IP地址信息
- var isUp = true
+ var isUp = params.IsUp
if params.AddressId > 0 {
addressResp, err := this.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(this.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{NodeIPAddressId: params.AddressId})
if err != nil {
diff --git a/web/public/js/components/common/labels.js b/web/public/js/components/common/labels.js
index fdbc9263..86e57d0f 100644
--- a/web/public/js/components/common/labels.js
+++ b/web/public/js/components/common/labels.js
@@ -26,5 +26,5 @@ Vue.component("micro-basic-label", {
// 灰色的Label
Vue.component("grey-label", {
- template: ``
+ template: ``
})
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 296a3327..6152bb74 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
@@ -5,209 +5,459 @@ Vue.component("node-ip-address-thresholds-box", {
let thresholds = this.vThresholds
if (thresholds == null) {
thresholds = []
+ } else {
+ thresholds.forEach(function (v) {
+ if (v.items == null) {
+ v.items = []
+ }
+ if (v.actions == null) {
+ v.actions = []
+ }
+ })
}
- let avgRequests = {
- duration: "",
- operator: "lte",
- value: ""
- }
-
- let avgTrafficOut = {
- duration: "",
- operator: "lte",
- value: ""
- }
-
- let avgTrafficIn = {
- duration: "",
- operator: "lte",
- value: ""
- }
-
- thresholds.forEach(function (v) {
- switch (v.item) {
- case "avgRequests":
- avgRequests.duration = v.duration
- avgRequests.operator = v.operator
- avgRequests.value = v.value.toString()
- break
- case "avgTrafficOut":
- avgTrafficOut.duration = v.duration
- avgTrafficOut.operator = v.operator
- avgTrafficOut.value = v.value.toString()
- break
- case "avgTrafficIn":
- avgTrafficIn.duration = v.duration
- avgTrafficIn.operator = v.operator
- avgTrafficIn.value = v.value.toString()
- break
- }
- })
-
return {
+ editingIndex: -1,
thresholds: thresholds,
- avgRequests: avgRequests,
- avgTrafficOut: avgTrafficOut,
- avgTrafficIn: avgTrafficIn
- }
- },
- watch: {
- "avgRequests.duration": function () {
- this.compose()
- },
- "avgRequests.operator": function () {
- this.compose()
- },
- "avgRequests.value": function () {
- this.compose()
- },
- "avgTrafficOut.duration": function () {
- this.compose()
- },
- "avgTrafficOut.operator": function () {
- this.compose()
- },
- "avgTrafficOut.value": function () {
- this.compose()
- },
- "avgTrafficIn.duration": function () {
- this.compose()
- },
- "avgTrafficIn.operator": function () {
- this.compose()
- },
- "avgTrafficIn.value": function () {
- this.compose()
+ addingThreshold: {
+ items: [],
+ actions: []
+ },
+ isAdding: false,
+ isAddingItem: false,
+ isAddingAction: false,
+
+ itemCode: "avgRequests",
+ 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": "%"
+ },
+ ],
+ allOperators: [
+ {
+ "name": "小于等于",
+ "code": "lte"
+ },
+ {
+ "name": "大于",
+ "code": "gt"
+ },
+ {
+ "name": "不等于",
+ "code": "neq"
+ },
+ {
+ "name": "小于",
+ "code": "lt"
+ },
+ {
+ "name": "大于等于",
+ "code": "gte"
+ }
+ ],
+ allActions: [
+ {
+ "name": "上线",
+ "code": "up",
+ "description": "上线当前IP。"
+ },
+ {
+ "name": "下线",
+ "code": "down",
+ "description": "下线当前IP。"
+ },
+ {
+ "name": "通知",
+ "code": "notify",
+ "description": "发送已达到阈值通知。"
+ }
+ ],
+
+ actionCode: "up"
}
},
methods: {
- compose: function () {
- let thresholds = []
-
- // avg requests
- {
- let duration = parseInt(this.avgRequests.duration)
- let value = parseInt(this.avgRequests.value)
- if (!isNaN(duration) && duration > 0 && !isNaN(value) && value > 0) {
- thresholds.push({
- item: "avgRequests",
- operator: this.avgRequests.operator,
- duration: duration,
- durationUnit: "minute",
- value: value
- })
- }
+ add: function () {
+ this.isAdding = !this.isAdding
+ },
+ cancel: function () {
+ this.isAdding = false
+ this.editingIndex = -1
+ this.addingThreshold = {
+ items: [],
+ actions: []
+ }
+ },
+ confirm: function () {
+ if (this.addingThreshold.items.length == 0) {
+ teaweb.warn("需要至少添加一个阈值")
+ return
+ }
+ if (this.addingThreshold.actions.length == 0) {
+ teaweb.warn("需要至少添加一个动作")
+ return
}
- // avg traffic out
- {
- let duration = parseInt(this.avgTrafficOut.duration)
- let value = parseInt(this.avgTrafficOut.value)
- if (!isNaN(duration) && duration > 0 && !isNaN(value) && value > 0) {
- thresholds.push({
- item: "avgTrafficOut",
- operator: this.avgTrafficOut.operator,
- duration: duration,
- durationUnit: "minute",
- value: value
- })
- }
+ if (this.editingIndex >= 0) {
+ this.thresholds[this.editingIndex].items = this.addingThreshold.items
+ this.thresholds[this.editingIndex].actions = this.addingThreshold.actions
+ } else {
+ this.thresholds.push({
+ items: this.addingThreshold.items,
+ actions: this.addingThreshold.actions
+ })
}
- // avg requests
- {
- let duration = parseInt(this.avgTrafficIn.duration)
- let value = parseInt(this.avgTrafficIn.value)
- if (!isNaN(duration) && duration > 0 && !isNaN(value) && value > 0) {
- thresholds.push({
- item: "avgTrafficIn",
- operator: this.avgTrafficIn.operator,
- duration: duration,
- durationUnit: "minute",
- value: value
- })
- }
+ // 还原
+ this.cancel()
+ },
+ remove: function (index) {
+ this.cancel()
+ this.thresholds.$remove(index)
+ },
+ update: function (index) {
+ this.editingIndex = index
+ this.addingThreshold = {
+ items: this.thresholds[index].items.$copy(),
+ actions: this.thresholds[index].actions.$copy()
+ }
+ this.isAdding = true
+ },
+
+ addItem: function () {
+ this.isAddingItem = !this.isAddingItem
+ let that = this
+ setTimeout(function () {
+ that.$refs.itemValue.focus()
+ }, 100)
+ },
+ cancelItem: function () {
+ this.isAddingItem = false
+
+ this.itemCode = "avgRequests"
+ this.itmeOperator = "lte"
+ this.itemValue = ""
+ this.itemDuration = "1"
+ this.itemReportGroups = []
+ },
+ confirmItem: function () {
+ if (this.itemDuration.length == 0) {
+ let that = this
+ teaweb.warn("请输入统计周期", function () {
+ that.$refs.itemDuration.focus()
+ })
+ return
+ }
+ let itemDuration = parseInt(this.itemDuration)
+ if (isNaN(itemDuration) || itemDuration <= 0) {
+ teaweb.warn("请输入正确的统计周期", function () {
+ that.$refs.itemDuration.focus()
+ })
+ return
}
- this.thresholds = thresholds
+ if (this.itemValue.length == 0) {
+ let that = this
+ teaweb.warn("请输入对比值", function () {
+ that.$refs.itemValue.focus()
+ })
+ return
+ }
+ let itemValue = parseFloat(this.itemValue)
+ if (isNaN(itemValue)) {
+ teaweb.warn("请输入正确的对比值", function () {
+ that.$refs.itemValue.focus()
+ })
+ return
+ }
+
+
+ let options = {}
+
+ switch (this.itemCode) {
+ case "connectivity": // 连通性校验
+ if (itemValue > 100) {
+ let that = this
+ teaweb.warn("连通性对比值不能超过100", function () {
+ that.$refs.itemValue.focus()
+ })
+ return
+ }
+
+ options["groups"] = this.itemReportGroups
+ break
+ }
+
+ // 添加
+ this.addingThreshold.items.push({
+ item: this.itemCode,
+ operator: this.itemOperator,
+ value: itemValue,
+ duration: itemDuration,
+ durationUnit: "minute",
+ options: options
+ })
+
+ // 还原
+ this.cancelItem()
+ },
+ removeItem: function (index) {
+ this.cancelItem()
+ this.addingThreshold.items.$remove(index)
+ },
+ changeReportGroups: function (groups) {
+ this.itemReportGroups = groups
+ },
+ itemName: function (item) {
+ let result = ""
+ this.allItems.forEach(function (v) {
+ if (v.code == item) {
+ result = v.name
+ }
+ })
+ return result
+ },
+ itemUnitName: function (itemCode) {
+ let result = ""
+ this.allItems.forEach(function (v) {
+ if (v.code == itemCode) {
+ result = v.unit
+ }
+ })
+ return result
+ },
+ itemDurationUnitName: function (unit) {
+ switch (unit) {
+ case "minute":
+ return "分钟"
+ case "second":
+ return "秒"
+ case "hour":
+ return "小时"
+ case "day":
+ return "天"
+ }
+ return unit
+ },
+ itemOperatorName: function (operator) {
+ let result = ""
+ this.allOperators.forEach(function (v) {
+ if (v.code == operator) {
+ result = v.name
+ }
+ })
+ return result
+ },
+
+ addAction: function () {
+ this.isAddingAction = !this.isAddingAction
+ },
+ cancelAction: function () {
+ this.isAddingAction = false
+ this.actionCode = "up"
+ },
+ confirmAction: function () {
+ // 是否已存在
+ let exists = false
+ let that = this
+ this.addingThreshold.actions.forEach(function (v) {
+ if (v.action == that.actionCode) {
+ exists = true
+ }
+ })
+ if (exists) {
+ teaweb.warn("此动作已经添加过了,无需重复添加")
+ return
+ }
+
+ this.addingThreshold.actions.push({
+ action: this.actionCode,
+ options: {}
+ })
+
+ // 还原
+ this.cancelAction()
+ },
+ removeAction: function (index) {
+ this.cancelAction()
+ this.addingThreshold.actions.$remove(index)
+ },
+ actionName: function (actionCode) {
+ let result = ""
+ this.allActions.forEach(function (v) {
+ if (v.code == actionCode) {
+ result = v.name
+ }
+ })
+ return result
}
},
template: `
-
-
+
+
+
+
+
[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}}
+
+ [{{group.name}} ]
+
+ [{{itemOperatorName(item.operator)}}] {{item.value}}{{itemUnitName(item.item)}} AND
+ ->
+
{{actionName(action.action)}} AND
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+ [{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}}
+
+ [{{group.name}} ]
+ [{{itemOperatorName(item.operator)}}] {{item.value}}{{itemUnitName(item.item)}}
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ {{actionName(action.action)}}
+
+
+
+
+
+
+
+
+ | 动作类型 |
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
`
})
\ No newline at end of file
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
new file mode 100644
index 00000000..0faa04b8
--- /dev/null
+++ b/web/public/js/components/node/node-ip-address-thresholds-view.js
@@ -0,0 +1,153 @@
+// 节点IP阈值
+Vue.component("node-ip-address-thresholds-view", {
+ props: ["v-thresholds"],
+ data: function () {
+ let thresholds = this.vThresholds
+ if (thresholds == null) {
+ thresholds = []
+ } else {
+ thresholds.forEach(function (v) {
+ if (v.items == null) {
+ v.items = []
+ }
+ if (v.actions == null) {
+ v.actions = []
+ }
+ })
+ }
+
+ 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": "%"
+ },
+ ],
+ allOperators: [
+ {
+ "name": "小于等于",
+ "code": "lte"
+ },
+ {
+ "name": "大于",
+ "code": "gt"
+ },
+ {
+ "name": "不等于",
+ "code": "neq"
+ },
+ {
+ "name": "小于",
+ "code": "lt"
+ },
+ {
+ "name": "大于等于",
+ "code": "gte"
+ }
+ ],
+ allActions: [
+ {
+ "name": "上线",
+ "code": "up",
+ "description": "上线当前IP。"
+ },
+ {
+ "name": "下线",
+ "code": "down",
+ "description": "下线当前IP。"
+ },
+ {
+ "name": "通知",
+ "code": "notify",
+ "description": "发送已达到阈值通知。"
+ }
+ ]
+ }
+ },
+ methods: {
+ itemName: function (item) {
+ let result = ""
+ this.allItems.forEach(function (v) {
+ if (v.code == item) {
+ result = v.name
+ }
+ })
+ return result
+ },
+ itemUnitName: function (itemCode) {
+ let result = ""
+ this.allItems.forEach(function (v) {
+ if (v.code == itemCode) {
+ result = v.unit
+ }
+ })
+ return result
+ },
+ itemDurationUnitName: function (unit) {
+ switch (unit) {
+ case "minute":
+ return "分钟"
+ case "second":
+ return "秒"
+ case "hour":
+ return "小时"
+ case "day":
+ return "天"
+ }
+ return unit
+ },
+ itemOperatorName: function (operator) {
+ let result = ""
+ this.allOperators.forEach(function (v) {
+ if (v.code == operator) {
+ result = v.name
+ }
+ })
+ return result
+ },
+ actionName: function (actionCode) {
+ let result = ""
+ this.allActions.forEach(function (v) {
+ if (v.code == actionCode) {
+ result = v.name
+ }
+ })
+ return result
+ }
+ },
+ template: `
+
+
+
+ [{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}}
+
+ [{{group.name}} ]
+
+ [{{itemOperatorName(item.operator)}}] {{item.value}}{{itemUnitName(item.item)}} AND
+ ->
+ {{actionName(action.action)}} AND
+
+
+
`
+})
\ No newline at end of file
diff --git a/web/public/js/components/node/node-ip-addresses-box.js b/web/public/js/components/node/node-ip-addresses-box.js
index 6ef965ce..9dbc1ca2 100644
--- a/web/public/js/components/node/node-ip-addresses-box.js
+++ b/web/public/js/components/node/node-ip-addresses-box.js
@@ -56,7 +56,7 @@ Vue.component("node-ip-addresses-box", {
(不可访问)
[off]
[down]
- [阈值]
+ [{{address.thresholds.length}}个阈值]
diff --git a/web/public/js/components/report/report-node-groups-selector.js b/web/public/js/components/report/report-node-groups-selector.js
index f0748011..f0fc3cff 100644
--- a/web/public/js/components/report/report-node-groups-selector.js
+++ b/web/public/js/components/report/report-node-groups-selector.js
@@ -36,6 +36,24 @@ Vue.component("report-node-groups-selector", {
that.groupIds.push(v.id)
}
})
+ this.change()
+ },
+ change: function () {
+ let that = this
+ let groups = []
+ this.groupIds.forEach(function (groupId) {
+ let group = that.groups.$find(function (k, v) {
+ return v.id == groupId
+ })
+ if (group == null) {
+ return
+ }
+ groups.push({
+ id: group.id,
+ name: group.name
+ })
+ })
+ this.$emit("change", groups)
}
},
watch: {
@@ -46,6 +64,8 @@ Vue.component("report-node-groups-selector", {
v.isChecked = false
})
}
+
+ this.change()
}
},
template: `
diff --git a/web/views/@default/clusters/cluster/node/updateDNSPopup.html b/web/views/@default/clusters/cluster/node/updateDNSPopup.html
index 7cf669fa..3a8ec1d3 100644
--- a/web/views/@default/clusters/cluster/node/updateDNSPopup.html
+++ b/web/views/@default/clusters/cluster/node/updateDNSPopup.html
@@ -31,6 +31,10 @@
+
+ | 线路 |
+ 当前集群没有选择域名。 |
+
diff --git a/web/views/@default/clusters/grants/index.html b/web/views/@default/clusters/grants/index.html
index 7b3af469..7d72ab32 100644
--- a/web/views/@default/clusters/grants/index.html
+++ b/web/views/@default/clusters/grants/index.html
@@ -11,6 +11,8 @@
diff --git a/web/views/@default/clusters/ip-addrs/addr/index.html b/web/views/@default/clusters/ip-addrs/addr/index.html
index b83352be..9de5a80b 100644
--- a/web/views/@default/clusters/ip-addrs/addr/index.html
+++ b/web/views/@default/clusters/ip-addrs/addr/index.html
@@ -11,7 +11,8 @@
| 状态 |
-
+ 不可访问
+ 禁用
在线
离线
|
@@ -33,20 +34,11 @@
-
-
- | 是否可以访问 |
-
- Y
- N
- |
-
| 阈值 |
-
- {{threshold.item}} {{threshold.operator}} {{threshold.value}}
-
+
没有设置阈值。
|
diff --git a/web/views/@default/clusters/monitors/reporters/index.html b/web/views/@default/clusters/monitors/reporters/index.html
index 3f09c9ac..cd3705ca 100644
--- a/web/views/@default/clusters/monitors/reporters/index.html
+++ b/web/views/@default/clusters/monitors/reporters/index.html
@@ -42,7 +42,7 @@
{{reporter.name}}
- {{group.name}}
+ {{group.name}}
v{{reporter.status.buildVersion}} -> v{{reporter.newVersion}}
diff --git a/web/views/@default/dns/index.html b/web/views/@default/dns/index.html
index a064d8b4..9d9aabea 100644
--- a/web/views/@default/dns/index.html
+++ b/web/views/@default/dns/index.html
@@ -9,6 +9,8 @@
diff --git a/web/views/@default/dns/issues/updateNodePopup.html b/web/views/@default/dns/issues/updateNodePopup.html
index 43556626..04a96460 100644
--- a/web/views/@default/dns/issues/updateNodePopup.html
+++ b/web/views/@default/dns/issues/updateNodePopup.html
@@ -31,6 +31,10 @@
|
+
+ | 线路 |
+ 当前集群没有选择域名。 |
+
diff --git a/web/views/@default/dns/providers/index.html b/web/views/@default/dns/providers/index.html
index df2d7cd4..7d86112b 100644
--- a/web/views/@default/dns/providers/index.html
+++ b/web/views/@default/dns/providers/index.html
@@ -13,6 +13,8 @@
diff --git a/web/views/@default/nodes/ipAddresses/createPopup.html b/web/views/@default/nodes/ipAddresses/createPopup.html
index 513d75c3..f701f3f0 100644
--- a/web/views/@default/nodes/ipAddresses/createPopup.html
+++ b/web/views/@default/nodes/ipAddresses/createPopup.html
@@ -30,8 +30,17 @@
+
+ | 在线状态 |
+
+
+ |
+
- | 上线阈值 |
+ 阈值设置 |
|
diff --git a/web/views/@default/nodes/ipAddresses/updatePopup.html b/web/views/@default/nodes/ipAddresses/updatePopup.html
index 0efbe274..611c3da4 100644
--- a/web/views/@default/nodes/ipAddresses/updatePopup.html
+++ b/web/views/@default/nodes/ipAddresses/updatePopup.html
@@ -41,8 +41,17 @@
+
+ | 在线状态 |
+
+
+ |
+
- | 上线阈值 |
+ 阈值设置 |
|
diff --git a/web/views/@default/nodes/ipAddresses/updatePopup.js b/web/views/@default/nodes/ipAddresses/updatePopup.js
index cd35c2f6..da22a175 100644
--- a/web/views/@default/nodes/ipAddresses/updatePopup.js
+++ b/web/views/@default/nodes/ipAddresses/updatePopup.js
@@ -2,4 +2,7 @@ Tea.context(function () {
this.success = NotifyPopup;
this.address = window.parent.UPDATING_NODE_IP_ADDRESS
-});
\ No newline at end of file
+ if (this.address != null) {
+ this.address.isUp = (this.address.isUp ? 1 : 0)
+ }
+})
\ No newline at end of file
diff --git a/web/views/@default/ns/domains/index.html b/web/views/@default/ns/domains/index.html
index 45e510a1..0cdb1980 100644
--- a/web/views/@default/ns/domains/index.html
+++ b/web/views/@default/ns/domains/index.html
@@ -21,6 +21,8 @@
diff --git a/web/views/@default/servers/certs/index.html b/web/views/@default/servers/certs/index.html
index 3d3a4661..a7646291 100644
--- a/web/views/@default/servers/certs/index.html
+++ b/web/views/@default/servers/certs/index.html
@@ -14,12 +14,15 @@
@@ -39,7 +42,7 @@
- | {{cert.name}}
+ | {{cert.name}}
CA
@@ -52,7 +55,7 @@
|
- {{dnsName}}
+ {{dnsName}}
|
{{certInfos[index].beginDay}} |
diff --git a/web/views/@default/servers/components/cache/index.html b/web/views/@default/servers/components/cache/index.html
index 4a9c76f1..b1925fa5 100644
--- a/web/views/@default/servers/components/cache/index.html
+++ b/web/views/@default/servers/components/cache/index.html
@@ -15,6 +15,8 @@
diff --git a/web/views/@default/servers/components/waf/group.html b/web/views/@default/servers/components/waf/group.html
index 36115ceb..30c28ee8 100644
--- a/web/views/@default/servers/components/waf/group.html
+++ b/web/views/@default/servers/components/waf/group.html
@@ -39,7 +39,7 @@
| |
- {{set.name}}
+ | {{set.name}}
diff --git a/web/views/@default/servers/components/waf/groups.html b/web/views/@default/servers/components/waf/groups.html
index 297ac034..d60ebbf7 100644
--- a/web/views/@default/servers/components/waf/groups.html
+++ b/web/views/@default/servers/components/waf/groups.html
@@ -20,9 +20,9 @@
|
| |
- {{group.name}}
+ | {{group.name}}
-
+
启用
停用
预置
diff --git a/web/views/@default/servers/components/waf/index.html b/web/views/@default/servers/components/waf/index.html
index 037c16ba..2068ca17 100644
--- a/web/views/@default/servers/components/waf/index.html
+++ b/web/views/@default/servers/components/waf/index.html
@@ -15,6 +15,8 @@
diff --git a/web/views/@default/servers/index.html b/web/views/@default/servers/index.html
index 7487b8bd..40975177 100644
--- a/web/views/@default/servers/index.html
+++ b/web/views/@default/servers/index.html
@@ -47,8 +47,10 @@
-
diff --git a/web/views/@default/servers/server/settings/waf/group.html b/web/views/@default/servers/server/settings/waf/group.html
index b8ad3146..8abcf2f1 100644
--- a/web/views/@default/servers/server/settings/waf/group.html
+++ b/web/views/@default/servers/server/settings/waf/group.html
@@ -41,7 +41,7 @@
|
| |
- {{set.name}}
+ | {{set.name}}
diff --git a/web/views/@default/servers/server/settings/waf/groups.html b/web/views/@default/servers/server/settings/waf/groups.html
index 0f545baf..b1edc653 100644
--- a/web/views/@default/servers/server/settings/waf/groups.html
+++ b/web/views/@default/servers/server/settings/waf/groups.html
@@ -24,9 +24,9 @@
|
| |
- {{group.name}}
+ | {{group.name}}
-
+
启用
停用
预置
|