68 lines
2.6 KiB
Go
68 lines
2.6 KiB
Go
package httpdnsutils
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
func AddLeftMenu(action *actionutils.ParentAction) {
|
|
tab := action.Data.GetString("mainTab")
|
|
action.Data["teaMenu"] = "httpdns"
|
|
action.Data["teaSubMenu"] = tab
|
|
action.Data["leftMenuItems"] = []maps.Map{
|
|
{
|
|
"name": "\u96c6\u7fa4\u7ba1\u7406",
|
|
"url": "/httpdns/clusters",
|
|
"isActive": tab == "cluster",
|
|
},
|
|
{
|
|
"name": "\u5e94\u7528\u7ba1\u7406",
|
|
"url": "/httpdns/apps",
|
|
"isActive": tab == "app",
|
|
},
|
|
{
|
|
"name": "\u8bbf\u95ee\u65e5\u5fd7",
|
|
"url": "/httpdns/resolveLogs",
|
|
"isActive": tab == "resolveLogs",
|
|
},
|
|
{
|
|
"name": "\u8fd0\u884c\u65e5\u5fd7",
|
|
"url": "/httpdns/runtimeLogs",
|
|
"isActive": tab == "runtimeLogs",
|
|
},
|
|
{
|
|
"name": "\u89e3\u6790\u6d4b\u8bd5",
|
|
"url": "/httpdns/sandbox",
|
|
"isActive": tab == "sandbox",
|
|
},
|
|
}
|
|
}
|
|
|
|
// AddClusterTabbar builds the top tabbar on cluster pages.
|
|
func AddClusterTabbar(action *actionutils.ParentAction, clusterName string, clusterId int64, selectedTab string) {
|
|
cid := strconv.FormatInt(clusterId, 10)
|
|
tabbar := actionutils.NewTabbar()
|
|
tabbar.Add("", "", "/httpdns/clusters", "arrow left", false)
|
|
titleItem := tabbar.Add(clusterName, "", "/httpdns/clusters/cluster?clusterId="+cid, "angle right", true)
|
|
titleItem.IsTitle = true
|
|
tabbar.Add("\u8282\u70b9\u5217\u8868", "", "/httpdns/clusters/cluster?clusterId="+cid, "server", selectedTab == "node")
|
|
tabbar.Add("\u96c6\u7fa4\u8bbe\u7f6e", "", "/httpdns/clusters/cluster/settings?clusterId="+cid, "setting", selectedTab == "setting")
|
|
tabbar.Add("\u5220\u9664\u96c6\u7fa4", "", "/httpdns/clusters/delete?clusterId="+cid, "trash", selectedTab == "delete")
|
|
actionutils.SetTabbar(action, tabbar)
|
|
}
|
|
|
|
// AddAppTabbar builds the top tabbar on app pages.
|
|
func AddAppTabbar(action *actionutils.ParentAction, appName string, appId int64, selectedTab string) {
|
|
aid := strconv.FormatInt(appId, 10)
|
|
tabbar := actionutils.NewTabbar()
|
|
tabbar.Add("", "", "/httpdns/apps", "arrow left", false)
|
|
titleItem := tabbar.Add(appName, "", "/httpdns/apps/domains?appId="+aid, "angle right", true)
|
|
titleItem.IsTitle = true
|
|
tabbar.Add("\u57df\u540d\u5217\u8868", "", "/httpdns/apps/domains?appId="+aid, "list", selectedTab == "domains")
|
|
tabbar.Add("\u5e94\u7528\u8bbe\u7f6e", "", "/httpdns/apps/app/settings?appId="+aid, "setting", selectedTab == "settings")
|
|
tabbar.Add("\u5220\u9664\u5e94\u7528", "", "/httpdns/apps/delete?appId="+aid, "trash", selectedTab == "delete")
|
|
actionutils.SetTabbar(action, tabbar)
|
|
}
|