实现健康检查配置、立即执行健康检查

This commit is contained in:
GoEdgeLab
2020-10-17 21:15:22 +08:00
parent 282900d611
commit bbe6253346
28 changed files with 500 additions and 115 deletions

View File

@@ -0,0 +1,10 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
<form class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="clusterId" :value="clusterId"/>
<health-check-config-box :v-health-check-config="healthCheckConfig"></health-check-config-box>
<submit-btn></submit-btn> &nbsp; <a href="" @click.prevent="run()">立即检查</a>
</form>
</div>

View File

@@ -0,0 +1,11 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
this.run = function () {
teaweb.confirm("确定要对当前集群下的所有节点进行健康检查吗?", function () {
teaweb.popup("/clusters/cluster/settings/healthRun?clusterId=" + this.clusterId, {
})
})
}
})

View File

@@ -0,0 +1,27 @@
{$layout "layout_popup"}
<h3>健康检查</h3>
<span class="red" v-if="isRequesting">正在执行中,请等待执行完毕...</span>
<form class="ui form" v-if="!isRequesting">
<p>成功节点:<span class="green">{{countSuccess}}</span> &nbsp; 失败节点:<span class="red">{{countFail}}</span></p>
<table class="ui table selectable">
<thead>
<tr>
<th>节点</th>
<th>结果</th>
<th>耗时</th>
</tr>
</thead>
<tr v-for="result in results">
<td>{{result.node.name}}<span class="small" v-if="result.nodeAddr != null && result.nodeAddr.length > 0">{{result.nodeAddr}}</span></td>
<td>
<span v-if="!result.isOk" class="red">失败:{{result.error}}</span>
<span v-else class="green">成功</span>
</td>
<td>{{result.costMs}}ms</td>
</tr>
</table>
<button class="ui button primary" type="button" @click.prevent="success">完成</button>
</form>

View File

@@ -0,0 +1,39 @@
Tea.context(function () {
this.success = NotifyPopup
this.isRequesting = false
this.results = []
this.countSuccess = 0
this.countFail = 0
this.$delay(function () {
this.run()
})
this.run = function () {
this.isRequesting = true
this.$post("$")
.params({
clusterId: this.clusterId
})
.success(function (resp) {
this.results = resp.data.results
let that = this
this.results.forEach(function (v) {
v.costMs = Math.ceil(v.costMs)
if (isNaN(v.costMs)) {
v.costMs = 0
}
if (v.isOk) {
that.countSuccess++
} else {
that.countFail++
}
})
})
.done(function () {
this.isRequesting = false
})
}
})