diff --git a/internal/web/actions/actionutils/tabbar.go b/internal/web/actions/actionutils/tabbar.go index e10e6bbf..40c2210b 100644 --- a/internal/web/actions/actionutils/tabbar.go +++ b/internal/web/actions/actionutils/tabbar.go @@ -2,38 +2,49 @@ package actionutils import ( "github.com/iwind/TeaGo/actions" - "github.com/iwind/TeaGo/maps" ) +type TabItem struct { + Name string `json:"name"` + SubName string `json:"subName"` + URL string `json:"url"` + Icon string `json:"icon"` + IsActive bool `json:"isActive"` + IsRight bool `json:"isRight"` + IsTitle bool `json:"isTitle"` + IsDisabled bool `json:"isDisabled"` +} + // Tabbar Tabbar定义 type Tabbar struct { - items []maps.Map + items []*TabItem } // NewTabbar 获取新对象 func NewTabbar() *Tabbar { return &Tabbar{ - items: []maps.Map{}, + items: []*TabItem{}, } } // Add 添加菜单项 -func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) maps.Map { - m := maps.Map{ - "name": name, - "subName": subName, - "url": url, - "icon": icon, - "active": active, - "right": false, - "isTitle": false, +func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) *TabItem { + var m = &TabItem{ + Name: name, + SubName: subName, + URL: url, + Icon: icon, + IsActive: active, + IsRight: false, + IsTitle: false, + IsDisabled: false, } this.items = append(this.items, m) return m } // Items 取得所有的Items -func (this *Tabbar) Items() []maps.Map { +func (this *Tabbar) Items() []*TabItem { return this.items } diff --git a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go index b87cbd94..dbf408b2 100644 --- a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go @@ -29,9 +29,9 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext action.Data["teaMenu"] = "clusters" - selectedTabbar := action.Data.GetString("mainTab") - clusterId := action.ParamInt64("clusterId") - clusterIdString := strconv.FormatInt(clusterId, 10) + var selectedTabbar = action.Data.GetString("mainTab") + var clusterId = action.ParamInt64("clusterId") + var clusterIdString = strconv.FormatInt(clusterId, 10) action.Data["clusterId"] = clusterId if clusterId > 0 { @@ -57,18 +57,39 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext return } + var nodeId = action.ParamInt64("nodeId") + var isInCluster = nodeId <= 0 + var tabbar = actionutils.NewTabbar() tabbar.Add("", "", "/clusters", "arrow left", false) { - var item = tabbar.Add(cluster.Name, "", "/clusters/cluster?clusterId="+clusterIdString, "angle right", true) - item["isTitle"] = true + var url = "/clusters/cluster?clusterId=" + clusterIdString + if !isInCluster { + url = "/clusters/cluster/nodes?clusterId=" + clusterIdString + } + + var item = tabbar.Add(cluster.Name, "", url, "angle right", true) + item.IsTitle = true } if teaconst.IsPlus { - tabbar.Add("看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board") + { + var item = tabbar.Add("集群看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board") + item.IsDisabled = !isInCluster + } + } + { + var item = tabbar.Add("节点列表", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node") + item.IsDisabled = !isInCluster + } + + { + var item = tabbar.Add("集群设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting") + item.IsDisabled = !isInCluster + } + { + var item = tabbar.Add("删除集群", "", "/clusters/cluster/delete?clusterId="+clusterIdString, "trash", selectedTabbar == "delete") + item.IsDisabled = !isInCluster } - tabbar.Add("节点", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node") - tabbar.Add("设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting") - tabbar.Add("删除", "", "/clusters/cluster/delete?clusterId="+clusterIdString, "trash", selectedTabbar == "delete") actionutils.SetTabbar(action, tabbar) // 左侧菜单 diff --git a/internal/web/actions/default/servers/serverutils/server_helper.go b/internal/web/actions/default/servers/serverutils/server_helper.go index eebd7ff9..46d3afbf 100644 --- a/internal/web/actions/default/servers/serverutils/server_helper.go +++ b/internal/web/actions/default/servers/serverutils/server_helper.go @@ -110,7 +110,7 @@ func (this *ServerHelper) createLeftMenu(action *actions.ActionObject) { tabbar.Add("", "", "/servers", "left arrow", false) if len(serverConfig.Name) > 0 { var item = tabbar.Add(serverConfig.Name, "", "/servers/server?serverId="+serverIdString, "angle right", true) - item["isTitle"] = true + item.IsTitle = true } if teaconst.IsPlus { diff --git a/web/views/@default/@layout.html b/web/views/@default/@layout.html index 7f2963e4..0020f072 100644 --- a/web/views/@default/@layout.html +++ b/web/views/@default/@layout.html @@ -107,9 +107,10 @@