2020-08-21 21:09:42 +08:00
|
|
|
package charset
|
|
|
|
|
|
|
|
|
|
import (
|
2020-11-20 15:32:42 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
2020-08-21 21:09:42 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
2020-09-26 08:07:18 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
2021-01-03 20:25:15 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
2020-09-16 20:29:13 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/iwind/TeaGo/actions"
|
2021-10-07 16:47:14 +08:00
|
|
|
"github.com/iwind/TeaGo/types"
|
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
|
|
|
|
|
}) {
|
2021-10-07 16:47:14 +08:00
|
|
|
// 服务分组设置
|
|
|
|
|
groupResp, err := this.RPC().ServerGroupRPC().FindEnabledServerGroupConfigInfo(this.AdminContext(), &pb.FindEnabledServerGroupConfigInfoRequest{
|
|
|
|
|
ServerId: params.ServerId,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.Data["hasGroupConfig"] = groupResp.HasCharsetConfig
|
|
|
|
|
this.Data["groupSettingURL"] = "/servers/groups/group/settings/charset?groupId=" + types.String(groupResp.ServerGroupId)
|
|
|
|
|
|
2021-01-03 20:25:15 +08:00
|
|
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
2020-09-16 20:29:13 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Data["webId"] = webConfig.Id
|
2020-09-23 18:43:38 +08:00
|
|
|
this.Data["charsetConfig"] = webConfig.Charset
|
2020-09-16 20:29:13 +08:00
|
|
|
|
|
|
|
|
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 {
|
2020-09-23 18:43:38 +08:00
|
|
|
WebId int64
|
|
|
|
|
CharsetJSON []byte
|
2020-09-16 20:29:13 +08:00
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
}) {
|
2020-11-20 15:32:42 +08:00
|
|
|
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的字符集设置", params.WebId)
|
|
|
|
|
|
2020-09-16 20:29:13 +08:00
|
|
|
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCharset(this.AdminContext(), &pb.UpdateHTTPWebCharsetRequest{
|
2020-09-23 18:43:38 +08:00
|
|
|
WebId: params.WebId,
|
|
|
|
|
CharsetJSON: params.CharsetJSON,
|
2020-09-16 20:29:13 +08:00
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|