Files
EdgeAdmin/internal/web/actions/default/servers/server/settings/charset/index.go

55 lines
1.2 KiB
Go
Raw Normal View History

2020-08-21 21:09:42 +08:00
package charset
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
2020-09-21 19:51:50 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
2020-09-16 20:29:13 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/configutils"
"github.com/iwind/TeaGo/actions"
2020-08-21 21:09:42 +08:00
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("charset")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
2020-09-21 19:51:50 +08:00
webConfig, err := webutils.FindWebConfigWithServerId(this.Parent(), params.ServerId)
2020-09-16 20:29:13 +08:00
if err != nil {
this.ErrorPage(err)
return
}
this.Data["webId"] = webConfig.Id
this.Data["charset"] = webConfig.Charset
this.Data["usualCharsets"] = configutils.UsualCharsets
this.Data["allCharsets"] = configutils.AllCharsets
2020-08-21 21:09:42 +08:00
this.Show()
}
2020-09-16 20:29:13 +08:00
func (this *IndexAction) RunPost(params struct {
WebId int64
Charset string
Must *actions.Must
}) {
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCharset(this.AdminContext(), &pb.UpdateHTTPWebCharsetRequest{
WebId: params.WebId,
Charset: params.Charset,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}