66 lines
1.9 KiB
Go
66 lines
1.9 KiB
Go
package sandbox
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/httpdnsutils"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
"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.AdminContext(), &pb.FindAllHTTPDNSClustersRequest{})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
clusters := make([]maps.Map, 0, len(clusterResp.GetClusters()))
|
|
for _, cluster := range clusterResp.GetClusters() {
|
|
clusters = append(clusters, maps.Map{
|
|
"id": cluster.GetId(),
|
|
"name": cluster.GetName(),
|
|
})
|
|
}
|
|
this.Data["clusters"] = clusters
|
|
|
|
appResp, err := this.RPC().HTTPDNSAppRPC().FindAllHTTPDNSApps(this.AdminContext(), &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.AdminContext(), &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()
|
|
}
|