This commit is contained in:
unknown
2026-02-04 20:27:13 +08:00
commit 3b042d1dad
9410 changed files with 1488147 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<first-menu>
<menu-item href="/db">所有节点</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/db/node?nodeId=' + node.id" code="node">"{{node.name}}"详情</menu-item>
<menu-item :href="'/db/clean?nodeId=' + node.id" code="clean">清理</menu-item>
<menu-item :href="'/db/logs?nodeId=' + node.id" code="log">运行日志</menu-item>
<menu-item :href="'/db/update?nodeId=' + node.id" code="update">修改</menu-item>
</first-menu>

View File

@@ -0,0 +1,26 @@
{$layout}
{$template "menu"}
<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}}
<span class="grey small" v-if="table.rows > 0">{{table.rows}}行)</span>
</td>
<td>{{table.comment}}</td>
<td>
<a href="" v-if="table.canDelete" @click.prevent="deleteTable(table.name)">删除</a><span v-if="table.canDelete"> &nbsp;</span>
<a href="" v-if="table.canClean" @click.prevent="truncateTable(table.name)">清空</a>
</td>
</tr>
</table>

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

View File

@@ -0,0 +1,71 @@
{$layout "layout_popup"}
<h3>添加节点</h3>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<table class="ui table definition selectable">
<tr>
<td class="title">节点名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus"/>
<p class="comment">给节点起一个容易识别的名称。</p>
</td>
</tr>
<tr>
<td>主机地址<em>Host</em> *</td>
<td>
<input type="text" name="host" placeholder="" maxlength="100"/>
<p class="comment">连接数据库的主机地址通常是域名或者IP出于性能考虑请使用局域网内的数据库。</p>
</td>
</tr>
<tr>
<td>数据库端口<em>Port</em> *</td>
<td>
<input type="text" name="port" value="3306" maxlength="5" style="width:6em"/>
<p class="comment">连接数据库的端口。</p>
</td>
</tr>
<tr>
<td>数据库名称<em>Database</em> *</td>
<td>
<input type="text" name="database" value="" maxlength="100" placeholder="比如 edge_logs"/>
<p class="comment">要写入日志的数据库名称需要事先创建好而且需要有创建新表和读写数据的权限。建议命名为edge_logs。</p>
</td>
</tr>
<tr>
<td>用户名<em>Username</em> *</td>
<td>
<input type="text" name="username" value=""/>
<p class="comment">连接数据库的用户名。</p>
</td>
</tr>
<tr>
<td>密码<em>Password</em></td>
<td>
<input type="password" name="password" value=""/>
<p class="comment">连接数据库的密码。</p>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>详细描述</td>
<td>
<textarea rows="3" name="description"></textarea>
</td>
</tr>
<tr>
<td>启用当前数据库</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" checked="checked"/>
<label></label>
</div>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,49 @@
{$layout}
<first-menu>
<a href="" class="item" @click.prevent="createNode()">[添加节点]</a>
</first-menu>
<p class="comment" v-if="nodes.length == 0">暂时还没有数据库节点。</p>
<table class="ui table selectable celled" v-if="nodes.length > 0">
<thead>
<tr>
<th>节点名称</th>
<th>连接地址</th>
<th>数据库名</th>
<th>数据库版本</th>
<th>用量</th>
<th class="center width10">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="node in nodes">
<td><a :href="'/db/node?nodeId=' + node.id">{{node.name}}</a></td>
<td>{{node.host}}:{{node.port}}</td>
<td>{{node.database}}</td>
<td>
<span v-if="node.status.version.length > 0">v{{node.status.version}}</span>
<span class="disabled" v-else>-</span>
</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="'/db/node?nodeId=' + node.id">详情</a>
<a href="" @click.prevent="deleteNode(node.id)">删除</a>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -0,0 +1,30 @@
Tea.context(function () {
// 添加节点
this.createNode = function () {
teaweb.popup("/db/createPopup", {
height: "30em",
callback: function () {
teaweb.success("保存成功", function () {
window.location.reload()
})
}
})
}
// 删除节点
this.deleteNode = function (nodeId) {
let that = this
teaweb.confirm("确定要删除此数据库节点吗?", function () {
that.$post(".delete")
.params({
nodeId: nodeId
})
.refresh()
})
}
// 显示错误信息
this.showError = function (err) {
teaweb.popupTip("<span style=\"color:#db2828\">错误信息:" + err + "</span>")
}
})

View File

@@ -0,0 +1,5 @@
pre.log-box {
margin: 0;
padding: 0;
}
/*# sourceMappingURL=logs.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["logs.less"],"names":[],"mappings":"AAAA,GAAG;EACF,SAAA;EACA,UAAA","file":"logs.css"}

View File

@@ -0,0 +1,51 @@
{$layout}
{$template "menu"}
{$template "/datepicker"}
<div class="margin"></div>
<form method="get" action="/db/logs" class="ui form" autocomplete="off">
<input type="hidden" name="nodeId" :value="nodeId"/>
<div class="ui fields inline">
<div class="ui field">
<input type="text" name="dayFrom" placeholder="开始日期" v-model="dayFrom" value="" style="width:8em" id="day-from-picker"/>
</div>
<div class="ui field">
<input type="text" name="dayTo" placeholder="结束日期" v-model="dayTo" value="" style="width:8em" id="day-to-picker"/>
</div>
<div class="ui field">
<select class="ui dropdown" name="level" v-model="level">
<option value="">[级别]</option>
<option value="error">错误</option>
<option value="warning">警告</option>
<option value="info">信息</option>
<option value="success">成功</option>
</select>
</div>
<div class="ui field">
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
</div>
<div class="ui field">
<button type="submit" class="ui button">查询</button>
</div>
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0">
<a :href="'/db/logs?nodeId=' + nodeId">[清除条件]</a>
</div>
</div>
</form>
<p class="comment" v-if="logs.length == 0">暂时还没有日志。</p>
<table class="ui table selectable" v-if="logs.length > 0">
<thead>
<tr>
</tr>
</thead>
<tr v-for="log in logs">
<td>
<node-log-row :v-log="log" :v-keyword="keyword"></node-log-row>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -0,0 +1,6 @@
Tea.context(function () {
this.$delay(function () {
teaweb.datepicker("day-from-picker")
teaweb.datepicker("day-to-picker")
})
})

View File

@@ -0,0 +1,4 @@
pre.log-box {
margin: 0;
padding: 0;
}

View File

@@ -0,0 +1,68 @@
{$layout}
{$template "menu"}
<table class="ui table definition selectable">
<tr>
<td class="title">节点名称</td>
<td>
{{node.name}}
</td>
</tr>
<tr>
<td>状态</td>
<td>
<label-on :v-is-on="node.isOn"></label-on>
<div v-if="node.isOn && status != null" style="margin-top: 0.8em">
<div v-if="status.isOk">
<p class="comment">
<span v-if="status.version.length > 0">版本: v{{status.version}} /</span>
<span v-if="status.isOk">用量:{{status.size}}</span>
<span v-else class="disabled">-</span>
</p>
</div>
<div v-else>
<span class="red">连接错误:{{status.error}}</span>
</div>
</div>
</td>
</tr>
<tr>
<td>主机地址<em>Host</em></td>
<td>
{{node.host}}
</td>
</tr>
<tr>
<td>数据库端口<em>Port</em></td>
<td>
{{node.port}}
</td>
</tr>
<tr>
<td>数据库名称<em>Database</em></td>
<td>
{{node.database}}
</td>
</tr>
<tr>
<td>用户名<em>Username</em></td>
<td>
{{node.username}}
</td>
</tr>
<tr>
<td>密码<em>Password</em></td>
<td>
<span v-if="node.password.length > 0">{{node.password}}</span>
<span v-else class="disabled">-</span>
</td>
</tr>
<tr>
<td>详细描述</td>
<td>
<span v-if="node.description.length > 0">{{node.description}}</span>
<span v-else class="disabled">-</span>
</td>
</tr>
</table>

View File

@@ -0,0 +1,16 @@
Tea.context(function () {
this.$delay(function () {
this.loadStatus(this.node.id)
})
this.status = null
this.loadStatus = function (nodeId) {
this.$post(".status")
.params({
nodeId: nodeId
})
.success(function (resp) {
this.status = resp.data.status
})
}
})

View File

@@ -0,0 +1,71 @@
{$layout}
{$template "menu"}
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="nodeId" :value="node.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">节点名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus" v-model="node.name"/>
<p class="comment">给节点起一个容易识别的名称。</p>
</td>
</tr>
<tr>
<td>主机地址<em>Host</em> *</td>
<td>
<input type="text" name="host" placeholder="" maxlength="100" v-model="node.host"/>
<p class="comment">连接数据库的主机地址通常是域名或者IP出于性能考虑请使用局域网内的数据库。</p>
</td>
</tr>
<tr>
<td>数据库端口<em>Port</em> *</td>
<td>
<input type="text" name="port" value="" maxlength="5" style="width:6em" v-model="node.port"/>
<p class="comment">连接数据库的端口。</p>
</td>
</tr>
<tr>
<td>数据库名称<em>Database</em> *</td>
<td>
<input type="text" name="database" value="" maxlength="100" placeholder="比如 edge_logs" v-model="node.database"/>
<p class="comment">要写入日志的数据库名称需要事先创建好而且需要有创建新表和读写数据的权限。建议命名为edge_logs。</p>
</td>
</tr>
<tr>
<td>用户名<em>Username</em> *</td>
<td>
<input type="text" name="username" value="" v-model="node.username"/>
<p class="comment">连接数据库的用户名。</p>
</td>
</tr>
<tr>
<td>密码<em>Password</em></td>
<td>
<input type="password" name="password" value="" v-model="node.password"/>
<p class="comment">连接数据库的密码。</p>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>详细描述</td>
<td>
<textarea rows="3" name="description" v-model="node.description"></textarea>
</td>
</tr>
<tr>
<td>启用当前数据库</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="node.isOn"/>
<label></label>
</div>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,3 @@
Tea.context(function () {
this.success = NotifySuccess("保存成功", "/db/node?nodeId=" + this.node.id)
})