[网站服务]可以审核域名、查看审核结果

This commit is contained in:
刘祥超
2020-12-19 19:08:39 +08:00
parent dafdff9d9a
commit eced5f9417
8 changed files with 145 additions and 23 deletions

View File

@@ -143,9 +143,13 @@ func (this *IndexAction) RunGet(params struct {
// 域名列表
serverNames := []*serverconfigs.ServerNameConfig{}
if server.IsAuditing {
if server.IsAuditing || (server.AuditingResult != nil && !server.AuditingResult.IsOk) {
server.ServerNamesJSON = server.AuditingServerNamesJSON
}
auditingIsOk := true
if !server.IsAuditing && server.AuditingResult != nil && !server.AuditingResult.IsOk {
auditingIsOk = false
}
if len(server.ServerNamesJSON) > 0 {
err = json.Unmarshal(server.ServerNamesJSON, &serverNames)
if err != nil {
@@ -185,6 +189,7 @@ func (this *IndexAction) RunGet(params struct {
"serverNames": serverNames,
"countServerNames": countServerNames,
"isAuditing": server.IsAuditing,
"auditingIsOk": auditingIsOk,
"user": userMap,
})
}

View File

@@ -28,7 +28,7 @@ func (this *IndexAction) RunPost(params struct {
defer this.CreateLog(oplogs.LevelInfo, "删除代理服务 %d", params.ServerId)
// 执行删除
_, err := this.RPC().ServerRPC().DisableServer(this.AdminContext(), &pb.DisableServerRequest{ServerId: params.ServerId})
_, err := this.RPC().ServerRPC().DeleteServer(this.AdminContext(), &pb.DeleteServerRequest{ServerId: params.ServerId})
if err != nil {
this.ErrorPage(err)
return

View File

@@ -0,0 +1,39 @@
package serverNames
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
// 审核域名
type AuditAction struct {
actionutils.ParentAction
}
func (this *AuditAction) RunPost(params struct {
ServerId int64
AuditingOK bool
AuditingReason string
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo("提交服务 %d 域名审核", params.ServerId)
if !params.AuditingOK && len(params.AuditingReason) == 0 {
this.FailField("auditingReason", "请输入审核不通过原因")
}
_, err := this.RPC().ServerRPC().UpdateServerNamesAuditing(this.AdminContext(), &pb.UpdateServerNamesAuditingRequest{
ServerId: params.ServerId,
AuditingResult: &pb.ServerNameAuditingResult{
IsOk: params.AuditingOK,
Reason: params.AuditingReason,
},
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -4,10 +4,11 @@ import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
timeutil "github.com/iwind/TeaGo/utils/time"
)
// 域名管理
@@ -22,14 +23,32 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
if !isOk {
serverNamesResp, err := this.RPC().ServerRPC().FindServerNames(this.AdminContext(), &pb.FindServerNamesRequest{ServerId: params.ServerId})
if err != nil {
this.ErrorPage(err)
return
}
serverNamesConfig := []*serverconfigs.ServerNameConfig{}
if len(server.ServerNamesJSON) > 0 {
err := json.Unmarshal(server.ServerNamesJSON, &serverNamesConfig)
this.Data["isAuditing"] = serverNamesResp.IsAuditing
this.Data["auditingResult"] = maps.Map{
"isOk": true,
}
if serverNamesResp.IsAuditing {
serverNamesResp.ServerNamesJSON = serverNamesResp.AuditingServerNamesJSON
} else if serverNamesResp.AuditingResult != nil {
if !serverNamesResp.AuditingResult.IsOk {
serverNamesResp.ServerNamesJSON = serverNamesResp.AuditingServerNamesJSON
}
this.Data["auditingResult"] = maps.Map{
"isOk": serverNamesResp.AuditingResult.IsOk,
"reason": serverNamesResp.AuditingResult.Reason,
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", serverNamesResp.AuditingResult.CreatedAt),
}
}
if len(serverNamesResp.ServerNamesJSON) > 0 {
err := json.Unmarshal(serverNamesResp.ServerNamesJSON, &serverNamesConfig)
if err != nil {
this.ErrorPage(err)
return
@@ -37,9 +56,6 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["serverNames"] = serverNamesConfig
// DNS
this.Data["dnsName"] = server.DnsName
this.Show()
}
@@ -47,6 +63,7 @@ func (this *IndexAction) RunPost(params struct {
ServerId int64
ServerNames string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
// 记录日志
defer this.CreateLog(oplogs.LevelInfo, "修改代理服务 %d 域名", params.ServerId)

View File

@@ -16,6 +16,7 @@ func init() {
Data("secondMenuItem", "serverName").
Prefix("/servers/server/settings/serverNames").
GetPost("", new(IndexAction)).
Post("/audit", new(AuditAction)).
EndAll()
})
}

View File

@@ -59,8 +59,14 @@
</span>
<span v-else class="disabled">-</span>
<!-- 审核中 -->
<div v-if="server.isAuditing" style="margin-top: 0.5em">
<span class="ui label basic tiny red">审核中</span>
<a class="ui label basic tiny red" title="点击跳到审核页面" :href="'/servers/server/settings/serverNames?serverId=' + server.id">审核中 &nbsp;<i class="icon long arrow right alternate"></i></a>
</div>
<!-- 审核失败 -->
<div v-if="!server.auditingIsOk" style="margin-top: 0.5em">
<a class="ui label basic tiny red" title="点击跳到审核页面" :href="'/servers/server/settings/serverNames?serverId=' + server.id">审核不通过 &nbsp;<i class="icon long arrow right alternate"></i></a>
</div>
</td>
<td>

View File

@@ -2,16 +2,58 @@
{$template "/left_menu"}
<div class="right-box">
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="serverId" :value="serverId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">已绑定的域名</td>
<td>
<server-name-box :v-server-names="serverNames"></server-name-box>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>
<!-- 审核中 -->
<div v-show="isAuditing">
<p class="ui message warning">当前域名正在审核中,请审核域名的所有人、备案情况等。</p>
<form method="post" class="ui form" data-tea-action=".audit" data-tea-success="auditSuccess">
<csrf-token></csrf-token>
<input type="hidden" name="serverId" :value="serverId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">审核中域名</td>
<td>
<span v-for="serverName in allServerNames" class="ui label basic">
{{serverName}}
</span>
</td>
</tr>
<tr>
<td>审核结果</td>
<td>
<radio name="auditingOK" :v-value="1" v-model="auditing">审核通过</radio> &nbsp;
<radio name="auditingOK" :v-value="0" v-model="auditing">审核不通过</radio>
</td>
</tr>
<tr v-show="auditing == 0">
<td>审核不通过原因 *</td>
<td>
<input type="text" name="auditingReason" maxlength="100" placeholder="包含审核不通过的域名等"/>
</td>
</tr>
</table>
<submit-btn>提交审核结果</submit-btn>
</form>
</div>
<!-- 审核不通过 -->
<div class="ui message error" v-if="!isAuditing && !auditingResult.isOk">
审核不通过,原因:{{auditingResult.reason}} {{auditingResult.createdTime}})。等待用户重新提交。
</div>
<!-- 不在审核中 -->
<div v-show="!isAuditing && auditingResult.isOk">
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="serverId" :value="serverId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">已绑定的域名</td>
<td>
<server-name-box :v-server-names="serverNames"></server-name-box>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>
</div>
</div>

View File

@@ -1,3 +1,15 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
this.auditSuccess = NotifyReloadSuccess("保存成功")
this.allServerNames = []
let that = this
this.serverNames.forEach(function (v) {
if (v.subNames == null || v.subNames.length == 0) {
that.allServerNames.push(v.name)
} else {
that.allServerNames.$pushAll(v.subNames)
}
})
this.auditing = 1
})