mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-01-06 03:55:48 +08:00
调整界面
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
@@ -13,11 +12,4 @@ func NewHelper() *Helper {
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
action.Data["teaMenu"] = "api"
|
||||
|
||||
selectedTabbar, _ := action.Data["mainTab"]
|
||||
|
||||
tabbar := actionutils.NewTabbar()
|
||||
tabbar.Add("API节点", "", "/api", "", selectedTabbar == "node")
|
||||
actionutils.SetTabbar(action, tabbar)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api/node"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
@@ -11,9 +12,10 @@ func init() {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(settingutils.NewHelper("api")).
|
||||
Prefix("/api").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/node/create", new(node.CreateAction)).
|
||||
GetPost("/node/createPopup", new(node.CreatePopupAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,19 +9,19 @@ import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CreateAction struct {
|
||||
type CreatePopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreateAction) Init() {
|
||||
func (this *CreatePopupAction) Init() {
|
||||
this.Nav("", "node", "create")
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunGet(params struct{}) {
|
||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunPost(params struct {
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Name string
|
||||
Description string
|
||||
ListensJSON []byte
|
||||
@@ -2,7 +2,6 @@ package node
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
@@ -43,22 +42,10 @@ func (this *Helper) BeforeAction(action *actions.ActionObject) (goNext bool) {
|
||||
action.WriteString("node not found")
|
||||
return
|
||||
}
|
||||
node := nodeResp.Node
|
||||
|
||||
// 顶部Tab栏
|
||||
selectedTabbar, _ := action.Data["mainTab"]
|
||||
tabbar := actionutils.NewTabbar()
|
||||
tabbar.Add("节点列表", "", "/api", "", false)
|
||||
tabbar.Add("设置", "", "/api/node/settings?nodeId="+nodeIdString, "setting", selectedTabbar == "setting")
|
||||
{
|
||||
m := tabbar.Add("当前节点:"+node.Name, "", "", "", false)
|
||||
m["right"] = true
|
||||
}
|
||||
actionutils.SetTabbar(action, tabbar)
|
||||
|
||||
// 左侧菜单栏
|
||||
secondMenuItem := action.Data.GetString("secondMenuItem")
|
||||
switch selectedTabbar {
|
||||
switch action.Data.GetString("firstMenuItem") {
|
||||
case "setting":
|
||||
action.Data["leftMenuItems"] = this.createSettingMenu(nodeIdString, secondMenuItem)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
@@ -9,6 +10,7 @@ func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("api")).
|
||||
Prefix("/api/node").
|
||||
|
||||
// 这里不受Helper的约束
|
||||
|
||||
@@ -15,7 +15,7 @@ type SettingsAction struct {
|
||||
}
|
||||
|
||||
func (this *SettingsAction) Init() {
|
||||
this.Nav("", "setting", "")
|
||||
this.Nav("", "setting", "setting")
|
||||
this.SecondMenu("basic")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
@@ -10,6 +11,7 @@ func init() {
|
||||
server.
|
||||
Helper(new(helpers.UserMustAuth)).
|
||||
Helper(new(Helper)).
|
||||
Helper(settingutils.NewHelper("db")).
|
||||
Prefix("/db").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/createPopup", new(CreatePopupAction)).
|
||||
|
||||
15
internal/web/actions/default/settings/backup/index.go
Normal file
15
internal/web/actions/default/settings/backup/index.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package backup
|
||||
|
||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
18
internal/web/actions/default/settings/backup/init.go
Normal file
18
internal/web/actions/default/settings/backup/init.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("backup")).
|
||||
Prefix("/settings/backup").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
@@ -10,6 +11,7 @@ func init() {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(settingutils.NewHelper("console")).
|
||||
Prefix("/settings").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
|
||||
15
internal/web/actions/default/settings/login/index.go
Normal file
15
internal/web/actions/default/settings/login/index.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package login
|
||||
|
||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
18
internal/web/actions/default/settings/login/init.go
Normal file
18
internal/web/actions/default/settings/login/init.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("login")).
|
||||
Prefix("/settings/login").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
15
internal/web/actions/default/settings/profile/index.go
Normal file
15
internal/web/actions/default/settings/profile/index.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package profile
|
||||
|
||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
18
internal/web/actions/default/settings/profile/init.go
Normal file
18
internal/web/actions/default/settings/profile/init.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("profile")).
|
||||
Prefix("/settings/profile").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
15
internal/web/actions/default/settings/security/index.go
Normal file
15
internal/web/actions/default/settings/security/index.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package security
|
||||
|
||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
18
internal/web/actions/default/settings/security/init.go
Normal file
18
internal/web/actions/default/settings/security/init.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("security")).
|
||||
Prefix("/settings/security").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
39
internal/web/actions/default/settings/settingutils/utils.go
Normal file
39
internal/web/actions/default/settings/settingutils/utils.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package settingutils
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
tab string
|
||||
}
|
||||
|
||||
func NewHelper(tab string) *Helper {
|
||||
return &Helper{
|
||||
tab: tab,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) (goNext bool) {
|
||||
goNext = true
|
||||
|
||||
action := actionPtr.Object()
|
||||
|
||||
// 左侧菜单
|
||||
action.Data["teaMenu"] = "settings"
|
||||
|
||||
// 标签栏
|
||||
tabbar := actionutils.NewTabbar()
|
||||
tabbar.Add("管理界面", "", "/settings", "", this.tab == "console")
|
||||
tabbar.Add("安全设置", "", "/settings/security", "", this.tab == "security")
|
||||
tabbar.Add("API节点", "", "/api", "exchange", this.tab == "api")
|
||||
tabbar.Add("日志数据库节点", "", "/db", "database", this.tab == "db")
|
||||
tabbar.Add("备份", "", "/settings/backup", "", this.tab == "backup")
|
||||
tabbar.Add("个人资料", "", "/settings/profile", "", this.tab == "profile")
|
||||
tabbar.Add("登录设置", "", "/settings/login", "", this.tab == "login")
|
||||
tabbar.Add("检查版本更新", "", "/settings/upgrade", "", this.tab == "upgrade")
|
||||
actionutils.SetTabbar(actionPtr, tabbar)
|
||||
|
||||
return
|
||||
}
|
||||
15
internal/web/actions/default/settings/upgrade/index.go
Normal file
15
internal/web/actions/default/settings/upgrade/index.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package upgrade
|
||||
|
||||
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
18
internal/web/actions/default/settings/upgrade/init.go
Normal file
18
internal/web/actions/default/settings/upgrade/init.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package upgrade
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("upgrade")).
|
||||
Prefix("/settings/upgrade").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user