阶段性提交

This commit is contained in:
刘祥超
2021-06-27 21:59:06 +08:00
parent bd34a9bd37
commit 963be2bc63
42 changed files with 956 additions and 139 deletions

View File

@@ -0,0 +1,7 @@
<first-menu>
<menu-item :href="'/servers/metrics'">指标列表</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/servers/metrics/item?itemId=' + item.id" code="item">"{{item.name}}"详情</menu-item>
<menu-item :href="'/servers/metrics/update?itemId=' + item.id" code="update">修改</menu-item>
<menu-item :href="'/servers/metrics/charts?itemId=' + item.id" code="chart">图表</menu-item>
</first-menu>

View File

@@ -0,0 +1,4 @@
{$layout}
{$template "item_menu"}
<p class="ui message warning">此功能暂未开通,敬等期待。</p>

View File

@@ -0,0 +1,54 @@
{$layout "layout_popup"}
<h3>创建{{category.toUpperCase()}}统计指标</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="category" :value="category"/>
<table class="ui table definition selectable">
<tr>
<td class="title">指标名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus"/>
</td>
</tr>
<tr>
<td>统计对象 *</td>
<td>
<metric-keys-config-box :v-category="category"></metric-keys-config-box>
</td>
</tr>
<tr>
<td>统计周期 *</td>
<td>
<metric-period-config-box></metric-period-config-box>
</td>
</tr>
<tr>
<td>统计数值 *</td>
<td>
<!-- HTTP -->
<select class="ui dropdown auto-width" name="value" v-if="category == 'http'">
<option value="${countRequest}">请求数</option>
<option value="${countConnection}">连接数</option>
<option value="${countTrafficIn}">下行流量</option>
<option value="${countTrafficOut}">上行流量</option>
</select>
<!-- TCP -->
<select class="ui dropdown auto-width" name="value" v-if="category == 'tcp'">
<option value="${countConnection}">连接数</option>
<option value="${countTrafficIn}">下行流量</option>
<option value="${countTrafficOut}">上行流量</option>
</select>
<!-- UDP -->
<select class="ui dropdown auto-width" name="value" v-if="category == 'udp'">
<option value="${countConnection}">连接数</option>
<option value="${countTrafficIn}">下行流量</option>
<option value="${countTrafficOut}">上行流量</option>
</select>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,46 @@
{$layout}
<first-menu>
<menu-item :href="'/servers/metrics?category=http'" :active="category == 'http'">HTTP</menu-item>
<menu-item :href="'/servers/metrics?category=tcp'" :active="category == 'tcp'">TCP</menu-item>
<menu-item :href="'/servers/metrics?category=udp'" :active="category == 'udp'">UDP</menu-item>
<span class="item disabled">|</span>
<menu-item @click.prevent="createItem">[创建指标]</menu-item>
<span class="item disabled">|</span>
<span class="item"><tip-icon content="在这里创建一些指标后,可以在集群中使用这些指标,从而实现阈值、图表等功能"></tip-icon></span>
</first-menu>
<p class="comment" v-if="items.length == 0">暂时还没有指标。</p>
<table class="ui table celled selectable" v-if="items.length > 0">
<thead>
<tr>
<th>指标名称</th>
<th>统计对象</th>
<th>统计周期</th>
<th class="three wide">统计数值</th>
<th class="two wide">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="item in items">
<td>{{item.name}}</td>
<td>
<span v-if="item.keys != null" v-for="key in item.keys" class="ui label basic small">{{key}}</span>
</td>
<td>
{{item.period}} {{item.periodUnit}}
</td>
<td>
<span class="ui label small basic">{{item.value}}</span>
</td>
<td>
<label-on :v-is-on="item.isOn"></label-on>
</td>
<td>
<a :href="'/servers/metrics/item?itemId=' + item.id">详情</a> &nbsp;
<a href="" @click.prevent="deleteItem(item.id)">删除</a>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -0,0 +1,27 @@
Tea.context(function () {
this.createItem = function () {
teaweb.popup(Tea.url(".createPopup?category=" + this.category), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
},
height: "26em"
})
}
this.deleteItem = function (itemId) {
let that = this
teaweb.confirm("确定要删除此指标吗?", function () {
that.$post(".delete")
.params({
itemId: itemId
})
.success(function () {
teaweb.success("删除成功", function () {
teaweb.reload()
})
})
})
}
})

View File

@@ -0,0 +1,27 @@
{$layout}
{$template "item_menu"}
<table class="ui table definition selectable">
<tr>
<td class="title">指标名称</td>
<td>
{{item.name}}
</td>
</tr>
<tr>
<td>状态</td>
<td><label-on :v-is-on="item.isOn"></label-on></td>
</tr>
<tr>
<td>统计周期</td>
<td>
{{item.period}} {{item.periodUnit}}
</td>
</tr>
<tr>
<td>统计数值</td>
<td>
{{item.value}}
</td>
</tr>
</table>

View File

@@ -0,0 +1,60 @@
{$layout "layout"}
{$template "item_menu"}
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="itemId" :value="item.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">指标名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus" v-model="item.name"/>
</td>
</tr>
<tr>
<td>统计对象 *</td>
<td>
<metric-keys-config-box :v-category="item.category" :v-keys="item.keys"></metric-keys-config-box>
</td>
</tr>
<tr>
<td>统计周期 *</td>
<td>
<metric-period-config-box :v-period="item.period" :v-period-unit="item.periodUnit"></metric-period-config-box>
</td>
</tr>
<tr>
<td>统计数值 *</td>
<td>
<!-- HTTP -->
<select class="ui dropdown auto-width" name="value" v-if="item.category == 'http'" v-model="item.value">
<option value="${countRequest}">请求数</option>
<option value="${countConnection}">连接数</option>
<option value="${countTrafficIn}">下行流量</option>
<option value="${countTrafficOut}">上行流量</option>
</select>
<!-- TCP -->
<select class="ui dropdown auto-width" name="value" v-if="item.category == 'tcp'">
<option value="${countConnection}">连接数</option>
<option value="${countTrafficIn}">下行流量</option>
<option value="${countTrafficOut}">上行流量</option>
</select>
<!-- UDP -->
<select class="ui dropdown auto-width" name="value" v-if="item.category == 'udp'">
<option value="${countConnection}">连接数</option>
<option value="${countTrafficIn}">下行流量</option>
<option value="${countTrafficOut}">上行流量</option>
</select>
</td>
</tr>
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" v-model="item.isOn" value="1"></checkbox>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,3 @@
Tea.context(function () {
this.success = NotifySuccess("保存成功", "/servers/metrics/item?itemId=" + this.item.id)
})