mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-30 11:35:21 +08:00
增加DNS域名管理
This commit is contained in:
@@ -71,7 +71,6 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Name: params.Name,
|
||||
Type: params.Type,
|
||||
ApiParamsJSON: apiParams.AsJSON(),
|
||||
RoutesJSON: nil,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -40,12 +40,21 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
dataUpdatedTime = timeutil.FormatTime("Y-m-d H:i:s", provider.DataUpdatedAt)
|
||||
}
|
||||
|
||||
// 域名
|
||||
countDomainsResp, err := this.RPC().DNSDomainRPC().CountAllEnabledDNSDomainsWithDNSProviderId(this.AdminContext(), &pb.CountAllEnabledDNSDomainsWithDNSProviderIdRequest{DnsProviderId: provider.Id})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
countDomains := countDomainsResp.Count
|
||||
|
||||
providerMaps = append(providerMaps, maps.Map{
|
||||
"id": provider.Id,
|
||||
"name": provider.Name,
|
||||
"type": provider.Type,
|
||||
"typeName": provider.TypeName,
|
||||
"dataUpdatedTime": dataUpdatedTime,
|
||||
"countDomains": countDomains,
|
||||
})
|
||||
}
|
||||
this.Data["providers"] = providerMaps
|
||||
|
||||
72
internal/web/actions/default/dns/providers/provider.go
Normal file
72
internal/web/actions/default/dns/providers/provider.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type ProviderAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *ProviderAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *ProviderAction) RunGet(params struct {
|
||||
ProviderId int64
|
||||
}) {
|
||||
providerResp, err := this.RPC().DNSProviderRPC().FindEnabledDNSProvider(this.AdminContext(), &pb.FindEnabledDNSProviderRequest{DnsProviderId: params.ProviderId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
provider := providerResp.DnsProvider
|
||||
if provider == nil {
|
||||
this.NotFound("dnsProvider", params.ProviderId)
|
||||
return
|
||||
}
|
||||
|
||||
apiParams := maps.Map{}
|
||||
if len(provider.ApiParamsJSON) > 0 {
|
||||
err = json.Unmarshal(provider.ApiParamsJSON, &apiParams)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["provider"] = maps.Map{
|
||||
"id": provider.Id,
|
||||
"name": provider.Name,
|
||||
"type": provider.Type,
|
||||
"typeName": provider.TypeName,
|
||||
"apiParams": apiParams,
|
||||
}
|
||||
|
||||
// 域名
|
||||
domainsResp, err := this.RPC().DNSDomainRPC().FindAllEnabledDNSDomainsWithDNSProviderId(this.AdminContext(), &pb.FindAllEnabledDNSDomainsWithDNSProviderIdRequest{DnsProviderId: provider.Id})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
domainMaps := []maps.Map{}
|
||||
for _, domain := range domainsResp.DnsDomains {
|
||||
dataUpdatedTime := ""
|
||||
if domain.DataUpdatedAt > 0 {
|
||||
dataUpdatedTime = timeutil.FormatTime("Y-m-d H:i:s", domain.DataUpdatedAt)
|
||||
}
|
||||
domainMaps = append(domainMaps, maps.Map{
|
||||
"id": domain.Id,
|
||||
"name": domain.Name,
|
||||
"isOn": domain.IsOn,
|
||||
"dataUpdatedTime": dataUpdatedTime,
|
||||
})
|
||||
}
|
||||
this.Data["domains"] = domainMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -38,7 +38,6 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.Data["provider"] = maps.Map{
|
||||
@@ -107,7 +106,6 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
DnsProviderId: params.ProviderId,
|
||||
Name: params.Name,
|
||||
ApiParamsJSON: apiParams.AsJSON(),
|
||||
RoutesJSON: nil,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
Reference in New Issue
Block a user