实现一些阈值设置细节

This commit is contained in:
刘祥超
2021-05-05 19:51:13 +08:00
parent e6970abcb8
commit c350fceef3
13 changed files with 258 additions and 61 deletions

View File

@@ -3,6 +3,7 @@
<span class="item">|</span>
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + nodeId" code="node">节点详情</menu-item>
<menu-item :href="'/clusters/cluster/node/monitor?clusterId=' + clusterId + '&nodeId=' + nodeId" code="monitor" v-if="teaIsPlus">监控图表</menu-item>
<menu-item :href="'/clusters/cluster/node/thresholds?clusterId=' + clusterId + '&nodeId=' + nodeId" code="threshold" v-if="teaIsPlus">阈值设置</menu-item>
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId" code="log">运行日志</menu-item>
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + nodeId" code="update">修改设置</menu-item>
<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + nodeId" code="install">安装节点</menu-item>

View File

@@ -6,10 +6,10 @@
<script type="text/javascript" src="/js/echarts/echarts.min.js"></script>
{$end}
<h4>上行流量</h4>
<h4>上行流量(字节)</h4>
<div class="chart-box" id="traffic-in-chart"></div>
<h4>下行流量</h4>
<h4>下行流量(字节)</h4>
<div class="chart-box" id="traffic-out-chart"></div>
<h4>连接数</h4>

View File

@@ -0,0 +1,37 @@
{$layout}
{$template "../node_menu"}
<div style="margin-top: -1em">
<second-menu>
<menu-item @click.prevent="createThreshold">添加阈值</menu-item>
</second-menu>
</div>
<p class="comment" v-if="thresholds.length == 0">暂时还没有设置阈值。</p>
<table class="ui table selectable celled" v-if="thresholds.length > 0">
<thead>
<tr>
<th>监控项</th>
<th>参数</th>
<th>操作符</th>
<th>对比值</th>
<th>统计时间段</th>
<th class="two wide">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="threshold in thresholds">
<td>{{threshold.itemName}}</td>
<td>{{threshold.paramName}}</td>
<td>{{threshold.operatorName}}</td>
<td>{{threshold.value}}</td>
<td>{{threshold.duration}}{{threshold.durationUnitName}}</td>
<td>
<label-on :v-is-on="threshold.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updateThreshold(threshold.id)">修改</a> &nbsp;
<a href="" @click.prevent="deleteThreshold(threshold.id)">删除</a>
</td>
</tr>
</table>

View File

@@ -0,0 +1,41 @@
Tea.context(function () {
this.createThreshold = function () {
teaweb.popup(Tea.url("/clusters/cluster/settings/thresholds/createPopup", {
clusterId: this.clusterId,
nodeId: this.nodeId
}), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.updateThreshold = function (thresholdId) {
teaweb.popup(Tea.url("/clusters/cluster/settings/thresholds/updatePopup", {
thresholdId: thresholdId
}), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.deleteThreshold = function (thresholdId) {
let that = this
teaweb.confirm("确定要删除这个阈值吗?", function () {
that.$post(".delete")
.params({
thresholdId: thresholdId
})
.success(function () {
teaweb.success("删除成功", function () {
teaweb.reload()
})
})
})
}
})

View File

@@ -4,6 +4,7 @@
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="clusterId" :value="clusterId" />
<input type="hidden" name="nodeId" :value="nodeId"/>
<input type="hidden" name="sumMethod" value="avg"/>
<table class="ui table definition selectable">
@@ -55,12 +56,31 @@
</td>
</tr>
<tr>
<td>消息</td>
<td>
<textarea rows="2" maxlength="100" name="message"></textarea>
<p class="comment">触发阈值时的消息提示。</p>
</td>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>消息</td>
<td>
<textarea rows="2" maxlength="100" name="message"></textarea>
<p class="comment">触发阈值时的消息提示。</p>
</td>
</tr>
<tr>
<td>消息通知间隔</td>
<td>
<div class="ui fields inline">
<div class="ui field">
<input type="text" name="notifyDuration" value="10" style="width: 5em"/>
</div>
<div class="ui field">
分钟
</div>
</div>
<p class="comment">在此间隔内将不会重复发送跟此阈值相关的消息。</p>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>

View File

@@ -7,7 +7,7 @@
</first-menu>
<p class="comment" v-if="thresholds.length == 0">暂时还没有设置阈值。</p>
<table class="ui table selectable" v-if="thresholds.length > 0">
<table class="ui table selectable celled" v-if="thresholds.length > 0">
<thead>
<tr>
<th>监控项</th>
@@ -20,10 +20,14 @@
</tr>
</thead>
<tr v-for="threshold in thresholds">
<td>{{threshold.itemName}}</td>
<td>{{threshold.itemName}}
<div v-if="threshold.node != null" style="margin-top: 0.3em">
<a :href="'/clusters/cluster/node/thresholds?clusterId=' + clusterId + '&nodeId=' + threshold.node.id" class="ui label basic tiny" title="节点专属阈值设置"><span class="small">节点:{{threshold.node.name}}</span></a>
</div>
</td>
<td>{{threshold.paramName}}</td>
<td>{{threshold.operatorName}}</td>
<td>{{threshold.itemName}}</td>
<td>{{threshold.value}}</td>
<td>{{threshold.duration}}{{threshold.durationUnitName}}</td>
<td>
<label-on :v-is-on="threshold.isOn"></label-on>

View File

@@ -55,18 +55,37 @@
</td>
</tr>
<tr>
<td>消息</td>
<td>
<textarea rows="2" maxlength="100" name="message" v-model="threshold.message"></textarea>
<p class="comment">触发阈值时的消息提示。</p>
</td>
</tr>
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" value="1" v-model="threshold.isOn"></checkbox>
</td>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>消息</td>
<td>
<textarea rows="2" maxlength="100" name="message" v-model="threshold.message"></textarea>
<p class="comment">触发阈值时的消息提示。</p>
</td>
</tr>
<tr>
<td>消息通知间隔</td>
<td>
<div class="ui fields inline">
<div class="ui field">
<input type="text" name="notifyDuration" v-model="threshold.notifyDuration" value="10" style="width: 5em"/>
</div>
<div class="ui field">
分钟
</div>
</div>
<p class="comment">在此间隔内将不会重复发送跟此阈值相关的消息。</p>
</td>
</tr>
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" value="1" v-model="threshold.isOn"></checkbox>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>