节点IP阈值增加节点健康检查失败

This commit is contained in:
刘祥超
2021-11-18 14:30:46 +08:00
parent 411b0fb4c2
commit 884342d6af
3 changed files with 67 additions and 24 deletions

View File

@@ -127,6 +127,21 @@ Vue.component("node-ip-address-thresholds-box", {
this.itemReportGroups = [] this.itemReportGroups = []
}, },
confirmItem: function () { confirmItem: function () {
// 特殊阈值快速添加
if (["nodeHealthCheckFailed"].$contains(this.itemCode)) {
// 添加
this.addingThreshold.items.push({
item: this.itemCode,
operator: this.itemOperator,
value: 0,
duration: 0,
durationUnit: "minute",
options: {}
})
this.cancelItem()
return
}
if (this.itemDuration.length == 0) { if (this.itemDuration.length == 0) {
let that = this let that = this
teaweb.warn("请输入统计周期", function () { teaweb.warn("请输入统计周期", function () {
@@ -335,11 +350,20 @@ Vue.component("node-ip-address-thresholds-box", {
<!-- 已有条件 --> <!-- 已有条件 -->
<div v-if="thresholds.length > 0"> <div v-if="thresholds.length > 0">
<div class="ui label basic small" v-for="(threshold, index) in thresholds"> <div class="ui label basic small" v-for="(threshold, index) in thresholds">
<span v-for="(item, itemIndex) in threshold.items">[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}} <span v-for="(item, itemIndex) in threshold.items">
<!-- 连通性 --> <span v-if="item.item != 'nodeHealthCheckFailed'">
<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">&nbsp; </span></span>]</span> [{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}]
</span>
<span class="grey">[{{itemOperatorName(item.operator)}}]</span> &nbsp;{{item.value}}{{itemUnitName(item.item)}} &nbsp;<span v-if="itemIndex != threshold.items.length - 1" style="font-style: italic">AND &nbsp;</span></span> {{itemName(item.item)}}
<span v-if="item.item != 'nodeHealthCheckFailed'">
<!-- 连通性 -->
<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">&nbsp; </span></span>]</span>
<span class="grey">[{{itemOperatorName(item.operator)}}]</span> &nbsp;{{item.value}}{{itemUnitName(item.item)}}
</span>
&nbsp;<span v-if="itemIndex != threshold.items.length - 1" style="font-style: italic">AND &nbsp;</span>
</span>
-&gt; -&gt;
<span v-for="(action, actionIndex) in threshold.actions">{{actionName(action.action)}} <span v-for="(action, actionIndex) in threshold.actions">{{actionName(action.action)}}
<span v-if="action.action == 'switch'">到{{action.options.ips.join(", ")}}</span> <span v-if="action.action == 'switch'">到{{action.options.ips.join(", ")}}</span>
@@ -365,10 +389,17 @@ Vue.component("node-ip-address-thresholds-box", {
<!-- 已经添加的项目 --> <!-- 已经添加的项目 -->
<div> <div>
<div v-for="(item, index) in addingThreshold.items" class="ui label basic small" style="margin-bottom: 0.5em;"> <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 != 'nodeHealthCheckFailed'">
<!-- 连通性 --> [{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}]
<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">&nbsp; </span></span>]</span> </span>
<span class="grey">[{{itemOperatorName(item.operator)}}]</span> {{item.value}}{{itemUnitName(item.item)}} &nbsp; {{itemName(item.item)}}
<span v-if="item.item != 'nodeHealthCheckFailed'">
<!-- 连通性 -->
<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">&nbsp; </span></span>]</span>
<span class="grey">[{{itemOperatorName(item.operator)}}]</span> {{item.value}}{{itemUnitName(item.item)}}
</span>
&nbsp;
<a href="" title="删除" @click.prevent="removeItem(index)"><i class="icon remove small"></i></a> <a href="" title="删除" @click.prevent="removeItem(index)"><i class="icon remove small"></i></a>
</div> </div>
</div> </div>
@@ -385,7 +416,7 @@ Vue.component("node-ip-address-thresholds-box", {
<p class="comment" v-for="item in allItems" v-if="item.code == itemCode">{{item.description}}</p> <p class="comment" v-for="item in allItems" v-if="item.code == itemCode">{{item.description}}</p>
</td> </td>
</tr> </tr>
<tr> <tr v-show="itemCode != 'nodeHealthCheckFailed'">
<td>统计周期</td> <td>统计周期</td>
<td> <td>
<div class="ui input right labeled"> <div class="ui input right labeled">
@@ -394,7 +425,7 @@ Vue.component("node-ip-address-thresholds-box", {
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr v-show="itemCode != 'nodeHealthCheckFailed'">
<td>操作符</td> <td>操作符</td>
<td> <td>
<select class="ui dropdown auto-width" v-model="itemOperator"> <select class="ui dropdown auto-width" v-model="itemOperator">
@@ -402,7 +433,7 @@ Vue.component("node-ip-address-thresholds-box", {
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr v-show="itemCode != 'nodeHealthCheckFailed'">
<td>对比值</td> <td>对比值</td>
<td> <td>
<div class="ui input right labeled"> <div class="ui input right labeled">

View File

@@ -98,17 +98,29 @@ Vue.component("node-ip-address-thresholds-view", {
template: `<div> template: `<div>
<!-- 已有条件 --> <!-- 已有条件 -->
<div v-if="thresholds.length > 0"> <div v-if="thresholds.length > 0">
<div class="ui label basic small" v-for="(threshold, index) in thresholds" style="margin-bottom: 0.5em"> <div class="ui label basic small" v-for="(threshold, index) in thresholds" style="margin-bottom: 0.8em">
<span v-for="(item, itemIndex) in threshold.items">[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}} <span v-for="(item, itemIndex) in threshold.items">
<!-- 连通性 --> <span>
<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">&nbsp; </span></span>]</span> <span v-if="item.item != 'nodeHealthCheckFailed'">
[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}]
<span class="grey">[{{itemOperatorName(item.operator)}}]</span> {{item.value}}{{itemUnitName(item.item)}} &nbsp;<span v-if="itemIndex != threshold.items.length - 1" style="font-style: italic">AND &nbsp;</span></span> </span>
-&gt; {{itemName(item.item)}}
<span v-for="(action, actionIndex) in threshold.actions">{{actionName(action.action)}}
<span v-if="action.action == 'switch'">到{{action.options.ips.join(", ")}}</span> <span v-if="item.item != 'nodeHealthCheckFailed'">
<span v-if="action.action == 'webHook'" class="small grey">({{action.options.url}})</span> <!-- 连通性 -->
&nbsp;<span v-if="actionIndex != threshold.actions.length - 1" style="font-style: italic">AND &nbsp;</span></span> <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">&nbsp; </span></span>]</span>
<span class="grey">[{{itemOperatorName(item.operator)}}]</span> {{item.value}}{{itemUnitName(item.item)}} &nbsp;
</span>
</span>
<span v-if="itemIndex != threshold.items.length - 1" style="font-style: italic">AND &nbsp;</span></span>
-&gt;
<span v-for="(action, actionIndex) in threshold.actions">{{actionName(action.action)}}
<span v-if="action.action == 'switch'">到{{action.options.ips.join(", ")}}</span>
<span v-if="action.action == 'webHook'" class="small grey">({{action.options.url}})</span>
&nbsp;
<span v-if="actionIndex != threshold.actions.length - 1" style="font-style: italic">AND &nbsp;</span>
</span>
</div> </div>
</div> </div>
</div>` </div>`

View File

@@ -5,7 +5,7 @@ Tea.context(function () {
this.updateUp = function (addrId, isUp) { this.updateUp = function (addrId, isUp) {
let status = isUp ? "在线" : "离线" let status = isUp ? "在线" : "离线"
teaweb.confirm("确定要手动将节点设置为" + status + "吗?", function () { teaweb.confirm("确定要手动将此IP设置为" + status + "吗?", function () {
this.$post(".up") this.$post(".up")
.params({ .params({
addrId: addrId, addrId: addrId,