mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-14 20:06:34 +08:00
可以清理数据库节点的数据表
This commit is contained in:
23
web/views/@default/db/cleanPopup.html
Normal file
23
web/views/@default/db/cleanPopup.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<div class="ui message" v-if="isLoading">正在加载中...</div>
|
||||
|
||||
<table class="ui table selectable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>表名</th>
|
||||
<th>占用空间</th>
|
||||
<th>用途</th>
|
||||
<th class="two op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="table in tables">
|
||||
<td>{{table.name}}</td>
|
||||
<td>{{table.size}}</td>
|
||||
<td>{{table.comment}}</td>
|
||||
<td>
|
||||
<a href="" v-if="table.canDelete" @click.prevent="deleteTable(table.name)">删除</a><span v-if="table.canDelete"> </span>
|
||||
<a href="" v-if="table.canClean" @click.prevent="truncateTable(table.name)">清空</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
52
web/views/@default/db/cleanPopup.js
Normal file
52
web/views/@default/db/cleanPopup.js
Normal file
@@ -0,0 +1,52 @@
|
||||
Tea.context(function () {
|
||||
this.tables = []
|
||||
this.isLoading = true
|
||||
|
||||
this.$delay(function () {
|
||||
this.reload()
|
||||
})
|
||||
|
||||
this.reload = function () {
|
||||
this.isLoading = true
|
||||
this.$post("$")
|
||||
.params({ nodeId: this.nodeId })
|
||||
.success(function (resp) {
|
||||
this.tables = resp.data.tables;
|
||||
})
|
||||
.done(function () {
|
||||
this.isLoading = false
|
||||
})
|
||||
}
|
||||
|
||||
this.deleteTable = function (tableName) {
|
||||
let that = this
|
||||
teaweb.confirm("html:确定要删除此数据表吗?<br/>删除后数据不能恢复!", function () {
|
||||
that.$post(".deleteTable")
|
||||
.params({
|
||||
nodeId: that.nodeId,
|
||||
table: tableName
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.success("操作成功", function () {
|
||||
that.reload()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.truncateTable = function (tableName) {
|
||||
let that = this
|
||||
teaweb.confirm("html:确定要清空此数据表吗?<br/>清空后数据不能恢复!", function () {
|
||||
that.$post(".truncateTable")
|
||||
.params({
|
||||
nodeId: that.nodeId,
|
||||
table: tableName
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.success("操作成功", function () {
|
||||
that.reload()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -12,16 +12,30 @@
|
||||
<th>节点名称</th>
|
||||
<th>连接地址</th>
|
||||
<th>数据库名</th>
|
||||
<th>用量</th>
|
||||
<th class="center width10">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
<th class="three op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="node in nodes">
|
||||
<td>{{node.name}}</td>
|
||||
<td>{{node.host}}:{{node.port}}</td>
|
||||
<td>{{node.database}}</td>
|
||||
<td class="center"><label-on :v-is-on="node.isOn"></label-on></td>
|
||||
<td>
|
||||
<span v-if="node.status.isOk">{{node.status.size}}</span>
|
||||
<span v-else class="disabled">-</span>
|
||||
</td>
|
||||
<td class="center">
|
||||
<div v-if="node.isOn">
|
||||
<span v-if="node.status.isOk" class="green">连接正常</span>
|
||||
<a href="" title="点击查看具体错误" v-else @click.prevent="showError(node.status.error)"><span class="red" style="border-bottom: 1px #db2828 dashed">连接错误</span></a>
|
||||
</div>
|
||||
<span v-else>
|
||||
<label-on :v-is-on="node.isOn"></label-on>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="" @click.prevent="cleanNode(node.id)" v-if="node.isOn && node.status.isOk">清理</a><span v-else class="disabled">清理 </span>
|
||||
<a href="" @click.prevent="updateNode(node.id)">修改</a>
|
||||
<a href="" @click.prevent="deleteNode(node.id)">删除</a>
|
||||
</td>
|
||||
|
||||
@@ -34,4 +34,14 @@ Tea.context(function () {
|
||||
.refresh()
|
||||
})
|
||||
}
|
||||
|
||||
// 清理节点
|
||||
this.cleanNode = function (nodeId) {
|
||||
teaweb.popup("/db/cleanPopup?nodeId=" + nodeId)
|
||||
}
|
||||
|
||||
// 显示错误信息
|
||||
this.showError = function (err) {
|
||||
teaweb.popupTip("<span style=\"color:#db2828\">错误信息:" + err + "</span>")
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user