阶段性提交

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

@@ -176,6 +176,7 @@ Vue.component("health-check-config-box", {
<td>域名</td>
<td>
<input type="text" v-model="urlHost"/>
<p class="comment">在此集群上可以访问到的一个域名。</p>
</td>
</tr>
<tr>

View File

@@ -62,7 +62,7 @@ Vue.component("tip-icon", {
teaweb.popupTip(this.content)
}
},
template: `<a href="" title="查看帮助" @click.prevent="showTip"><i class="icon question circle"></i></a>`
template: `<a href="" title="查看帮助" @click.prevent="showTip"><i class="icon question circle grey"></i></a>`
})
// 提交点击事件

View File

@@ -8,29 +8,52 @@ Vue.component("metric-keys-config-box", {
}
return {
keys: keys,
isAdding: false
isAdding: false,
key: ""
}
},
methods: {
cancel: function () {
this.key = ""
this.isAdding = false
},
confirm: function () {
if (this.key.length > 0) {
this.keys.push(this.key)
this.cancel()
}
},
add: function () {
this.isAdding = true
let that = this
setTimeout(function () {
that.$refs.key.focus()
}, 100)
},
remove: function (index) {
this.keys.$remove(index)
}
},
methods: {},
template: `<div>
<input type="hidden" name="keysJSON" :value="JSON.stringify(keys)"/>
<div>
<div v-for="key in keys">
<div v-for="(key, index) in keys" class="ui label small basic">
{{key}} &nbsp; <a href="" title="删除" @click.prevent="remove"><i class="icon remove small"></i></a>
</div>
</div>
<div>
<div v-if="isAdding" style="margin-top: 1em">
<div class="ui fields inline">
<div class="ui field">
<input type="text" placeholder=""/>
<input type="text" v-model="key" ref="key" @keyup.enter="confirm()" @keypress.enter.prevent="1"/>
</div>
<div class="ui field">
<button type="button" class="ui button tiny">确定</button>
<button type="button" class="ui button tiny" @click.prevent="confirm">确定</button>
<a href="" @click.prevent="cancel"><i class="icon remove small"></i></a>
</div>
</div>
</div>
<div>
<button type="button" class="ui button tiny">+</button>
<div style="margin-top: 1em" v-if="!isAdding">
<button type="button" class="ui button tiny" @click.prevent="add">+</button>
</div>
</div>`
})

View File

@@ -219,9 +219,9 @@ window.teaweb = {
},
popupTip: function (html) {
Swal.fire({
html: '<i class="icon question circle"></i><span style="line-height: 1.7">' + html + "</span>",
html: '<div style="line-height: 1.7;text-align: left "><i class="icon question circle"></i>' + html + "</div>",
width: "30em",
padding: "5em",
padding: "4em",
showConfirmButton: false,
showCloseButton: true,
focusConfirm: false

View File

@@ -219,9 +219,14 @@ p.margin {
.main-menu .ui.menu .sub-items .item {
padding-left: 2.8em !important;
}
.main-menu .ui.menu .sub-items .item .icon {
position: absolute;
left: 1.1em;
top: 0.93em;
}
@media screen and (max-width: 512px) {
.main-menu .ui.menu .sub-items .item {
padding-left: 1em!important;
padding-left: 1em !important;
}
}
.main-menu .ui.menu .sub-items .item.active {

File diff suppressed because one or more lines are too long

View File

@@ -85,7 +85,7 @@
<div class="subtitle" v-if="module.subtitle != null && module.subtitle.length > 0">{{module.subtitle}}</div>
</a>
<div v-if="teaMenu == module.code" class="sub-items">
<a class="item" v-for="subItem in module.subItems" v-if="subItem.isOn !== false" :href="subItem.url" :class="{active:subItem.code == teaSubMenu}">{{subItem.name}}</a>
<a class="item" v-for="subItem in module.subItems" v-if="subItem.isOn !== false" :href="subItem.url"><i class="icon angle right" v-if="subItem.code == teaSubMenu"></i> {{subItem.name}}</a>
</div>
</div>
</div>

View File

@@ -172,11 +172,17 @@ div.margin, p.margin {
.sub-items {
.item {
padding-left: 2.8em !important;
.icon {
position: absolute;
left: 1.1em;
top: 0.93em;
}
}
@media screen and (max-width: 512px) {
.item {
padding-left: 1em!important;
padding-left: 1em !important;
}
}

View File

@@ -6,7 +6,7 @@
<form method="post" class="ui form" v-if="!isRequesting">
<p>成功节点:<span class="green">{{countSuccess}}</span> &nbsp; 失败节点:<span class="red">{{countFail}}</span></p>
<table class="ui table selectable celled">
<table class="ui table selectable celled" v-if="results.length > 0">
<thead>
<tr>
<th>节点</th>

View File

@@ -0,0 +1,38 @@
{$layout "layout_popup"}
<h3>添加指标</h3>
<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="" v-if="!item.isChecked">添加</a>
<a href="" v-if="item.isChecked"><span class="grey">已添加</span></a>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -0,0 +1,47 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
<first-menu>
<menu-item :href="'/clusters/cluster/settings/metrics?category=http&clusterId=' + clusterId" :active="category == 'http'">HTTP</menu-item>
<menu-item :href="'/clusters/cluster/settings/metrics?category=tcp&clusterId=' + clusterId" :active="category == 'tcp'">TCP</menu-item>
<menu-item :href="'/clusters/cluster/settings/metrics?category=udp&clusterId=' + clusterId" :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="" @click.prevent="deleteItem(item.id)">删除</a>
</td>
</tr>
</table>
</div>

View File

@@ -0,0 +1,30 @@
Tea.context(function () {
this.createItem = function () {
teaweb.popup(Tea.url(".createPopup", {
clusterId: this.clusterId
}), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
},
width: "50em",
height: "25em"
})
}
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

@@ -12,7 +12,7 @@
<td class="title">是否启用TOA</td>
<td>
<checkbox name="isOn" v-model="toa.isOn"></checkbox>
<p class="comment">在启用之前,请确保当前集群下所有节点服务器已经安装TOA模块和libnetfilter_queue并启用了IPTables。</p>
<p class="comment">在启用之前请确保当前集群下所有节点服务器已经安装libnetfilter_queue并启用了IPTables。</p>
</td>
</tr>
<tbody v-show="toa.isOn">

View File

@@ -41,6 +41,7 @@
<td>绑定域名</td>
<td>
<server-name-box></server-name-box>
<p class="comment">绑定后,才能通过域名可以访问不同的服务。</p>
</td>
</tr>

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)
})