mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
部分中文转换为多语言代号
This commit is contained in:
@@ -317,7 +317,7 @@ func (this *CreateNodeAction) RunPost(params struct {
|
||||
"id": grantResp.NodeGrant.Id,
|
||||
"name": grantResp.NodeGrant.Name,
|
||||
"method": grantResp.NodeGrant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||
"username": grantResp.NodeGrant.Username,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ func (this *DetailAction) RunGet(params struct {
|
||||
"id": grantResp.NodeGrant.Id,
|
||||
"name": grantResp.NodeGrant.Name,
|
||||
"method": grantResp.NodeGrant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||
"username": grantResp.NodeGrant.Username,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (this *LogsAction) RunGet(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
||||
this.Data["tags"] = nodelogutils.FindNodeCommonTags(this.LangCode())
|
||||
|
||||
this.Data["nodeId"] = params.NodeId
|
||||
this.Data["dayFrom"] = params.DayFrom
|
||||
|
||||
@@ -59,7 +59,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"id": grantResp.NodeGrant.Id,
|
||||
"name": grantResp.NodeGrant.Name,
|
||||
"method": grantResp.NodeGrant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||
"username": grantResp.NodeGrant.Username,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"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,
|
||||
"name": grantResp.NodeGrant.Name,
|
||||
"method": grantResp.NodeGrant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method, this.LangCode()),
|
||||
}
|
||||
}
|
||||
this.Data["grant"] = grantMap
|
||||
|
||||
@@ -18,7 +18,7 @@ func (this *CreateAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunGet(params struct{}) {
|
||||
this.Data["methods"] = grantutils.AllGrantMethods()
|
||||
this.Data["methods"] = grantutils.AllGrantMethods(this.LangCode())
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ func (this *CreatePopupAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
||||
this.Data["methods"] = grantutils.AllGrantMethods()
|
||||
this.Data["methods"] = grantutils.AllGrantMethods(this.LangCode())
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
"id": createResp.NodeGrantId,
|
||||
"name": params.Name,
|
||||
"method": params.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(params.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(params.Method, this.LangCode()),
|
||||
"username": params.Username,
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func (this *GrantAction) RunGet(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"method": grant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
"username": grant.Username,
|
||||
"password": strings.Repeat("*", len(grant.Password)),
|
||||
"privateKey": grant.PrivateKey,
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// 所有的认证类型
|
||||
func AllGrantMethods() []maps.Map {
|
||||
// AllGrantMethods 所有的认证类型
|
||||
func AllGrantMethods(langCode langs.LangCode) []maps.Map {
|
||||
return []maps.Map{
|
||||
{
|
||||
"name": "用户名+密码",
|
||||
"name": langs.Message(langCode, codes.AdminNodeGrantMethodUserPassword),
|
||||
"value": "user",
|
||||
},
|
||||
{
|
||||
"name": "私钥",
|
||||
"name": langs.Message(langCode, codes.AdminNodeGrantMethodPrivateKey),
|
||||
"value": "privateKey",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 获得对应的认证类型名称
|
||||
func FindGrantMethodName(method string) string {
|
||||
for _, m := range AllGrantMethods() {
|
||||
// FindGrantMethodName 获得对应的认证类型名称
|
||||
func FindGrantMethodName(method string, langCode langs.LangCode) string {
|
||||
for _, m := range AllGrantMethods(langCode) {
|
||||
if m.GetString("value") == method {
|
||||
return m.GetString("name")
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"name": grant.Name,
|
||||
"method": maps.Map{
|
||||
"type": grant.Method,
|
||||
"name": grantutils.FindGrantMethodName(grant.Method),
|
||||
"name": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
},
|
||||
"username": grant.Username,
|
||||
"countClusters": countClusters,
|
||||
|
||||
@@ -33,7 +33,7 @@ func (this *SelectPopupAction) RunGet(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"method": grant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
"username": grant.Username,
|
||||
"description": grant.Description,
|
||||
})
|
||||
@@ -55,7 +55,7 @@ func (this *SelectPopupAction) RunGet(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"method": grant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
"username": grant.Username,
|
||||
"description": grant.Description,
|
||||
})
|
||||
@@ -92,7 +92,7 @@ func (this *SelectPopupAction) RunPost(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"method": grant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
}
|
||||
|
||||
this.Success()
|
||||
|
||||
@@ -37,7 +37,7 @@ func (this *TestAction) RunGet(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"method": grant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
"username": grant.Username,
|
||||
"password": strings.Repeat("*", len(grant.Password)),
|
||||
"privateKey": grant.PrivateKey,
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *UpdateAction) Init() {
|
||||
func (this *UpdateAction) RunGet(params struct {
|
||||
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})
|
||||
if err != nil {
|
||||
@@ -40,7 +40,7 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
"id": grant.Id,
|
||||
"name": grant.Name,
|
||||
"method": grant.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(grant.Method, this.LangCode()),
|
||||
"username": grant.Username,
|
||||
"password": grant.Password,
|
||||
"privateKey": grant.PrivateKey,
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *UpdatePopupAction) Init() {
|
||||
func (this *UpdatePopupAction) RunGet(params struct {
|
||||
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})
|
||||
if err != nil {
|
||||
@@ -123,7 +123,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
"id": params.GrantId,
|
||||
"name": params.Name,
|
||||
"method": params.Method,
|
||||
"methodName": grantutils.FindGrantMethodName(params.Method),
|
||||
"methodName": grantutils.FindGrantMethodName(params.Method, this.LangCode()),
|
||||
"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{
|
||||
|
||||
Reference in New Issue
Block a user