mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-08 07:50:28 +08:00
部分中文转换为多语言代号
This commit is contained in:
@@ -4,22 +4,24 @@
|
|||||||
package nodelogutils
|
package nodelogutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FindCommonTags 查找常用的标签
|
// FindCommonTags 查找常用的标签
|
||||||
func FindNodeCommonTags() []maps.Map {
|
func FindNodeCommonTags(langCode langs.LangCode) []maps.Map {
|
||||||
return []maps.Map{
|
return []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "端口监听",
|
"name": langs.Message(langCode, codes.AdminLogTagListener),
|
||||||
"code": "LISTENER",
|
"code": "LISTENER",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "WAF",
|
"name": langs.Message(langCode, codes.AdminLogTagWAF),
|
||||||
"code": "WAF",
|
"code": "WAF",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "访问日志",
|
"name": langs.Message(langCode, codes.AdminLogTagAccessLog),
|
||||||
"code": "ACCESS_LOG",
|
"code": "ACCESS_LOG",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ func (this *CreateNodeAction) RunPost(params struct {
|
|||||||
"id": grantResp.NodeGrant.Id,
|
"id": grantResp.NodeGrant.Id,
|
||||||
"name": grantResp.NodeGrant.Name,
|
"name": grantResp.NodeGrant.Name,
|
||||||
"method": grantResp.NodeGrant.Method,
|
"method": grantResp.NodeGrant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||||
"username": grantResp.NodeGrant.Username,
|
"username": grantResp.NodeGrant.Username,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ func (this *DetailAction) RunGet(params struct {
|
|||||||
"id": grantResp.NodeGrant.Id,
|
"id": grantResp.NodeGrant.Id,
|
||||||
"name": grantResp.NodeGrant.Name,
|
"name": grantResp.NodeGrant.Name,
|
||||||
"method": grantResp.NodeGrant.Method,
|
"method": grantResp.NodeGrant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||||
"username": grantResp.NodeGrant.Username,
|
"username": grantResp.NodeGrant.Username,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func (this *LogsAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
this.Data["tags"] = nodelogutils.FindNodeCommonTags(this.LangCode())
|
||||||
|
|
||||||
this.Data["nodeId"] = params.NodeId
|
this.Data["nodeId"] = params.NodeId
|
||||||
this.Data["dayFrom"] = params.DayFrom
|
this.Data["dayFrom"] = params.DayFrom
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
"id": grantResp.NodeGrant.Id,
|
"id": grantResp.NodeGrant.Id,
|
||||||
"name": grantResp.NodeGrant.Name,
|
"name": grantResp.NodeGrant.Name,
|
||||||
"method": grantResp.NodeGrant.Method,
|
"method": grantResp.NodeGrant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||||
"username": grantResp.NodeGrant.Username,
|
"username": grantResp.NodeGrant.Username,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func (this *UpdateNodeSSHAction) RunGet(params struct {
|
|||||||
"id": grantResp.NodeGrant.Id,
|
"id": grantResp.NodeGrant.Id,
|
||||||
"name": grantResp.NodeGrant.Name,
|
"name": grantResp.NodeGrant.Name,
|
||||||
"method": grantResp.NodeGrant.Method,
|
"method": grantResp.NodeGrant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.Data["grant"] = grantMap
|
this.Data["grant"] = grantMap
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func (this *CreateAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreateAction) RunGet(params struct{}) {
|
func (this *CreateAction) RunGet(params struct{}) {
|
||||||
this.Data["methods"] = grantutils.AllGrantMethods()
|
this.Data["methods"] = grantutils.AllGrantMethods(this.LangCode())
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func (this *CreatePopupAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
func (this *CreatePopupAction) RunGet(params struct{}) {
|
||||||
this.Data["methods"] = grantutils.AllGrantMethods()
|
this.Data["methods"] = grantutils.AllGrantMethods(this.LangCode())
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
"id": createResp.NodeGrantId,
|
"id": createResp.NodeGrantId,
|
||||||
"name": params.Name,
|
"name": params.Name,
|
||||||
"method": params.Method,
|
"method": params.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(params.Method),
|
"methodName": grantutils.FindGrantMethodName(params.Method, this.LangCode()),
|
||||||
"username": params.Username,
|
"username": params.Username,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (this *GrantAction) RunGet(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
"username": grant.Username,
|
"username": grant.Username,
|
||||||
"password": strings.Repeat("*", len(grant.Password)),
|
"password": strings.Repeat("*", len(grant.Password)),
|
||||||
"privateKey": grant.PrivateKey,
|
"privateKey": grant.PrivateKey,
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
package grantutils
|
package grantutils
|
||||||
|
|
||||||
import "github.com/iwind/TeaGo/maps"
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
)
|
||||||
|
|
||||||
// 所有的认证类型
|
// AllGrantMethods 所有的认证类型
|
||||||
func AllGrantMethods() []maps.Map {
|
func AllGrantMethods(langCode langs.LangCode) []maps.Map {
|
||||||
return []maps.Map{
|
return []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "用户名+密码",
|
"name": langs.Message(langCode, codes.AdminNodeGrantMethodUserPassword),
|
||||||
"value": "user",
|
"value": "user",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "私钥",
|
"name": langs.Message(langCode, codes.AdminNodeGrantMethodPrivateKey),
|
||||||
"value": "privateKey",
|
"value": "privateKey",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获得对应的认证类型名称
|
// FindGrantMethodName 获得对应的认证类型名称
|
||||||
func FindGrantMethodName(method string) string {
|
func FindGrantMethodName(method string, langCode langs.LangCode) string {
|
||||||
for _, m := range AllGrantMethods() {
|
for _, m := range AllGrantMethods(langCode) {
|
||||||
if m.GetString("value") == method {
|
if m.GetString("value") == method {
|
||||||
return m.GetString("name")
|
return m.GetString("name")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": maps.Map{
|
"method": maps.Map{
|
||||||
"type": grant.Method,
|
"type": grant.Method,
|
||||||
"name": grantutils.FindGrantMethodName(grant.Method),
|
"name": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
},
|
},
|
||||||
"username": grant.Username,
|
"username": grant.Username,
|
||||||
"countClusters": countClusters,
|
"countClusters": countClusters,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func (this *SelectPopupAction) RunGet(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
"username": grant.Username,
|
"username": grant.Username,
|
||||||
"description": grant.Description,
|
"description": grant.Description,
|
||||||
})
|
})
|
||||||
@@ -55,7 +55,7 @@ func (this *SelectPopupAction) RunGet(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
"username": grant.Username,
|
"username": grant.Username,
|
||||||
"description": grant.Description,
|
"description": grant.Description,
|
||||||
})
|
})
|
||||||
@@ -92,7 +92,7 @@ func (this *SelectPopupAction) RunPost(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func (this *TestAction) RunGet(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
"username": grant.Username,
|
"username": grant.Username,
|
||||||
"password": strings.Repeat("*", len(grant.Password)),
|
"password": strings.Repeat("*", len(grant.Password)),
|
||||||
"privateKey": grant.PrivateKey,
|
"privateKey": grant.PrivateKey,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func (this *UpdateAction) Init() {
|
|||||||
func (this *UpdateAction) RunGet(params struct {
|
func (this *UpdateAction) RunGet(params struct {
|
||||||
GrantId int64
|
GrantId int64
|
||||||
}) {
|
}) {
|
||||||
this.Data["methods"] = grantutils.AllGrantMethods()
|
this.Data["methods"] = grantutils.AllGrantMethods(this.LangCode())
|
||||||
|
|
||||||
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: params.GrantId})
|
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: params.GrantId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -40,7 +40,7 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||||
"username": grant.Username,
|
"username": grant.Username,
|
||||||
"password": grant.Password,
|
"password": grant.Password,
|
||||||
"privateKey": grant.PrivateKey,
|
"privateKey": grant.PrivateKey,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func (this *UpdatePopupAction) Init() {
|
|||||||
func (this *UpdatePopupAction) RunGet(params struct {
|
func (this *UpdatePopupAction) RunGet(params struct {
|
||||||
GrantId int64
|
GrantId int64
|
||||||
}) {
|
}) {
|
||||||
this.Data["methods"] = grantutils.AllGrantMethods()
|
this.Data["methods"] = grantutils.AllGrantMethods(this.LangCode())
|
||||||
|
|
||||||
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: params.GrantId})
|
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: params.GrantId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -123,7 +123,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
"id": params.GrantId,
|
"id": params.GrantId,
|
||||||
"name": params.Name,
|
"name": params.Name,
|
||||||
"method": params.Method,
|
"method": params.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(params.Method),
|
"methodName": grantutils.FindGrantMethodName(params.Method, this.LangCode()),
|
||||||
"username": params.Username,
|
"username": params.Username,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 常见标签
|
// 常见标签
|
||||||
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
this.Data["tags"] = nodelogutils.FindNodeCommonTags(this.LangCode())
|
||||||
|
|
||||||
// 未读数量
|
// 未读数量
|
||||||
countUnreadResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
countUnreadResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package log
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
@@ -41,15 +42,15 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["levelOptions"] = []maps.Map{
|
this.Data["levelOptions"] = []maps.Map{
|
||||||
{
|
{
|
||||||
"code": "info",
|
"code": "info",
|
||||||
"name": "信息",
|
"name": this.Lang(codes.AdminLevelInfo),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "warn",
|
"code": "warn",
|
||||||
"name": "警告",
|
"name": this.Lang(codes.AdminLevelWarn),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "error",
|
"code": "error",
|
||||||
"name": "错误",
|
"name": this.Lang(codes.AdminLevelError),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package certs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
@@ -10,14 +12,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Helper struct {
|
type Helper struct {
|
||||||
|
helpers.LangHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHelper() *Helper {
|
func NewHelper() *Helper {
|
||||||
return &Helper{}
|
return &Helper{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Helper) BeforeAction(actionWrapper actions.ActionWrapper) {
|
func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) {
|
||||||
var action = actionWrapper.Object()
|
var action = actionPtr.Object()
|
||||||
if action.Request.Method != http.MethodGet {
|
if action.Request.Method != http.MethodGet {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -25,7 +28,7 @@ func (this *Helper) BeforeAction(actionWrapper actions.ActionWrapper) {
|
|||||||
action.Data["teaMenu"] = "servers"
|
action.Data["teaMenu"] = "servers"
|
||||||
|
|
||||||
var countOCSP int64 = 0
|
var countOCSP int64 = 0
|
||||||
parentAction, ok := actionWrapper.(actionutils.ActionInterface)
|
parentAction, ok := actionPtr.(actionutils.ActionInterface)
|
||||||
if ok {
|
if ok {
|
||||||
countOCSPResp, err := parentAction.RPC().SSLCertRPC().CountAllSSLCertsWithOCSPError(parentAction.AdminContext(), &pb.CountAllSSLCertsWithOCSPErrorRequest{})
|
countOCSPResp, err := parentAction.RPC().SSLCertRPC().CountAllSSLCertsWithOCSPError(parentAction.AdminContext(), &pb.CountAllSSLCertsWithOCSPErrorRequest{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -33,19 +36,19 @@ func (this *Helper) BeforeAction(actionWrapper actions.ActionWrapper) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ocspMenuName = "OCSP日志"
|
var ocspMenuName = this.Lang(actionPtr, codes.AdminCertMenuOCSP)
|
||||||
if countOCSP > 0 {
|
if countOCSP > 0 {
|
||||||
ocspMenuName += "(" + types.String(countOCSP) + ")"
|
ocspMenuName += "(" + types.String(countOCSP) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
var menu = []maps.Map{
|
var menu = []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "证书",
|
"name": this.Lang(actionPtr, codes.AdminCertMenuCerts),
|
||||||
"url": "/servers/certs",
|
"url": "/servers/certs",
|
||||||
"isActive": action.Data.GetString("leftMenuItem") == "cert",
|
"isActive": action.Data.GetString("leftMenuItem") == "cert",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "申请证书",
|
"name": this.Lang(actionPtr, codes.AdminCertMenuApply),
|
||||||
"url": "/servers/certs/acme",
|
"url": "/servers/certs/acme",
|
||||||
"isActive": action.Data.GetString("leftMenuItem") == "acme",
|
"isActive": action.Data.GetString("leftMenuItem") == "acme",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package waf
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||||
@@ -41,14 +42,14 @@ func (this *CreateSetPopupAction) RunGet(params struct {
|
|||||||
// 一些配置
|
// 一些配置
|
||||||
this.Data["connectors"] = []maps.Map{
|
this.Data["connectors"] = []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "和(AND)",
|
"name": this.Lang(codes.AdminWAFConnectorAnd),
|
||||||
"value": firewallconfigs.HTTPFirewallRuleConnectorAnd,
|
"value": firewallconfigs.HTTPFirewallRuleConnectorAnd,
|
||||||
"description": "所有规则都满足才视为匹配",
|
"description": this.Lang(codes.AdminWAFConnectorAndDescription),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "或(OR)",
|
"name": this.Lang(codes.AdminWAFConnectorOr),
|
||||||
"value": firewallconfigs.HTTPFirewallRuleConnectorOr,
|
"value": firewallconfigs.HTTPFirewallRuleConnectorOr,
|
||||||
"description": "任一规则满足了就视为匹配",
|
"description": this.Lang(codes.AdminWAFConnectorOrDescription),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||||
@@ -45,14 +46,14 @@ func (this *UpdateSetPopupAction) RunGet(params struct {
|
|||||||
// 一些配置
|
// 一些配置
|
||||||
this.Data["connectors"] = []maps.Map{
|
this.Data["connectors"] = []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "和(AND)",
|
"name": this.Lang(codes.AdminWAFConnectorAnd),
|
||||||
"value": firewallconfigs.HTTPFirewallRuleConnectorAnd,
|
"value": firewallconfigs.HTTPFirewallRuleConnectorAnd,
|
||||||
"description": "所有规则都满足才视为匹配",
|
"description": this.Lang(codes.AdminWAFConnectorAndDescription),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "或(OR)",
|
"name": this.Lang(codes.AdminWAFConnectorOr),
|
||||||
"value": firewallconfigs.HTTPFirewallRuleConnectorOr,
|
"value": firewallconfigs.HTTPFirewallRuleConnectorOr,
|
||||||
"description": "任一规则满足了就视为匹配",
|
"description": this.Lang(codes.AdminWAFConnectorOrDescription),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,15 @@
|
|||||||
package servergrouputils
|
package servergrouputils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
func filterMenuItems(leftMenuItems []maps.Map, groupId int64, urlPrefix string, menuItem string, configInfoResp *pb.FindEnabledServerGroupConfigInfoResponse) []maps.Map {
|
func filterMenuItems(leftMenuItems []maps.Map, groupId int64, urlPrefix string, menuItem string, configInfoResp *pb.FindEnabledServerGroupConfigInfoResponse, parent *actionutils.ParentAction) []maps.Map {
|
||||||
return leftMenuItems
|
return leftMenuItems
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterMenuItems2(leftMenuItems []maps.Map, groupId int64, urlPrefix string, menuItem string, configInfoResp *pb.FindEnabledServerGroupConfigInfoResponse) []maps.Map {
|
func filterMenuItems2(leftMenuItems []maps.Map, groupId int64, urlPrefix string, menuItem string, configInfoResp *pb.FindEnabledServerGroupConfigInfoResponse, parent *actionutils.ParentAction) []maps.Map {
|
||||||
return leftMenuItems
|
return leftMenuItems
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package servergrouputils
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
@@ -37,39 +38,39 @@ func InitGroup(parent *actionutils.ParentAction, groupId int64, menuItem string)
|
|||||||
var urlPrefix = "/servers/groups/group/settings"
|
var urlPrefix = "/servers/groups/group/settings"
|
||||||
var leftMenuItems = []maps.Map{
|
var leftMenuItems = []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "HTTP代理",
|
"name": parent.Lang(codes.AdminServerMenuSettingHTTPProxy),
|
||||||
"url": urlPrefix + "/httpReverseProxy?groupId=" + types.String(groupId),
|
"url": urlPrefix + "/httpReverseProxy?groupId=" + types.String(groupId),
|
||||||
"isActive": menuItem == "httpReverseProxy",
|
"isActive": menuItem == "httpReverseProxy",
|
||||||
"isOn": configInfoResp.HasHTTPReverseProxy,
|
"isOn": configInfoResp.HasHTTPReverseProxy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "TCP代理",
|
"name": parent.Lang(codes.AdminServerMenuSettingTCPProxy),
|
||||||
"url": urlPrefix + "/tcpReverseProxy?groupId=" + types.String(groupId),
|
"url": urlPrefix + "/tcpReverseProxy?groupId=" + types.String(groupId),
|
||||||
"isActive": menuItem == "tcpReverseProxy",
|
"isActive": menuItem == "tcpReverseProxy",
|
||||||
"isOn": configInfoResp.HasTCPReverseProxy,
|
"isOn": configInfoResp.HasTCPReverseProxy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "UDP代理",
|
"name": parent.Lang(codes.AdminServerMenuSettingUDPProxy),
|
||||||
"url": urlPrefix + "/udpReverseProxy?groupId=" + types.String(groupId),
|
"url": urlPrefix + "/udpReverseProxy?groupId=" + types.String(groupId),
|
||||||
"isActive": menuItem == "udpReverseProxy",
|
"isActive": menuItem == "udpReverseProxy",
|
||||||
"isOn": configInfoResp.HasUDPReverseProxy,
|
"isOn": configInfoResp.HasUDPReverseProxy,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
leftMenuItems = filterMenuItems(leftMenuItems, groupId, urlPrefix, menuItem, configInfoResp)
|
leftMenuItems = filterMenuItems(leftMenuItems, groupId, urlPrefix, menuItem, configInfoResp, parent)
|
||||||
|
|
||||||
leftMenuItems = append(leftMenuItems, maps.Map{
|
leftMenuItems = append(leftMenuItems, maps.Map{
|
||||||
"name": "-",
|
"name": "-",
|
||||||
"url": "",
|
"url": "",
|
||||||
})
|
})
|
||||||
leftMenuItems = append(leftMenuItems, maps.Map{
|
leftMenuItems = append(leftMenuItems, maps.Map{
|
||||||
"name": "访客IP地址",
|
"name": parent.Lang(codes.AdminServerMenuSettingClientIP),
|
||||||
"url": urlPrefix + "/remoteAddr?groupId=" + types.String(groupId),
|
"url": urlPrefix + "/remoteAddr?groupId=" + types.String(groupId),
|
||||||
"isActive": menuItem == "remoteAddr",
|
"isActive": menuItem == "remoteAddr",
|
||||||
"isOn": configInfoResp.HasRemoteAddrConfig,
|
"isOn": configInfoResp.HasRemoteAddrConfig,
|
||||||
})
|
})
|
||||||
|
|
||||||
leftMenuItems = filterMenuItems2(leftMenuItems, groupId, urlPrefix, menuItem, configInfoResp)
|
leftMenuItems = filterMenuItems2(leftMenuItems, groupId, urlPrefix, menuItem, configInfoResp, parent)
|
||||||
|
|
||||||
parent.Data["leftMenuItems"] = leftMenuItems
|
parent.Data["leftMenuItems"] = leftMenuItems
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package locationutils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
@@ -10,6 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LocationHelper struct {
|
type LocationHelper struct {
|
||||||
|
helpers.LangHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocationHelper() *LocationHelper {
|
func NewLocationHelper() *LocationHelper {
|
||||||
@@ -48,31 +51,31 @@ func (this *LocationHelper) BeforeAction(actionPtr actions.ActionWrapper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 左侧菜单
|
// 左侧菜单
|
||||||
action.Data["tinyLeftMenuItems"] = this.createMenus(serverIdString, locationIdString, action.Data.GetString("tinyMenuItem"), currentLocationConfig)
|
action.Data["tinyLeftMenuItems"] = this.createMenus(serverIdString, locationIdString, action.Data.GetString("tinyMenuItem"), currentLocationConfig, actionPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *LocationHelper) createMenus(serverIdString string, locationIdString string, secondMenuItem string, locationConfig *serverconfigs.HTTPLocationConfig) []maps.Map {
|
func (this *LocationHelper) createMenus(serverIdString string, locationIdString string, secondMenuItem string, locationConfig *serverconfigs.HTTPLocationConfig, actionPtr actions.ActionWrapper) []maps.Map {
|
||||||
menuItems := []maps.Map{}
|
menuItems := []maps.Map{}
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "基本信息",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingBasic),
|
||||||
"url": "/servers/server/settings/locations/location?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/location?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "basic",
|
"isActive": secondMenuItem == "basic",
|
||||||
"isOff": locationConfig != nil && !locationConfig.IsOn,
|
"isOff": locationConfig != nil && !locationConfig.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTP",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingHTTP),
|
||||||
"url": "/servers/server/settings/locations/http?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/http?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "http",
|
"isActive": secondMenuItem == "http",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RedirectToHttps != nil && locationConfig.Web.RedirectToHttps.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RedirectToHttps != nil && locationConfig.Web.RedirectToHttps.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "源站",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingOrigins),
|
||||||
"url": "/servers/server/settings/locations/reverseProxy?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/reverseProxy?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "reverseProxy",
|
"isActive": secondMenuItem == "reverseProxy",
|
||||||
"isOn": locationConfig != nil && locationConfig.ReverseProxyRef != nil && locationConfig.ReverseProxyRef.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.ReverseProxyRef != nil && locationConfig.ReverseProxyRef.IsPrior,
|
||||||
})
|
})
|
||||||
|
|
||||||
menuItems = filterMenuItems1(locationConfig, menuItems, serverIdString, locationIdString, secondMenuItem)
|
menuItems = this.filterMenuItems1(locationConfig, menuItems, serverIdString, locationIdString, secondMenuItem, actionPtr)
|
||||||
|
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "-",
|
"name": "-",
|
||||||
@@ -80,103 +83,103 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
|
|||||||
"isActive": false,
|
"isActive": false,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "重写规则",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingRewriteRules),
|
||||||
"url": "/servers/server/settings/locations/rewrite?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/rewrite?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "rewrite",
|
"isActive": secondMenuItem == "rewrite",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && len(locationConfig.Web.RewriteRefs) > 0,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && len(locationConfig.Web.RewriteRefs) > 0,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "WAF",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingWAF),
|
||||||
"url": "/servers/server/settings/locations/waf?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/waf?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "waf",
|
"isActive": secondMenuItem == "waf",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FirewallRef != nil && locationConfig.Web.FirewallRef.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FirewallRef != nil && locationConfig.Web.FirewallRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "缓存",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingCache),
|
||||||
"url": "/servers/server/settings/locations/cache?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/cache?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "cache",
|
"isActive": secondMenuItem == "cache",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Cache != nil && locationConfig.Web.Cache.IsPrior && locationConfig.Web.Cache.IsOn,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Cache != nil && locationConfig.Web.Cache.IsPrior && locationConfig.Web.Cache.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "访问鉴权",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingAuth),
|
||||||
"url": "/servers/server/settings/locations/access?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/access?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "access",
|
"isActive": secondMenuItem == "access",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Auth != nil && locationConfig.Web.Auth.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Auth != nil && locationConfig.Web.Auth.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "防盗链",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingReferers),
|
||||||
"url": "/servers/server/settings/locations/referers?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/referers?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "referer",
|
"isActive": secondMenuItem == "referer",
|
||||||
"isOn": locationConfig.Web != nil && locationConfig.Web.Referers != nil && locationConfig.Web.Referers.IsPrior,
|
"isOn": locationConfig.Web != nil && locationConfig.Web.Referers != nil && locationConfig.Web.Referers.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "UA名单",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingUserAgents),
|
||||||
"url": "/servers/server/settings/locations/userAgent?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/userAgent?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "userAgent",
|
"isActive": secondMenuItem == "userAgent",
|
||||||
"isOn": locationConfig.Web != nil && locationConfig.Web.UserAgent != nil && locationConfig.Web.UserAgent.IsPrior,
|
"isOn": locationConfig.Web != nil && locationConfig.Web.UserAgent != nil && locationConfig.Web.UserAgent.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "字符编码",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingCharset),
|
||||||
"url": "/servers/server/settings/locations/charset?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/charset?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "charset",
|
"isActive": secondMenuItem == "charset",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Charset != nil && locationConfig.Web.Charset.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Charset != nil && locationConfig.Web.Charset.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "访问日志",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingAccessLog),
|
||||||
"url": "/servers/server/settings/locations/accessLog?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/accessLog?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "accessLog",
|
"isActive": secondMenuItem == "accessLog",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.AccessLogRef != nil && locationConfig.Web.AccessLogRef.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.AccessLogRef != nil && locationConfig.Web.AccessLogRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "统计",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingStat),
|
||||||
"url": "/servers/server/settings/locations/stat?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/stat?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "stat",
|
"isActive": secondMenuItem == "stat",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.StatRef != nil && locationConfig.Web.StatRef.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.StatRef != nil && locationConfig.Web.StatRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "内容压缩",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingCompress),
|
||||||
"url": "/servers/server/settings/locations/compression?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/compression?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "compression",
|
"isActive": secondMenuItem == "compression",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Compression != nil && locationConfig.Web.Compression.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Compression != nil && locationConfig.Web.Compression.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "自定义页面",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingPages),
|
||||||
"url": "/servers/server/settings/locations/pages?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/pages?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "pages",
|
"isActive": secondMenuItem == "pages",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && (len(locationConfig.Web.Pages) > 0 || (locationConfig.Web.Shutdown != nil && locationConfig.Web.Shutdown.IsPrior)),
|
"isOn": locationConfig != nil && locationConfig.Web != nil && (len(locationConfig.Web.Pages) > 0 || (locationConfig.Web.Shutdown != nil && locationConfig.Web.Shutdown.IsPrior)),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTP Header",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingHTTPHeaders),
|
||||||
"url": "/servers/server/settings/locations/headers?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/headers?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "header",
|
"isActive": secondMenuItem == "header",
|
||||||
"isOn": locationConfig != nil && this.hasHTTPHeaders(locationConfig.Web),
|
"isOn": locationConfig != nil && this.hasHTTPHeaders(locationConfig.Web),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Websocket",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingWebsocket),
|
||||||
"url": "/servers/server/settings/locations/websocket?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/websocket?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "websocket",
|
"isActive": secondMenuItem == "websocket",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.WebsocketRef != nil && locationConfig.Web.WebsocketRef.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.WebsocketRef != nil && locationConfig.Web.WebsocketRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "WebP",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingWebP),
|
||||||
"url": "/servers/server/settings/locations/webp?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/webp?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "webp",
|
"isActive": secondMenuItem == "webp",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.WebP != nil && locationConfig.Web.WebP.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.WebP != nil && locationConfig.Web.WebP.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "静态分发",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingRoot),
|
||||||
"url": "/servers/server/settings/locations/web?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/web?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "web",
|
"isActive": secondMenuItem == "web",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Root != nil && locationConfig.Web.Root.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Root != nil && locationConfig.Web.Root.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Fastcgi",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingFastcgi),
|
||||||
"url": "/servers/server/settings/locations/fastcgi?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/fastcgi?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "fastcgi",
|
"isActive": secondMenuItem == "fastcgi",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FastcgiRef != nil && locationConfig.Web.FastcgiRef.IsPrior,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FastcgiRef != nil && locationConfig.Web.FastcgiRef.IsPrior,
|
||||||
})
|
})
|
||||||
|
|
||||||
menuItems = filterMenuItems2(locationConfig, menuItems, serverIdString, locationIdString, secondMenuItem)
|
menuItems = this.filterMenuItems2(locationConfig, menuItems, serverIdString, locationIdString, secondMenuItem, actionPtr)
|
||||||
|
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "-",
|
"name": "-",
|
||||||
@@ -185,14 +188,14 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
|
|||||||
})
|
})
|
||||||
|
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "访客IP地址",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingClientIP),
|
||||||
"url": "/servers/server/settings/locations/remoteAddr?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/remoteAddr?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "remoteAddr",
|
"isActive": secondMenuItem == "remoteAddr",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RemoteAddr != nil && locationConfig.Web.RemoteAddr.IsOn,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RemoteAddr != nil && locationConfig.Web.RemoteAddr.IsOn,
|
||||||
})
|
})
|
||||||
|
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "请求限制",
|
"name": this.Lang(actionPtr, codes.AdminServerMenuSettingRequestLimit),
|
||||||
"url": "/servers/server/settings/locations/requestLimit?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/requestLimit?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "requestLimit",
|
"isActive": secondMenuItem == "requestLimit",
|
||||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RequestLimit != nil && locationConfig.Web.RequestLimit.IsOn,
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RequestLimit != nil && locationConfig.Web.RequestLimit.IsOn,
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ package locationutils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
func filterMenuItems1(locationConfig *serverconfigs.HTTPLocationConfig, menuItems []maps.Map, serverIdString string, locationIdString string, secondMenuItem string) []maps.Map {
|
func (this *LocationHelper) filterMenuItems1(locationConfig *serverconfigs.HTTPLocationConfig, menuItems []maps.Map, serverIdString string, locationIdString string, secondMenuItem string, actionPtr actions.ActionWrapper) []maps.Map {
|
||||||
return menuItems
|
return menuItems
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterMenuItems2(locationConfig *serverconfigs.HTTPLocationConfig, menuItems []maps.Map, serverIdString string, locationIdString string, secondMenuItem string) []maps.Map {
|
func (this *LocationHelper) filterMenuItems2(locationConfig *serverconfigs.HTTPLocationConfig, menuItems []maps.Map, serverIdString string, locationIdString string, secondMenuItem string, actionPtr actions.ActionWrapper) []maps.Map {
|
||||||
return menuItems
|
return menuItems
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user