mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-08 06:00:24 +08:00
域名服务集群创建时可以选择开启访问日志
This commit is contained in:
@@ -3,7 +3,9 @@
|
|||||||
package clusters
|
package clusters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
)
|
)
|
||||||
@@ -17,24 +19,44 @@ func (this *CreateAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreateAction) RunGet(params struct{}) {
|
func (this *CreateAction) RunGet(params struct{}) {
|
||||||
|
// 默认的访问日志设置
|
||||||
|
this.Data["accessLogRef"] = &dnsconfigs.AccessLogRef{
|
||||||
|
IsOn: true,
|
||||||
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreateAction) RunPost(params struct {
|
func (this *CreateAction) RunPost(params struct {
|
||||||
Name string
|
Name string
|
||||||
|
AccessLogJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
}) {
|
}) {
|
||||||
var clusterId int64
|
var clusterId int64
|
||||||
defer this.CreateLogInfo("创建域名服务集群 %d", clusterId)
|
defer func() {
|
||||||
|
this.CreateLogInfo("创建域名服务集群 %d", clusterId)
|
||||||
|
}()
|
||||||
|
|
||||||
params.Must.
|
params.Must.
|
||||||
Field("name", params.Name).
|
Field("name", params.Name).
|
||||||
Require("请输入集群名称")
|
Require("请输入集群名称")
|
||||||
|
|
||||||
|
// 校验访问日志设置
|
||||||
|
ref := &dnsconfigs.AccessLogRef{}
|
||||||
|
err := json.Unmarshal(params.AccessLogJSON, ref)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("数据格式错误:" + err.Error())
|
||||||
|
}
|
||||||
|
err = ref.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("数据格式错误:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := this.RPC().NSClusterRPC().CreateNSCluster(this.AdminContext(), &pb.CreateNSClusterRequest{
|
resp, err := this.RPC().NSClusterRPC().CreateNSCluster(this.AdminContext(), &pb.CreateNSClusterRequest{
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
|
AccessLogJSON: params.AccessLogJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ func (this *CreateAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreateAction) RunGet(params struct{}) {
|
func (this *CreateAction) RunGet(params struct{}) {
|
||||||
|
// 集群数量
|
||||||
|
countClustersResp, err := this.RPC().NSClusterRPC().CountAllEnabledNSClusters(this.AdminContext(), &pb.CountAllEnabledNSClustersRequest{})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.Data["countClusters"] = countClustersResp.Count
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,9 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<h3>访问日志设置</h3>
|
||||||
|
<ns-access-log-ref-box :v-access-log-ref="accessLogRef"></ns-access-log-ref-box>
|
||||||
|
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
@@ -1,29 +1,38 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "../menu"}
|
{$template "../menu"}
|
||||||
|
|
||||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
|
||||||
<csrf-token></csrf-token>
|
<div v-if="countClusters == 0">
|
||||||
<table class="ui table definition selectable">
|
<not-found-box>
|
||||||
<tr>
|
暂时还没有集群,请先 <a href="/ns/clusters/create">创建集群</a>。
|
||||||
<td>域名 *</td>
|
</not-found-box>
|
||||||
<td>
|
</div>
|
||||||
<input type="text" name="name" maxlength="255" ref="focus"/>
|
|
||||||
</td>
|
<div v-show="countClusters > 0">
|
||||||
</tr>
|
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
<tr>
|
<csrf-token></csrf-token>
|
||||||
<td class="title">所属集群 *</td>
|
<table class="ui table definition selectable">
|
||||||
<td>
|
<tr>
|
||||||
<ns-cluster-selector></ns-cluster-selector>
|
<td>域名 *</td>
|
||||||
<p class="comment">需要部署域名服务的集群。</p>
|
<td>
|
||||||
</td>
|
<input type="text" name="name" maxlength="255" ref="focus"/>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>所属用户</td>
|
<tr>
|
||||||
<td>
|
<td class="title">所属集群 *</td>
|
||||||
<ns-user-selector></ns-user-selector>
|
<td>
|
||||||
<p class="comment">当前域名所属的平台用户。</p>
|
<ns-cluster-selector></ns-cluster-selector>
|
||||||
</td>
|
<p class="comment">需要部署域名服务的集群。</p>
|
||||||
</tr>
|
</td>
|
||||||
</table>
|
</tr>
|
||||||
<submit-btn></submit-btn>
|
<tr>
|
||||||
</form>
|
<td>所属用户</td>
|
||||||
|
<td>
|
||||||
|
<ns-user-selector></ns-user-selector>
|
||||||
|
<p class="comment">当前域名所属的平台用户。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<submit-btn></submit-btn>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<div v-if="countClusters == 0">
|
<div v-if="countClusters == 0">
|
||||||
<not-found-box>
|
<not-found-box>
|
||||||
暂时还没有集群,请先 <a href="/ns/clusters">创建集群</a>。
|
暂时还没有集群,请先 <a href="/ns/clusters/create">创建集群</a>。
|
||||||
</not-found-box>
|
</not-found-box>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user