Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
//go:build plus
|
||||
|
||||
package domain
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/domains/domainutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
DomainId int64
|
||||
}) {
|
||||
err := domainutils.InitDomain(this.Parent(), params.DomainId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var countRecords = this.Data.GetMap("domain").GetInt64("countRecords")
|
||||
var countKeys = this.Data.GetMap("domain").GetInt64("countKeys")
|
||||
|
||||
// 域名信息
|
||||
domainResp, err := this.RPC().NSDomainRPC().FindNSDomain(this.AdminContext(), &pb.FindNSDomainRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var domain = domainResp.NsDomain
|
||||
if domain == nil {
|
||||
this.NotFound("nsDomain", params.DomainId)
|
||||
return
|
||||
}
|
||||
|
||||
var clusterMap maps.Map
|
||||
if domain.NsCluster != nil {
|
||||
clusterMap = maps.Map{
|
||||
"id": domain.NsCluster.Id,
|
||||
"name": domain.NsCluster.Name,
|
||||
}
|
||||
}
|
||||
|
||||
// 用户信息
|
||||
var userMap maps.Map
|
||||
if domain.User != nil {
|
||||
userMap = maps.Map{
|
||||
"id": domain.User.Id,
|
||||
"username": domain.User.Username,
|
||||
"fullname": domain.User.Fullname,
|
||||
}
|
||||
}
|
||||
|
||||
// 分组信息
|
||||
var groupMaps = []maps.Map{}
|
||||
for _, group := range domain.NsDomainGroups {
|
||||
groupMaps = append(groupMaps, maps.Map{
|
||||
"id": group.Id,
|
||||
"name": group.Name,
|
||||
"userId": group.UserId,
|
||||
})
|
||||
}
|
||||
|
||||
// 健康检查
|
||||
var healthCheckConfig = dnsconfigs.NewNSRecordsHealthCheckConfig()
|
||||
if len(domain.RecordsHealthCheckJSON) > 0 {
|
||||
err = json.Unmarshal(domain.RecordsHealthCheckJSON, healthCheckConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["domain"] = maps.Map{
|
||||
"id": domain.Id,
|
||||
"name": domain.Name,
|
||||
"isOn": domain.IsOn,
|
||||
"status": domain.Status,
|
||||
"statusName": dnsconfigs.NSDomainStatusName(domain.Status),
|
||||
"cluster": clusterMap,
|
||||
"user": userMap,
|
||||
"groups": groupMaps,
|
||||
"countRecords": countRecords,
|
||||
"countKeys": countKeys,
|
||||
"enableHealthCheck": healthCheckConfig.IsOn,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build plus
|
||||
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdateStatusPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateStatusPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdateStatusPopupAction) RunGet(params struct {
|
||||
DomainId int64
|
||||
}) {
|
||||
domainResp, err := this.RPC().NSDomainRPC().FindNSDomain(this.AdminContext(), &pb.FindNSDomainRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var domain = domainResp.NsDomain
|
||||
if domain == nil {
|
||||
this.NotFound("NSDomain", params.DomainId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["domain"] = maps.Map{
|
||||
"id": domain.Id,
|
||||
"name": domain.Name,
|
||||
"status": domain.Status,
|
||||
}
|
||||
|
||||
this.Data["statusList"] = dnsconfigs.FindAllNSDomainStatusList()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdateStatusPopupAction) RunPost(params struct {
|
||||
DomainId int64
|
||||
Status string
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.NSDomain_LogUpdateNSDomainStatus, params.DomainId, params.Status)
|
||||
|
||||
_, err := this.RPC().NSDomainRPC().UpdateNSDomainStatus(this.AdminContext(), &pb.UpdateNSDomainStatusRequest{
|
||||
NsDomainId: params.DomainId,
|
||||
Status: params.Status,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user