阶段性提交

This commit is contained in:
GoEdgeLab
2020-08-21 21:09:42 +08:00
parent 8f22f2fda1
commit 2ba46b9162
161 changed files with 3520 additions and 219 deletions

View File

@@ -1,6 +1,7 @@
package nodes
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
@@ -38,11 +39,12 @@ func (this *CreateAction) RunGet(params struct{}) {
}
func (this *CreateAction) RunPost(params struct {
Name string
ClusterId int64
GrantId int64
SshHost string
SshPort int
Name string
IPAddresses string `alias:"ipAddresses"`
ClusterId int64
GrantId int64
SshHost string
SshPort int
Must *actions.Must
}) {
@@ -68,7 +70,7 @@ func (this *CreateAction) RunPost(params struct {
}
// 保存
_, err := this.RPC().NodeRPC().CreateNode(this.AdminContext(), &pb.CreateNodeRequest{
createResp, err := this.RPC().NodeRPC().CreateNode(this.AdminContext(), &pb.CreateNodeRequest{
Name: params.Name,
ClusterId: params.ClusterId,
Login: loginInfo,
@@ -77,6 +79,26 @@ func (this *CreateAction) RunPost(params struct {
this.ErrorPage(err)
return
}
nodeId := createResp.NodeId
// IP地址
ipAddresses := []maps.Map{}
err = json.Unmarshal([]byte(params.IPAddresses), &ipAddresses)
if err != nil {
this.ErrorPage(err)
return
}
for _, address := range ipAddresses {
addressId := address.GetInt64("id")
_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
AddressId: addressId,
NodeId: nodeId,
})
if err != nil {
this.ErrorPage(err)
return
}
}
this.Success()
}

View File

@@ -0,0 +1,104 @@
package grants
import (
"github.com/TeaOSLab/EdgeAdmin/internal/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type UpdatePopupAction struct {
actionutils.ParentAction
}
func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct {
GrantId int64
}) {
this.Data["methods"] = grantutils.AllGrantMethods()
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledGrant(this.AdminContext(), &pb.FindEnabledGrantRequest{GrantId: params.GrantId})
if err != nil {
this.ErrorPage(err)
return
}
if grantResp.Grant == nil {
this.WriteString("找不到要操作的对象")
return
}
grant := grantResp.Grant
this.Data["grant"] = maps.Map{
"id": grant.Id,
"nodeId": grant.NodeId,
"method": grant.Method,
"name": grant.Name,
"username": grant.Username,
"password": grant.Password,
"description": grant.Description,
"privateKey": grant.PrivateKey,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
GrantId int64
NodeId int64
Name string
Method string
Username string
Password string
PrivateKey string
Description string
Must *actions.Must
}) {
params.Must.
Field("name", params.Name).
Require("请输入名称")
switch params.Method {
case "user":
if len(params.Username) == 0 {
this.FailField("username", "请输入SSH登录用户名")
}
case "privateKey":
if len(params.PrivateKey) == 0 {
this.FailField("privateKey", "请输入RSA私钥")
}
default:
this.Fail("请选择正确的认证方式")
}
// 执行修改
_, err := this.RPC().NodeGrantRPC().UpdateNodeGrant(this.AdminContext(), &pb.UpdateNodeGrantRequest{
GrantId: params.GrantId,
Name: params.Name,
Method: params.Method,
Username: params.Username,
Password: params.Password,
PrivateKey: params.PrivateKey,
Description: params.Description,
NodeId: params.NodeId,
})
if err != nil {
this.ErrorPage(err)
return
}
// 返回信息
this.Data["grant"] = maps.Map{
"id": params.GrantId,
"name": params.Name,
"method": params.Method,
"methodName": grantutils.FindGrantMethodName(params.Method),
}
this.Success()
}

View File

@@ -14,7 +14,7 @@ func (this *Helper) BeforeAction(action *actions.ActionObject) {
selectedTabbar, _ := action.Data["mainTab"]
tabbar := actionutils.NewTabbar()
tabbar.Add("节点管理", "", "/nodes", "", selectedTabbar == "node")
tabbar.Add("认证管理", "", "/nodes/grants", "", selectedTabbar == "grant")
tabbar.Add("节点", "", "/nodes", "", selectedTabbar == "node")
tabbar.Add("认证", "", "/nodes/grants", "", selectedTabbar == "grant")
actionutils.SetTabbar(action, tabbar)
}

View File

@@ -46,6 +46,21 @@ func (this *IndexAction) RunGet(params struct{}) {
status.IsActive = time.Now().Unix()-status.UpdatedAt < 120 // 2分钟之内认为活跃
}
// IP
ipAddressesResp, err := this.RPC().NodeIPAddressRPC().FindAllEnabledIPAddressesWithNodeId(this.AdminContext(), &pb.FindAllEnabledIPAddressesWithNodeIdRequest{NodeId: node.Id})
if err != nil {
this.ErrorPage(err)
return
}
ipAddresses := []maps.Map{}
for _, addr := range ipAddressesResp.Addresses {
ipAddresses = append(ipAddresses, maps.Map{
"id": addr.Id,
"name": addr.Name,
"ip": addr.Ip,
})
}
nodeMaps = append(nodeMaps, maps.Map{
"id": node.Id,
"name": node.Name,
@@ -62,6 +77,7 @@ func (this *IndexAction) RunGet(params struct{}) {
"id": node.Cluster.Id,
"name": node.Cluster.Name,
},
"ipAddresses": ipAddresses,
})
}
this.Data["nodes"] = nodeMaps

View File

@@ -2,6 +2,7 @@ package nodes
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
@@ -18,6 +19,10 @@ func init() {
GetPost("/update", new(UpdateAction)).
Get("/node", new(NodeAction)).
// IP地址
GetPost("/ipAddresses/createPopup", new(ipAddresses.CreatePopupAction)).
GetPost("/ipAddresses/updatePopup", new(ipAddresses.UpdatePopupAction)).
// 授权管理
Get("/grants", new(grants.IndexAction)).
GetPost("/grants/create", new(grants.CreateAction)).
@@ -26,6 +31,7 @@ func init() {
Get("/grants/grant", new(grants.GrantAction)).
GetPost("/grants/selectPopup", new(grants.SelectPopupAction)).
GetPost("/grants/createPopup", new(grants.CreatePopupAction)).
GetPost("/grants/updatePopup", new(grants.UpdatePopupAction)).
EndAll()
})
}

View File

@@ -0,0 +1,50 @@
package ipAddresses
import (
"github.com/TeaOSLab/EdgeAdmin/internal/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type CreatePopupAction struct {
actionutils.ParentAction
}
func (this *CreatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *CreatePopupAction) RunGet(params struct{}) {
this.Show()
}
func (this *CreatePopupAction) RunPost(params struct {
IP string `alias:"ip"`
Name string
Must *actions.Must
}) {
// TODO 严格校验IP地址
params.Must.
Field("ip", params.IP).
Require("请输入IP地址")
resp, err := this.RPC().NodeIPAddressRPC().CreateNodeIPAddress(this.AdminContext(), &pb.CreateNodeIPAddressRequest{
NodeId: 0,
Name: params.Name,
Ip: params.IP,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["ipAddress"] = maps.Map{
"name": params.Name,
"ip": params.IP,
"id": resp.AddressId,
}
this.Success()
}

View File

@@ -0,0 +1,71 @@
package ipAddresses
import (
"github.com/TeaOSLab/EdgeAdmin/internal/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type UpdatePopupAction struct {
actionutils.ParentAction
}
func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct {
AddressId int64
}) {
addressResp, err := this.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(this.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{AddressId: params.AddressId})
if err != nil {
this.ErrorPage(err)
return
}
address := addressResp.IpAddress
if address == nil {
this.WriteString("找不到要修改的IP地址")
return
}
this.Data["address"] = maps.Map{
"id": address.Id,
"name": address.Name,
"ip": address.Ip,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
AddressId int64
IP string `alias:"ip"`
Name string
Must *actions.Must
}) {
// TODO 严格校验IP地址
params.Must.
Field("ip", params.IP).
Require("请输入IP地址")
_, err := this.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(this.AdminContext(), &pb.UpdateNodeIPAddressRequest{
AddressId: params.AddressId,
Name: params.Name,
Ip: params.IP,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["ipAddress"] = maps.Map{
"name": params.Name,
"ip": params.IP,
"id": params.AddressId,
}
this.Success()
}

View File

@@ -40,6 +40,22 @@ func (this *NodeAction) RunGet(params struct {
}
}
// IP地址
ipAddressesResp, err := this.RPC().NodeIPAddressRPC().FindAllEnabledIPAddressesWithNodeId(this.AdminContext(), &pb.FindAllEnabledIPAddressesWithNodeIdRequest{NodeId: params.NodeId})
if err != nil {
this.ErrorPage(err)
return
}
ipAddressMaps := []maps.Map{}
for _, addr := range ipAddressesResp.Addresses {
ipAddressMaps = append(ipAddressMaps, maps.Map{
"id": addr.Id,
"name": addr.Name,
"ip": addr.Ip,
})
}
// 登录信息
var loginMap maps.Map = nil
if node.Login != nil {
loginParams := maps.Map{}
@@ -79,10 +95,11 @@ func (this *NodeAction) RunGet(params struct {
}
this.Data["node"] = maps.Map{
"id": node.Id,
"name": node.Name,
"cluster": clusterMap,
"login": loginMap,
"id": node.Id,
"name": node.Name,
"ipAddresses": ipAddressMaps,
"cluster": clusterMap,
"login": loginMap,
}
this.Show()

View File

@@ -41,6 +41,22 @@ func (this *UpdateAction) RunGet(params struct {
}
}
// IP地址
ipAddressesResp, err := this.RPC().NodeIPAddressRPC().FindAllEnabledIPAddressesWithNodeId(this.AdminContext(), &pb.FindAllEnabledIPAddressesWithNodeIdRequest{NodeId: params.NodeId})
if err != nil {
this.ErrorPage(err)
return
}
ipAddressMaps := []maps.Map{}
for _, addr := range ipAddressesResp.Addresses {
ipAddressMaps = append(ipAddressMaps, maps.Map{
"id": addr.Id,
"name": addr.Name,
"ip": addr.Ip,
})
}
// 登录信息
var loginMap maps.Map = nil
if node.Login != nil {
loginParams := maps.Map{}
@@ -80,10 +96,11 @@ func (this *UpdateAction) RunGet(params struct {
}
this.Data["node"] = maps.Map{
"id": node.Id,
"name": node.Name,
"cluster": clusterMap,
"login": loginMap,
"id": node.Id,
"name": node.Name,
"ipAddresses": ipAddressMaps,
"cluster": clusterMap,
"login": loginMap,
}
// 所有集群
@@ -108,13 +125,14 @@ func (this *UpdateAction) RunGet(params struct {
}
func (this *UpdateAction) RunPost(params struct {
LoginId int64
NodeId int64
Name string
ClusterId int64
GrantId int64
SshHost string
SshPort int
LoginId int64
NodeId int64
Name string
IPAddresses string `alias:"ipAddresses"`
ClusterId int64
GrantId int64
SshHost string
SshPort int
Must *actions.Must
}) {
@@ -155,5 +173,31 @@ func (this *UpdateAction) RunPost(params struct {
return
}
// 禁用老的IP地址
_, err = this.RPC().NodeIPAddressRPC().DisableAllIPAddressesWithNodeId(this.AdminContext(), &pb.DisableAllIPAddressesWithNodeIdRequest{NodeId: params.NodeId})
if err != nil {
this.ErrorPage(err)
return
}
// 添加新的IP地址
ipAddresses := []maps.Map{}
err = json.Unmarshal([]byte(params.IPAddresses), &ipAddresses)
if err != nil {
this.ErrorPage(err)
return
}
for _, address := range ipAddresses {
addressId := address.GetInt64("id")
_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
AddressId: addressId,
NodeId: params.NodeId,
})
if err != nil {
this.ErrorPage(err)
return
}
}
this.Success()
}

View File

@@ -0,0 +1,24 @@
package components
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
)
type Helper struct {
}
func NewHelper() *Helper {
return &Helper{}
}
func (this *Helper) BeforeAction(action *actions.ActionObject) {
action.Data["teaMenu"] = "servers"
selectedTabbar, _ := action.Data["mainTab"]
tabbar := actionutils.NewTabbar()
tabbar.Add("服务", "", "/servers", "", selectedTabbar == "server")
tabbar.Add("组件", "", "/servers/components", "", selectedTabbar == "component")
actionutils.SetTabbar(action, tabbar)
}

View File

@@ -0,0 +1,18 @@
package components
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "component", "index")
}
func (this *IndexAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,17 @@
package components
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(NewHelper()).
Prefix("/servers/components").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -18,6 +18,7 @@ func (this *Helper) BeforeAction(action *actions.ActionObject) {
selectedTabbar, _ := action.Data["mainTab"]
tabbar := actionutils.NewTabbar()
tabbar.Add("服务管理", "", "/servers", "", selectedTabbar == "server")
tabbar.Add("服务", "", "/servers", "", selectedTabbar == "server")
tabbar.Add("组件", "", "/servers/components", "", selectedTabbar == "component")
actionutils.SetTabbar(action, tabbar)
}

View File

@@ -8,6 +8,7 @@ type IndexAction struct {
func (this *IndexAction) Init() {
this.Nav("", "board", "")
this.SecondMenu("index")
}
func (this *IndexAction) RunGet(params struct{}) {

View File

@@ -8,6 +8,7 @@ type IndexAction struct {
func (this *IndexAction) Init() {
this.Nav("", "delete", "")
this.SecondMenu("index")
}
func (this *IndexAction) RunGet(params struct{}) {

View File

@@ -8,6 +8,7 @@ type IndexAction struct {
func (this *IndexAction) Init() {
this.Nav("", "log", "")
this.SecondMenu("index")
}
func (this *IndexAction) RunGet(params struct{}) {

View File

@@ -0,0 +1,22 @@
package access
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("access")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package access
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/access").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package accessLog
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("accessLog")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package accessLog
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/accessLog").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("cache")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/cache").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package charset
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("charset")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package charset
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/charset").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package gzip
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("gzip")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package gzip
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/gzip").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package headers
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("header")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package headers
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/headers").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -1,4 +1,4 @@
package server
package http
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
@@ -16,5 +16,7 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -1,4 +1,4 @@
package server
package http
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
@@ -11,7 +11,7 @@ func init() {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/http").
Prefix("/servers/server/settings/http").
Get("", new(IndexAction)).
EndAll()
})

View File

@@ -0,0 +1,20 @@
package https
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("https")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
this.Show()
}

View File

@@ -0,0 +1,18 @@
package https
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/https").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package locations
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("locations")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package locations
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/locations").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package pages
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("pages")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package pages
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/pages").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package reverseProxy
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("reverseProxy")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package reverseProxy
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/reverseProxy").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package stat
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("stat")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package stat
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/stat").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package tcp
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("tcp")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package tcp
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/tcp").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package udp
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("udp")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package udp
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/udp").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package unix
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("unix")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package unix
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/unix").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package waf
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("waf")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package waf
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/waf").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -0,0 +1,22 @@
package web
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("web")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
this.Show()
}

View File

@@ -0,0 +1,18 @@
package web
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/web").
Get("", new(IndexAction)).
EndAll()
})
}

View File

@@ -8,6 +8,7 @@ type IndexAction struct {
func (this *IndexAction) Init() {
this.Nav("", "stat", "")
this.SecondMenu("index")
}
func (this *IndexAction) RunGet(params struct{}) {

View File

@@ -83,18 +83,52 @@ func (this *ServerHelper) createLeftMenu(action *actions.ActionObject) {
// 左侧操作子菜单
switch types.String(mainTab) {
case "board":
// TODO
action.Data["leftMenuItems"] = this.createBoardMenu(types.String(secondMenuItem), serverIdString, serverConfig)
case "log":
// TODO
action.Data["leftMenuItems"] = this.createLogMenu(types.String(secondMenuItem), serverIdString, serverConfig)
case "stat":
// TODO
action.Data["leftMenuItems"] = this.createStatMenu(types.String(secondMenuItem), serverIdString, serverConfig)
case "setting":
action.Data["leftMenuItems"] = this.createSettingsMenu(types.String(secondMenuItem), serverIdString, serverConfig)
case "delete":
// TODO
action.Data["leftMenuItems"] = this.createDeleteMenu(types.String(secondMenuItem), serverIdString, serverConfig)
}
}
// 看板菜单
func (this *ServerHelper) createBoardMenu(secondMenuItem string, serverIdString string, serverConfig *serverconfigs.ServerConfig) []maps.Map {
menuItems := []maps.Map{}
menuItems = append(menuItems, maps.Map{
"name": "看板",
"url": "/servers/server/board?serverId=" + serverIdString,
"isActive": secondMenuItem == "index",
})
return menuItems
}
// 日志菜单
func (this *ServerHelper) createLogMenu(secondMenuItem string, serverIdString string, serverConfig *serverconfigs.ServerConfig) []maps.Map {
menuItems := []maps.Map{}
menuItems = append(menuItems, maps.Map{
"name": "实时",
"url": "/servers/server/log?serverId=" + serverIdString,
"isActive": secondMenuItem == "index",
})
return menuItems
}
// 统计菜单
func (this *ServerHelper) createStatMenu(secondMenuItem string, serverIdString string, serverConfig *serverconfigs.ServerConfig) []maps.Map {
menuItems := []maps.Map{}
menuItems = append(menuItems, maps.Map{
"name": "统计",
"url": "/servers/server/stat?serverId=" + serverIdString,
"isActive": secondMenuItem == "index",
})
return menuItems
}
// 设置菜单
func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdString string, serverConfig *serverconfigs.ServerConfig) (items []maps.Map) {
menuItems := []maps.Map{
{
@@ -108,105 +142,122 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
if serverConfig.IsHTTP() {
menuItems = append(menuItems, maps.Map{
"name": "HTTP",
"url": "/servers/server/http?serverId=" + serverIdString,
"url": "/servers/server/settings/http?serverId=" + serverIdString,
"isActive": secondMenuItem == "http",
})
menuItems = append(menuItems, maps.Map{
"name": "HTTPS",
"url": "/servers/server/https?serverId=" + serverIdString,
"url": "/servers/server/settings/https?serverId=" + serverIdString,
"isActive": secondMenuItem == "https",
})
menuItems = append(menuItems, maps.Map{
"name": "Web设置",
"url": "/servers/server/web?serverId=" + serverIdString,
"url": "/servers/server/settings/web?serverId=" + serverIdString,
"isActive": secondMenuItem == "web",
})
menuItems = append(menuItems, maps.Map{
"name": "字符集",
"url": "/servers/server/charset?serverId=" + serverIdString,
"isActive": secondMenuItem == "charset",
})
menuItems = append(menuItems, maps.Map{
"name": "访问日志",
"url": "/servers/server/accessLog?serverId=" + serverIdString,
"isActive": secondMenuItem == "accessLog",
})
menuItems = append(menuItems, maps.Map{
"name": "统计",
"url": "/servers/server/stat?serverId=" + serverIdString,
"isActive": secondMenuItem == "stat",
})
menuItems = append(menuItems, maps.Map{
"name": "Gzip压缩",
"url": "/servers/server/gzip?serverId=" + serverIdString,
"isActive": secondMenuItem == "gzip",
})
menuItems = append(menuItems, maps.Map{
"name": "特殊页面",
"url": "/servers/server/pages?serverId=" + serverIdString,
"isActive": secondMenuItem == "pages",
})
menuItems = append(menuItems, maps.Map{
"name": "HTTP Header",
"url": "/servers/server/headers?serverId=" + serverIdString,
"isActive": secondMenuItem == "header",
})
menuItems = append(menuItems, maps.Map{
"name": "反向代理",
"url": "/servers/server/reverseProxy?serverId=" + serverIdString,
"url": "/servers/server/settings/reverseProxy?serverId=" + serverIdString,
"isActive": secondMenuItem == "reverseProxy",
})
menuItems = append(menuItems, maps.Map{
"name": "路径规则",
"url": "/servers/server/locations?serverId=" + serverIdString,
"url": "/servers/server/settings/locations?serverId=" + serverIdString,
"isActive": secondMenuItem == "locations",
})
menuItems = append(menuItems, maps.Map{
"name": "访问控制",
"url": "/servers/server/access?serverId=" + serverIdString,
"url": "/servers/server/settings/access?serverId=" + serverIdString,
"isActive": secondMenuItem == "access",
})
menuItems = append(menuItems, maps.Map{
"name": "WAF",
"url": "/servers/server/waf?serverId=" + serverIdString,
"url": "/servers/server/settings/waf?serverId=" + serverIdString,
"isActive": secondMenuItem == "waf",
})
menuItems = append(menuItems, maps.Map{
"name": "缓存",
"url": "/servers/server/cache?serverId=" + serverIdString,
"url": "/servers/server/settings/cache?serverId=" + serverIdString,
"isActive": secondMenuItem == "cache",
})
menuItems = append(menuItems, maps.Map{
"name": "-",
"url": "",
"isActive": false,
})
menuItems = append(menuItems, maps.Map{
"name": "字符集",
"url": "/servers/server/settings/charset?serverId=" + serverIdString,
"isActive": secondMenuItem == "charset",
})
menuItems = append(menuItems, maps.Map{
"name": "访问日志",
"url": "/servers/server/settings/accessLog?serverId=" + serverIdString,
"isActive": secondMenuItem == "accessLog",
})
menuItems = append(menuItems, maps.Map{
"name": "统计",
"url": "/servers/server/settings/stat?serverId=" + serverIdString,
"isActive": secondMenuItem == "stat",
})
menuItems = append(menuItems, maps.Map{
"name": "Gzip压缩",
"url": "/servers/server/settings/gzip?serverId=" + serverIdString,
"isActive": secondMenuItem == "gzip",
})
menuItems = append(menuItems, maps.Map{
"name": "特殊页面",
"url": "/servers/server/settings/pages?serverId=" + serverIdString,
"isActive": secondMenuItem == "pages",
})
menuItems = append(menuItems, maps.Map{
"name": "HTTP Header",
"url": "/servers/server/settings/headers?serverId=" + serverIdString,
"isActive": secondMenuItem == "header",
})
} else if serverConfig.IsTCP() {
menuItems = append(menuItems, maps.Map{
"name": "TCP",
"url": "/servers/server/tcp?serverId=" + serverIdString,
"url": "/servers/server/settings/tcp?serverId=" + serverIdString,
"isActive": secondMenuItem == "tcp",
})
} else if serverConfig.IsUnix() {
menuItems = append(menuItems, maps.Map{
"name": "Unix",
"url": "/servers/server/unix?serverId=" + serverIdString,
"url": "/servers/server/settings/unix?serverId=" + serverIdString,
"isActive": secondMenuItem == "unix",
})
} else if serverConfig.IsUDP() {
menuItems = append(menuItems, maps.Map{
"name": "UDP",
"url": "/servers/server/udp?serverId=" + serverIdString,
"url": "/servers/server/settings/udp?serverId=" + serverIdString,
"isActive": secondMenuItem == "udp",
})
}
return menuItems
}
// 删除菜单
func (this *ServerHelper) createDeleteMenu(secondMenuItem string, serverIdString string, serverConfig *serverconfigs.ServerConfig) []maps.Map {
menuItems := []maps.Map{}
menuItems = append(menuItems, maps.Map{
"name": "删除",
"url": "/servers/server/delete?serverId=" + serverIdString,
"isActive": secondMenuItem == "index",
})
return menuItems
}