diff --git a/internal/rpc/context_interface.go b/internal/rpc/context_interface.go new file mode 100644 index 00000000..a311f1f5 --- /dev/null +++ b/internal/rpc/context_interface.go @@ -0,0 +1,7 @@ +package rpc + +import "context" + +type ContextInterface interface { + AdminContext() context.Context +} diff --git a/internal/tasks/task_sync_cluster.go b/internal/tasks/task_sync_cluster.go index 6ada44fb..6222d6a8 100644 --- a/internal/tasks/task_sync_cluster.go +++ b/internal/tasks/task_sync_cluster.go @@ -53,7 +53,7 @@ func (this *SyncClusterTask) loop() error { return err } - for _, cluster := range resp.Clusters { + for _, cluster := range resp.NodeClusters { _, err := rpcClient.NodeRPC().SyncNodesVersionWithCluster(ctx, &pb.SyncNodesVersionWithClusterRequest{ NodeClusterId: cluster.Id, }) diff --git a/internal/web/actions/default/clusters/checkChange.go b/internal/web/actions/default/clusters/checkChange.go index b8034b95..41823fc6 100644 --- a/internal/web/actions/default/clusters/checkChange.go +++ b/internal/web/actions/default/clusters/checkChange.go @@ -25,7 +25,7 @@ func (this *CheckChangeAction) RunPost(params struct { } result := []maps.Map{} - for _, cluster := range resp.Clusters { + for _, cluster := range resp.NodeClusters { result = append(result, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/clusters/cluster/index.go b/internal/web/actions/default/clusters/cluster/index.go index 5004d9b2..679812c8 100644 --- a/internal/web/actions/default/clusters/cluster/index.go +++ b/internal/web/actions/default/clusters/cluster/index.go @@ -139,8 +139,8 @@ func (this *IndexAction) RunGet(params struct { "memUsageText": fmt.Sprintf("%.2f%%", status.MemoryUsage*100), }, "cluster": maps.Map{ - "id": node.Cluster.Id, - "name": node.Cluster.Name, + "id": node.NodeCluster.Id, + "name": node.NodeCluster.Name, }, "isSynced": isSynced, "ipAddresses": ipAddresses, diff --git a/internal/web/actions/default/clusters/cluster/installNodes.go b/internal/web/actions/default/clusters/cluster/installNodes.go index 5e110819..4a4669f6 100644 --- a/internal/web/actions/default/clusters/cluster/installNodes.go +++ b/internal/web/actions/default/clusters/cluster/installNodes.go @@ -26,12 +26,12 @@ func (this *InstallNodesAction) RunGet(params struct { this.ErrorPage(err) return } - if clusterResp.Cluster == nil { + if clusterResp.NodeCluster == nil { this.NotFound("nodeCluster", params.ClusterId) return } - cluster := clusterResp.Cluster + cluster := clusterResp.NodeCluster clusterAPINodesResp, err := this.RPC().NodeClusterRPC().FindAPINodesWithNodeCluster(this.AdminContext(), &pb.FindAPINodesWithNodeClusterRequest{NodeClusterId: params.ClusterId}) if err != nil { diff --git a/internal/web/actions/default/clusters/cluster/node/install.go b/internal/web/actions/default/clusters/cluster/node/install.go index 45d80a7a..2d1b6920 100644 --- a/internal/web/actions/default/clusters/cluster/node/install.go +++ b/internal/web/actions/default/clusters/cluster/node/install.go @@ -51,14 +51,14 @@ func (this *InstallAction) RunGet(params struct { // 集群 var clusterMap maps.Map = nil - if node.Cluster != nil { - clusterId := node.Cluster.Id + if node.NodeCluster != nil { + clusterId := node.NodeCluster.Id clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId}) if err != nil { this.ErrorPage(err) return } - cluster := clusterResp.Cluster + cluster := clusterResp.NodeCluster if cluster != nil { clusterMap = maps.Map{ "id": cluster.Id, diff --git a/internal/web/actions/default/clusters/cluster/node/node.go b/internal/web/actions/default/clusters/cluster/node/node.go index a99ed1a7..f27ec2e2 100644 --- a/internal/web/actions/default/clusters/cluster/node/node.go +++ b/internal/web/actions/default/clusters/cluster/node/node.go @@ -37,14 +37,14 @@ func (this *NodeAction) RunGet(params struct { } var clusterMap maps.Map = nil - if node.Cluster != nil { - clusterId := node.Cluster.Id + if node.NodeCluster != nil { + clusterId := node.NodeCluster.Id clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId}) if err != nil { this.ErrorPage(err) return } - cluster := clusterResp.Cluster + cluster := clusterResp.NodeCluster if cluster != nil { clusterMap = maps.Map{ "id": cluster.Id, diff --git a/internal/web/actions/default/clusters/cluster/node/update.go b/internal/web/actions/default/clusters/cluster/node/update.go index a7d0bf9d..7dcc75a9 100644 --- a/internal/web/actions/default/clusters/cluster/node/update.go +++ b/internal/web/actions/default/clusters/cluster/node/update.go @@ -37,10 +37,10 @@ func (this *UpdateAction) RunGet(params struct { } var clusterMap maps.Map = nil - if node.Cluster != nil { + if node.NodeCluster != nil { clusterMap = maps.Map{ - "id": node.Cluster.Id, - "name": node.Cluster.Name, + "id": node.NodeCluster.Id, + "name": node.NodeCluster.Name, } } @@ -178,7 +178,7 @@ func (this *UpdateAction) RunGet(params struct { return } clusterMaps := []maps.Map{} - for _, cluster := range resp.Clusters { + for _, cluster := range resp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/clusters/cluster/settings/index.go b/internal/web/actions/default/clusters/cluster/settings/index.go index c940e187..965d6f35 100644 --- a/internal/web/actions/default/clusters/cluster/settings/index.go +++ b/internal/web/actions/default/clusters/cluster/settings/index.go @@ -26,7 +26,7 @@ func (this *IndexAction) RunGet(params struct { this.ErrorPage(err) return } - cluster := clusterResp.Cluster + cluster := clusterResp.NodeCluster if cluster == nil { this.WriteString("not found cluster") return diff --git a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go index c5016a6d..bc7c9d48 100644 --- a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go @@ -2,7 +2,9 @@ package clusterutils import ( "github.com/TeaOSLab/EdgeAdmin/internal/rpc" + "github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/logs" @@ -19,7 +21,8 @@ func NewClusterHelper() *ClusterHelper { return &ClusterHelper{} } -func (this *ClusterHelper) BeforeAction(action *actions.ActionObject) { +func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) { + action := actionPtr.Object() if action.Request.Method != http.MethodGet { return } @@ -31,19 +34,12 @@ func (this *ClusterHelper) BeforeAction(action *actions.ActionObject) { clusterIdString := strconv.FormatInt(clusterId, 10) action.Data["clusterId"] = clusterId - rpcClient, err := rpc.SharedRPC() - if err != nil { - logs.Error(err) - return - } - if clusterId > 0 { - clusterResp, err := rpcClient.NodeClusterRPC().FindEnabledNodeCluster(rpcClient.Context(action.Context.GetInt64("adminId")), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId}) + cluster, err := models.SharedNodeClusterDAO.FindEnabledNodeCluster(actionPtr.(rpc.ContextInterface).AdminContext(), clusterId) if err != nil { logs.Error(err) return } - cluster := clusterResp.Cluster if cluster == nil { action.WriteString("can not find cluster") return @@ -65,13 +61,14 @@ func (this *ClusterHelper) BeforeAction(action *actions.ActionObject) { secondMenuItem := action.Data.GetString("secondMenuItem") switch selectedTabbar { case "setting": - action.Data["leftMenuItems"] = this.createSettingMenu(clusterIdString, secondMenuItem) + action.Data["leftMenuItems"] = this.createSettingMenu(cluster, secondMenuItem) } } } // 设置菜单 -func (this *ClusterHelper) createSettingMenu(clusterId string, selectedItem string) (items []maps.Map) { +func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, selectedItem string) (items []maps.Map) { + clusterId := numberutils.FormatInt64(cluster.Id) items = append(items, maps.Map{ "name": "基础设置", "url": "/clusters/cluster/settings?clusterId=" + clusterId, @@ -81,11 +78,13 @@ func (this *ClusterHelper) createSettingMenu(clusterId string, selectedItem stri "name": "缓存设置", "url": "/clusters/cluster/settings/cache?clusterId=" + clusterId, "isActive": selectedItem == "cache", + "isOn": cluster.HttpCachePolicyId > 0, }) items = append(items, maps.Map{ "name": "WAF设置", "url": "/clusters/cluster/settings/waf?clusterId=" + clusterId, "isActive": selectedItem == "waf", + "isOn": cluster.HttpFirewallPolicyId > 0, }) items = append(items, maps.Map{ "name": "健康检查", diff --git a/internal/web/actions/default/clusters/grants/grant.go b/internal/web/actions/default/clusters/grants/grant.go index 452ff440..2dc61688 100644 --- a/internal/web/actions/default/clusters/grants/grant.go +++ b/internal/web/actions/default/clusters/grants/grant.go @@ -50,7 +50,7 @@ func (this *GrantAction) RunGet(params struct { this.ErrorPage(err) return } - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, @@ -66,13 +66,13 @@ func (this *GrantAction) RunGet(params struct { return } for _, node := range nodesResp.Nodes { - if node.Cluster == nil { + if node.NodeCluster == nil { continue } clusterMap := maps.Map{ - "id": node.Cluster.Id, - "name": node.Cluster.Name, + "id": node.NodeCluster.Id, + "name": node.NodeCluster.Name, } nodeMaps = append(nodeMaps, maps.Map{ diff --git a/internal/web/actions/default/clusters/index.go b/internal/web/actions/default/clusters/index.go index 1118b7a3..34aa99d9 100644 --- a/internal/web/actions/default/clusters/index.go +++ b/internal/web/actions/default/clusters/index.go @@ -36,7 +36,7 @@ func (this *IndexAction) RunGet(params struct{}) { this.ErrorPage(err) return } - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { // 全部节点数量 countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{NodeClusterId: cluster.Id}) if err != nil { diff --git a/internal/web/actions/default/clusters/options.go b/internal/web/actions/default/clusters/options.go index 35838dfd..2776f7c8 100644 --- a/internal/web/actions/default/clusters/options.go +++ b/internal/web/actions/default/clusters/options.go @@ -18,7 +18,7 @@ func (this *OptionsAction) RunPost(params struct{}) { } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/clusters/sync.go b/internal/web/actions/default/clusters/sync.go index 94bf10d5..4e0d2d29 100644 --- a/internal/web/actions/default/clusters/sync.go +++ b/internal/web/actions/default/clusters/sync.go @@ -21,7 +21,7 @@ func (this *SyncAction) RunPost(params struct{}) { this.ErrorPage(err) return } - clusters := clustersResp.Clusters + clusters := clustersResp.NodeClusters for _, cluster := range clusters { _, err := this.RPC().NodeRPC().SyncNodesVersionWithCluster(this.AdminContext(), &pb.SyncNodesVersionWithClusterRequest{ diff --git a/internal/web/actions/default/dns/clusters/cluster.go b/internal/web/actions/default/dns/clusters/cluster.go index 9a7b55a1..91928863 100644 --- a/internal/web/actions/default/dns/clusters/cluster.go +++ b/internal/web/actions/default/dns/clusters/cluster.go @@ -23,7 +23,7 @@ func (this *ClusterAction) RunGet(params struct { this.ErrorPage(err) return } - cluster := clusterResp.Cluster + cluster := clusterResp.NodeCluster if cluster == nil { this.NotFound("nodeCluster", params.ClusterId) return diff --git a/internal/web/actions/default/dns/index.go b/internal/web/actions/default/dns/index.go index 00144d95..c59a32bc 100644 --- a/internal/web/actions/default/dns/index.go +++ b/internal/web/actions/default/dns/index.go @@ -32,7 +32,7 @@ func (this *IndexAction) RunGet(params struct{}) { return } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { domainId := cluster.DnsDomainId domainName := "" providerId := int64(0) diff --git a/internal/web/actions/default/messages/index.go b/internal/web/actions/default/messages/index.go index 0c02b431..629d0749 100644 --- a/internal/web/actions/default/messages/index.go +++ b/internal/web/actions/default/messages/index.go @@ -38,10 +38,10 @@ func (this *IndexAction) RunGet(params struct{}) { messages := []maps.Map{} for _, message := range listResp.Messages { clusterMap := maps.Map{} - if message.Cluster != nil { + if message.NodeCluster != nil { clusterMap = maps.Map{ - "id": message.Cluster.Id, - "name": message.Cluster.Name, + "id": message.NodeCluster.Id, + "name": message.NodeCluster.Name, } } diff --git a/internal/web/actions/default/servers/components/cache/clean.go b/internal/web/actions/default/servers/components/cache/clean.go index 89519640..1e958b2d 100644 --- a/internal/web/actions/default/servers/components/cache/clean.go +++ b/internal/web/actions/default/servers/components/cache/clean.go @@ -21,7 +21,9 @@ func (this *CleanAction) Init() { this.Nav("", "", "clean") } -func (this *CleanAction) RunGet(params struct{}) { +func (this *CleanAction) RunGet(params struct { + CachePolicyId int64 +}) { // 默认的集群ID cookie, err := this.Request.Cookie("cache_cluster_id") if cookie != nil && err == nil { @@ -29,13 +31,13 @@ func (this *CleanAction) RunGet(params struct{}) { } // 集群列表 - clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{}) + clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId}) if err != nil { this.ErrorPage(err) return } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/servers/components/cache/preheat.go b/internal/web/actions/default/servers/components/cache/preheat.go index 08543391..e4ee2b04 100644 --- a/internal/web/actions/default/servers/components/cache/preheat.go +++ b/internal/web/actions/default/servers/components/cache/preheat.go @@ -23,7 +23,9 @@ func (this *PreheatAction) Init() { this.Nav("", "", "preheat") } -func (this *PreheatAction) RunGet(params struct{}) { +func (this *PreheatAction) RunGet(params struct { + CachePolicyId int64 +}) { // 默认的集群ID cookie, err := this.Request.Cookie("cache_cluster_id") if cookie != nil && err == nil { @@ -31,13 +33,13 @@ func (this *PreheatAction) RunGet(params struct{}) { } // 集群列表 - clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{}) + clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId}) if err != nil { this.ErrorPage(err) return } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/servers/components/cache/purge.go b/internal/web/actions/default/servers/components/cache/purge.go index 51007545..9cd0caf8 100644 --- a/internal/web/actions/default/servers/components/cache/purge.go +++ b/internal/web/actions/default/servers/components/cache/purge.go @@ -23,7 +23,9 @@ func (this *PurgeAction) Init() { this.Nav("", "", "purge") } -func (this *PurgeAction) RunGet(params struct{}) { +func (this *PurgeAction) RunGet(params struct { + CachePolicyId int64 +}) { // 默认的集群ID cookie, err := this.Request.Cookie("cache_cluster_id") if cookie != nil && err == nil { @@ -31,13 +33,13 @@ func (this *PurgeAction) RunGet(params struct{}) { } // 集群列表 - clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{}) + clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId}) if err != nil { this.ErrorPage(err) return } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/servers/components/cache/stat.go b/internal/web/actions/default/servers/components/cache/stat.go index 639ff4e3..33e59105 100644 --- a/internal/web/actions/default/servers/components/cache/stat.go +++ b/internal/web/actions/default/servers/components/cache/stat.go @@ -21,7 +21,9 @@ func (this *StatAction) Init() { this.Nav("", "", "stat") } -func (this *StatAction) RunGet(params struct{}) { +func (this *StatAction) RunGet(params struct { + CachePolicyId int64 +}) { // 默认的集群ID cookie, err := this.Request.Cookie("cache_cluster_id") if cookie != nil && err == nil { @@ -29,13 +31,13 @@ func (this *StatAction) RunGet(params struct{}) { } // 集群列表 - clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{}) + clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId}) if err != nil { this.ErrorPage(err) return } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/servers/components/cache/test.go b/internal/web/actions/default/servers/components/cache/test.go index a50c6b00..1b8b33cc 100644 --- a/internal/web/actions/default/servers/components/cache/test.go +++ b/internal/web/actions/default/servers/components/cache/test.go @@ -15,7 +15,9 @@ func (this *TestAction) Init() { this.Nav("", "", "test") } -func (this *TestAction) RunGet(params struct{}) { +func (this *TestAction) RunGet(params struct { + CachePolicyId int64 +}) { // 默认的集群ID cookie, err := this.Request.Cookie("cache_cluster_id") if cookie != nil && err == nil { @@ -23,13 +25,13 @@ func (this *TestAction) RunGet(params struct{}) { } // 集群列表 - clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{}) + clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId}) if err != nil { this.ErrorPage(err) return } clusterMaps := []maps.Map{} - for _, cluster := range clustersResp.Clusters { + for _, cluster := range clustersResp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/servers/create.go b/internal/web/actions/default/servers/create.go index dfa889a0..90492d11 100644 --- a/internal/web/actions/default/servers/create.go +++ b/internal/web/actions/default/servers/create.go @@ -30,7 +30,7 @@ func (this *CreateAction) RunGet(params struct{}) { return } clusterMaps := []maps.Map{} - for _, cluster := range resp.Clusters { + for _, cluster := range resp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, diff --git a/internal/web/actions/default/servers/index.go b/internal/web/actions/default/servers/index.go index 680a778a..fe19d616 100644 --- a/internal/web/actions/default/servers/index.go +++ b/internal/web/actions/default/servers/index.go @@ -151,8 +151,8 @@ func (this *IndexAction) RunGet(params struct { "isOn": server.IsOn, "name": server.Name, "cluster": maps.Map{ - "id": server.Cluster.Id, - "name": server.Cluster.Name, + "id": server.NodeCluster.Id, + "name": server.NodeCluster.Name, }, "ports": portMaps, "serverTypeName": serverconfigs.FindServerType(server.Type).GetString("name"), diff --git a/internal/web/actions/default/servers/server/settings/index.go b/internal/web/actions/default/servers/server/settings/index.go index 93ecf1b6..684efc02 100644 --- a/internal/web/actions/default/servers/server/settings/index.go +++ b/internal/web/actions/default/servers/server/settings/index.go @@ -33,7 +33,7 @@ func (this *IndexAction) RunGet(params struct { return } clusterMaps := []maps.Map{} - for _, cluster := range resp.Clusters { + for _, cluster := range resp.NodeClusters { clusterMaps = append(clusterMaps, maps.Map{ "id": cluster.Id, "name": cluster.Name, @@ -54,8 +54,8 @@ func (this *IndexAction) RunGet(params struct { } clusterId := int64(0) - if server.Cluster != nil { - clusterId = server.Cluster.Id + if server.NodeCluster != nil { + clusterId = server.NodeCluster.Id } // 分组 diff --git a/internal/web/actions/default/users/index.go b/internal/web/actions/default/users/index.go index 656c8b79..4745b718 100644 --- a/internal/web/actions/default/users/index.go +++ b/internal/web/actions/default/users/index.go @@ -35,10 +35,10 @@ func (this *IndexAction) RunGet(params struct { userMaps := []maps.Map{} for _, user := range usersResp.Users { var clusterMap maps.Map = nil - if user.Cluster != nil { + if user.NodeCluster != nil { clusterMap = maps.Map{ - "id": user.Cluster.Id, - "name": user.Cluster.Name, + "id": user.NodeCluster.Id, + "name": user.NodeCluster.Name, } } userMaps = append(userMaps, maps.Map{ diff --git a/internal/web/actions/default/users/update.go b/internal/web/actions/default/users/update.go index ae3a589b..45568b17 100644 --- a/internal/web/actions/default/users/update.go +++ b/internal/web/actions/default/users/update.go @@ -48,8 +48,8 @@ func (this *UpdateAction) RunGet(params struct { } this.Data["clusterId"] = 0 - if user.Cluster != nil { - this.Data["clusterId"] = user.Cluster.Id + if user.NodeCluster != nil { + this.Data["clusterId"] = user.NodeCluster.Id } this.Show() diff --git a/internal/web/actions/default/users/user.go b/internal/web/actions/default/users/user.go index 8b63b004..f9e2f49f 100644 --- a/internal/web/actions/default/users/user.go +++ b/internal/web/actions/default/users/user.go @@ -36,10 +36,10 @@ func (this *UserAction) RunGet(params struct { } var clusterMap maps.Map = nil - if user.Cluster != nil { + if user.NodeCluster != nil { clusterMap = maps.Map{ - "id": user.Cluster.Id, - "name": user.Cluster.Name, + "id": user.NodeCluster.Id, + "name": user.NodeCluster.Name, } } diff --git a/internal/web/models/http_cache_policy_dao.go b/internal/web/models/http_cache_policy_dao.go index 5a2d8138..1dd51d45 100644 --- a/internal/web/models/http_cache_policy_dao.go +++ b/internal/web/models/http_cache_policy_dao.go @@ -51,10 +51,10 @@ func (this *HTTPCachePolicyDAO) FindEnabledHTTPCachePolicyWithServerId(ctx conte if server == nil { return nil, nil } - if server.Cluster == nil { + if server.NodeCluster == nil { return nil, nil } - clusterId := server.Cluster.Id + clusterId := server.NodeCluster.Id cluster, err := SharedNodeClusterDAO.FindEnabledNodeCluster(ctx, clusterId) if err != nil { return nil, err diff --git a/internal/web/models/http_firewall_policy_dao.go b/internal/web/models/http_firewall_policy_dao.go index 530ccf80..4a851c46 100644 --- a/internal/web/models/http_firewall_policy_dao.go +++ b/internal/web/models/http_firewall_policy_dao.go @@ -172,10 +172,10 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledHTTPFirewallPolicyWithServerId(ctx if server == nil { return nil, nil } - if server.Cluster == nil { + if server.NodeCluster == nil { return nil, nil } - clusterId := server.Cluster.Id + clusterId := server.NodeCluster.Id cluster, err := SharedNodeClusterDAO.FindEnabledNodeCluster(ctx, clusterId) if err != nil { return nil, err diff --git a/internal/web/models/node_cluster_dao.go b/internal/web/models/node_cluster_dao.go index 82c0fabf..e6262d6a 100644 --- a/internal/web/models/node_cluster_dao.go +++ b/internal/web/models/node_cluster_dao.go @@ -17,5 +17,5 @@ func (this *NodeClusterDAO) FindEnabledNodeCluster(ctx context.Context, clusterI if err != nil { return nil, err } - return clusterResp.Cluster, nil + return clusterResp.NodeCluster, nil } diff --git a/web/public/js/components/server/http-cache-policy-selector.js b/web/public/js/components/server/http-cache-policy-selector.js index 053e9bc9..3527bdb6 100644 --- a/web/public/js/components/server/http-cache-policy-selector.js +++ b/web/public/js/components/server/http-cache-policy-selector.js @@ -40,7 +40,7 @@ Vue.component("http-cache-policy-selector", { template: `
- {{cachePolicy.name}}     + {{cachePolicy.name}}    
[选择已有策略]     [创建新策略] diff --git a/web/public/js/components/server/http-firewall-policy-selector.js b/web/public/js/components/server/http-firewall-policy-selector.js index 1a8b965a..ed191bcd 100644 --- a/web/public/js/components/server/http-firewall-policy-selector.js +++ b/web/public/js/components/server/http-firewall-policy-selector.js @@ -40,7 +40,7 @@ Vue.component("http-firewall-policy-selector", { template: `
- {{firewallPolicy.name}}     + {{firewallPolicy.name}}    
[选择已有策略]     [创建新策略]