自定义页面增加是否“启用系统自定义页面”选项

This commit is contained in:
GoEdgeLab
2024-05-03 09:34:58 +08:00
parent 772ec1ac38
commit 89d70ce121
9 changed files with 99 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
package pages
import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/groups/group/servergrouputils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
@@ -33,6 +34,7 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["webId"] = webConfig.Id
this.Data["enableGlobalPages"] = webConfig.EnableGlobalPages
this.Data["pages"] = webConfig.Pages
this.Data["shutdownConfig"] = webConfig.Shutdown
@@ -40,17 +42,27 @@ func (this *IndexAction) RunGet(params struct {
}
func (this *IndexAction) RunPost(params struct {
WebId int64
PagesJSON string
ShutdownJSON string
Must *actions.Must
WebId int64
EnableGlobalPages bool
PagesJSON string
ShutdownJSON string
Must *actions.Must
}) {
// 日志
defer this.CreateLogInfo(codes.ServerPage_LogUpdatePages, params.WebId)
// TODO 检查配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebGlobalPagesEnabled(this.AdminContext(), &pb.UpdateHTTPWebGlobalPagesEnabledRequest{
HttpWebId: params.WebId,
IsEnabled: params.EnableGlobalPages,
})
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
HttpWebId: params.WebId,
PagesJSON: []byte(params.PagesJSON),
})

View File

@@ -25,6 +25,7 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["webId"] = webConfig.Id
this.Data["enableGlobalPages"] = webConfig.EnableGlobalPages
this.Data["pages"] = webConfig.Pages
this.Data["shutdownConfig"] = webConfig.Shutdown
@@ -32,16 +33,26 @@ func (this *IndexAction) RunGet(params struct {
}
func (this *IndexAction) RunPost(params struct {
WebId int64
PagesJSON string
ShutdownJSON string
Must *actions.Must
WebId int64
EnableGlobalPages bool
PagesJSON string
ShutdownJSON string
Must *actions.Must
}) {
defer this.CreateLogInfo(codes.ServerPage_LogUpdatePages, params.WebId)
// TODO 检查配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebGlobalPagesEnabled(this.AdminContext(), &pb.UpdateHTTPWebGlobalPagesEnabledRequest{
HttpWebId: params.WebId,
IsEnabled: params.EnableGlobalPages,
})
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
HttpWebId: params.WebId,
PagesJSON: []byte(params.PagesJSON),
})

View File

@@ -47,6 +47,7 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["webId"] = webConfig.Id
this.Data["enableGlobalPages"] = webConfig.EnableGlobalPages
this.Data["pages"] = webConfig.Pages
this.Data["shutdownConfig"] = webConfig.Shutdown
@@ -54,10 +55,11 @@ func (this *IndexAction) RunGet(params struct {
}
func (this *IndexAction) RunPost(params struct {
WebId int64
PagesJSON []byte
ShutdownJSON []byte
Must *actions.Must
WebId int64
PagesJSON []byte
ShutdownJSON []byte
EnableGlobalPages bool
Must *actions.Must
}) {
// 日志
defer this.CreateLogInfo(codes.ServerPage_LogUpdatePages, params.WebId)
@@ -135,7 +137,16 @@ func (this *IndexAction) RunPost(params struct {
}
}
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebGlobalPagesEnabled(this.AdminContext(), &pb.UpdateHTTPWebGlobalPagesEnabledRequest{
HttpWebId: params.WebId,
IsEnabled: params.EnableGlobalPages,
})
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
HttpWebId: params.WebId,
PagesJSON: params.PagesJSON,
})