带阿里标识的版本
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package sandbox
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/default/httpdns/httpdnsutils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("httpdns", "sandbox", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
httpdnsutils.AddLeftMenu(this.Parent())
|
||||
|
||||
clusterResp, err := this.RPC().HTTPDNSClusterRPC().FindAllHTTPDNSClusters(this.UserContext(), &pb.FindAllHTTPDNSClustersRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
clusters := make([]maps.Map, 0, len(clusterResp.GetClusters()))
|
||||
for _, cluster := range clusterResp.GetClusters() {
|
||||
serviceDomain := strings.TrimSpace(cluster.GetServiceDomain())
|
||||
displayName := serviceDomain
|
||||
if len(displayName) == 0 {
|
||||
displayName = cluster.GetName()
|
||||
}
|
||||
clusters = append(clusters, maps.Map{
|
||||
"id": cluster.GetId(),
|
||||
"name": cluster.GetName(),
|
||||
"serviceDomain": serviceDomain,
|
||||
"displayName": displayName,
|
||||
})
|
||||
}
|
||||
this.Data["clusters"] = clusters
|
||||
|
||||
appResp, err := this.RPC().HTTPDNSAppRPC().FindAllHTTPDNSApps(this.UserContext(), &pb.FindAllHTTPDNSAppsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
apps := make([]maps.Map, 0, len(appResp.GetApps()))
|
||||
for _, app := range appResp.GetApps() {
|
||||
domainResp, err := this.RPC().HTTPDNSDomainRPC().ListHTTPDNSDomainsWithAppId(this.UserContext(), &pb.ListHTTPDNSDomainsWithAppIdRequest{
|
||||
AppDbId: app.GetId(),
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
domains := make([]string, 0, len(domainResp.GetDomains()))
|
||||
for _, domain := range domainResp.GetDomains() {
|
||||
domains = append(domains, domain.GetDomain())
|
||||
}
|
||||
apps = append(apps, maps.Map{
|
||||
"id": app.GetId(),
|
||||
"name": app.GetName(),
|
||||
"appId": app.GetAppId(),
|
||||
"clusterId": app.GetPrimaryClusterId(),
|
||||
"primaryClusterId": app.GetPrimaryClusterId(),
|
||||
"backupClusterId": app.GetBackupClusterId(),
|
||||
"domains": domains,
|
||||
})
|
||||
}
|
||||
this.Data["apps"] = apps
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user