mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-07 21:50:25 +08:00
域名服务集群创建时可以选择开启访问日志
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
package clusters
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
@@ -17,24 +19,44 @@ func (this *CreateAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunGet(params struct{}) {
|
||||
// 默认的访问日志设置
|
||||
this.Data["accessLogRef"] = &dnsconfigs.AccessLogRef{
|
||||
IsOn: true,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunPost(params struct {
|
||||
Name string
|
||||
AccessLogJSON []byte
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
var clusterId int64
|
||||
defer this.CreateLogInfo("创建域名服务集群 %d", clusterId)
|
||||
defer func() {
|
||||
this.CreateLogInfo("创建域名服务集群 %d", clusterId)
|
||||
}()
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
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{
|
||||
Name: params.Name,
|
||||
AccessLogJSON: params.AccessLogJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -19,6 +19,14 @@ func (this *CreateAction) Init() {
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
@@ -12,5 +12,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>访问日志设置</h3>
|
||||
<ns-access-log-ref-box :v-access-log-ref="accessLogRef"></ns-access-log-ref-box>
|
||||
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -1,7 +1,15 @@
|
||||
{$layout}
|
||||
{$template "../menu"}
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
|
||||
<div v-if="countClusters == 0">
|
||||
<not-found-box>
|
||||
暂时还没有集群,请先 <a href="/ns/clusters/create">创建集群</a>。
|
||||
</not-found-box>
|
||||
</div>
|
||||
|
||||
<div v-show="countClusters > 0">
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
@@ -26,4 +34,5 @@
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<div v-if="countClusters == 0">
|
||||
<not-found-box>
|
||||
暂时还没有集群,请先 <a href="/ns/clusters">创建集群</a>。
|
||||
暂时还没有集群,请先 <a href="/ns/clusters/create">创建集群</a>。
|
||||
</not-found-box>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user