mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-01-04 18:16:36 +08:00
实现基本的域名、记录管理
This commit is contained in:
7
web/views/@default/ns/domains/@domain_menu.html
Normal file
7
web/views/@default/ns/domains/@domain_menu.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<first-menu>
|
||||
<menu-item href="/ns">所有域名</menu-item>
|
||||
<span class="item disabled">|</span>
|
||||
<menu-item :href="'/ns/domains/domain?domainId=' + domain.id" code="index">详情<span class="grey small">({{domain.name}})</span></menu-item>
|
||||
<menu-item :href="'/ns/domains/records?domainId=' + domain.id" code="record">记录</menu-item>
|
||||
<menu-item :href="'/ns/domains/update?domainId=' + domain.id" code="update">修改</menu-item>
|
||||
</first-menu>
|
||||
27
web/views/@default/ns/domains/create.html
Normal file
27
web/views/@default/ns/domains/create.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{$layout}
|
||||
{$template "../menu"}
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td>域名 *</td>
|
||||
<td>
|
||||
<input type="text" name="name" maxlength="255" ref="focus"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">所属集群 *</td>
|
||||
<td>
|
||||
<ns-cluster-selector></ns-cluster-selector>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属用户</td>
|
||||
<td>
|
||||
<ns-user-selector></ns-user-selector>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
3
web/views/@default/ns/domains/create.js
Normal file
3
web/views/@default/ns/domains/create.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifySuccess("保存成功", "/ns")
|
||||
})
|
||||
30
web/views/@default/ns/domains/domain.html
Normal file
30
web/views/@default/ns/domains/domain.html
Normal file
@@ -0,0 +1,30 @@
|
||||
{$layout}
|
||||
{$template "domain_menu"}
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">域名</td>
|
||||
<td>{{domain.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>状态</td>
|
||||
<td>
|
||||
<label-on :v-is-on="domain.isOn"></label-on>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属集群</td>
|
||||
<td>
|
||||
{{domain.cluster.name}}<link-icon :href="'/ns/clusters/cluster?clusterId=' + domain.cluster.id"></link-icon>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属用户</td>
|
||||
<td>
|
||||
<span v-if="domain.user != null">
|
||||
{{domain.user.fullname}} ({{domain.user.username}})
|
||||
</span>
|
||||
<span v-else class="disabled">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
48
web/views/@default/ns/domains/records/createPopup.html
Normal file
48
web/views/@default/ns/domains/records/createPopup.html
Normal file
@@ -0,0 +1,48 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>创建记录</h3>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<input type="hidden" name="domainId" :value="domain.id"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">记录名</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="name" ref="focus"/>
|
||||
<span class="ui label">.{{domain.name}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>记录类型</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="type" v-model="type" @change="changeType">
|
||||
<option v-for="t in types" :value="t.type">{{t.type}}</option>
|
||||
</select>
|
||||
<p class="comment">{{typeDescription}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>记录值</td>
|
||||
<td>
|
||||
<input type="text" name="value" maxlength="1024"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TTL</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="ttl">
|
||||
<option v-for="v in ttlValues" :value="v.value">{{v.name}}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>备注</td>
|
||||
<td>
|
||||
<textarea rows="2" name="description"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
15
web/views/@default/ns/domains/records/createPopup.js
Normal file
15
web/views/@default/ns/domains/records/createPopup.js
Normal file
@@ -0,0 +1,15 @@
|
||||
Tea.context(function () {
|
||||
this.type = "A"
|
||||
this.typeDescription = ""
|
||||
|
||||
this.changeType = function () {
|
||||
let that = this
|
||||
this.types.forEach(function (v) {
|
||||
if (v.type == that.type) {
|
||||
that.typeDescription = v.description
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.changeType()
|
||||
})
|
||||
37
web/views/@default/ns/domains/records/index.html
Normal file
37
web/views/@default/ns/domains/records/index.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{$layout}
|
||||
{$template "../domain_menu"}
|
||||
|
||||
<second-menu>
|
||||
<menu-item @click.prevent="createRecord">[创建记录]</menu-item>
|
||||
</second-menu>
|
||||
|
||||
<p class="comment" v-if="records.length == 0">暂时还没有记录。</p>
|
||||
<table class="ui table selectable celled" v-if="records.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>记录名</th>
|
||||
<th>记录类型</th>
|
||||
<th>记录值</th>
|
||||
<th>TTL</th>
|
||||
<th>线路</th>
|
||||
<th>备注</th>
|
||||
<th class="two op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="record in records">
|
||||
<td>{{record.name}}</td>
|
||||
<td>{{record.type}}</td>
|
||||
<td>{{record.value}}</td>
|
||||
<td>{{formatTTL(record.ttl)}}</td>
|
||||
<td>
|
||||
<span class="ui label basic text tiny" v-for="route in record.routes">{{route.name}}</span>
|
||||
</td>
|
||||
<td>{{record.description}}</td>
|
||||
<td>
|
||||
<a href="" @click.prevent="updateRecord(record.id)">修改</a>
|
||||
<a href="" @click.prevent="deleteRecord(record.id)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="page" v-html="page"></div>
|
||||
50
web/views/@default/ns/domains/records/index.js
Normal file
50
web/views/@default/ns/domains/records/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
Tea.context(function () {
|
||||
this.createRecord = function () {
|
||||
teaweb.popup("/ns/domains/records/createPopup?domainId=" + this.domain.id, {
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.updateRecord = function (recordId) {
|
||||
teaweb.popup("/ns/domains/records/updatePopup?recordId=" + recordId, {
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.deleteRecord = function (recordId) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除此记录吗?", function () {
|
||||
that.$post(".delete")
|
||||
.params({
|
||||
recordId: recordId
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.formatTTL = function (ttl) {
|
||||
if (ttl % 86400 == 0) {
|
||||
let days = ttl / 86400
|
||||
return days + "天"
|
||||
}
|
||||
if (ttl % 3600 == 0) {
|
||||
let hours = ttl / 3600
|
||||
return hours + "小时"
|
||||
}
|
||||
if (ttl % 60 == 0) {
|
||||
let minutes = ttl / 60
|
||||
return minutes + "分钟"
|
||||
}
|
||||
return ttl + "秒"
|
||||
}
|
||||
})
|
||||
48
web/views/@default/ns/domains/records/updatePopup.html
Normal file
48
web/views/@default/ns/domains/records/updatePopup.html
Normal file
@@ -0,0 +1,48 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>创建记录</h3>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<input type="hidden" name="recordId" :value="record.id"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">记录名</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="name" ref="focus" v-model="record.name"/>
|
||||
<span class="ui label">.{{domain.name}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>记录类型</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="type" v-model="type" @change="changeType">
|
||||
<option v-for="t in types" :value="t.type">{{t.type}}</option>
|
||||
</select>
|
||||
<p class="comment">{{typeDescription}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>记录值</td>
|
||||
<td>
|
||||
<input type="text" name="value" maxlength="1024" v-model="record.value"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TTL</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="ttl" v-model="record.ttl">
|
||||
<option v-for="v in ttlValues" :value="v.value">{{v.name}}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>备注</td>
|
||||
<td>
|
||||
<textarea rows="2" name="description" v-model="record.description"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
15
web/views/@default/ns/domains/records/updatePopup.js
Normal file
15
web/views/@default/ns/domains/records/updatePopup.js
Normal file
@@ -0,0 +1,15 @@
|
||||
Tea.context(function () {
|
||||
this.type = this.record.type
|
||||
this.typeDescription = ""
|
||||
|
||||
this.changeType = function () {
|
||||
let that = this
|
||||
this.types.forEach(function (v) {
|
||||
if (v.type == that.type) {
|
||||
that.typeDescription = v.description
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.changeType()
|
||||
})
|
||||
39
web/views/@default/ns/domains/update.html
Normal file
39
web/views/@default/ns/domains/update.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{$layout}
|
||||
{$template "domain_menu"}
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<input type="hidden" name="domainId" :value="domain.id"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td>域名 *</td>
|
||||
<td>
|
||||
<input type="text" name="name" maxlength="255" ref="focus" v-model="domain.name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">所属集群 *</td>
|
||||
<td>
|
||||
<ns-cluster-selector :v-cluster-id="domain.clusterId"></ns-cluster-selector>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属用户</td>
|
||||
<td>
|
||||
<ns-user-selector :v-user-id="domain.userId"></ns-user-selector>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
<tbody v-show="moreOptionsVisible">
|
||||
<tr>
|
||||
<td>是否启用</td>
|
||||
<td>
|
||||
<checkbox name="isOn" value="1" v-model="domain.isOn"></checkbox>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
3
web/views/@default/ns/domains/update.js
Normal file
3
web/views/@default/ns/domains/update.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifySuccess("保存成功", "/ns/domains/domain?domainId=" + this.domain.id)
|
||||
})
|
||||
Reference in New Issue
Block a user