2020-08-21 21:09:42 +08:00
|
|
|
package accessLog
|
|
|
|
|
|
|
|
|
|
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"
|
2021-01-03 20:25:15 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
2020-09-20 11:56:49 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
|
|
|
|
"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("accessLog")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *IndexAction) RunGet(params struct {
|
|
|
|
|
ServerId int64
|
|
|
|
|
}) {
|
2020-09-20 11:56:49 +08:00
|
|
|
// 获取配置
|
2021-01-03 20:25:15 +08:00
|
|
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
2020-09-20 11:56:49 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.Data["webId"] = webConfig.Id
|
2020-09-20 16:28:16 +08:00
|
|
|
this.Data["accessLogConfig"] = webConfig.AccessLogRef
|
2020-09-20 11:56:49 +08:00
|
|
|
|
|
|
|
|
// 通用变量
|
|
|
|
|
this.Data["fields"] = serverconfigs.HTTPAccessLogFields
|
|
|
|
|
this.Data["defaultFieldCodes"] = serverconfigs.HTTPAccessLogDefaultFieldsCodes
|
2020-08-21 21:09:42 +08:00
|
|
|
|
|
|
|
|
this.Show()
|
|
|
|
|
}
|
2020-09-20 11:56:49 +08:00
|
|
|
|
|
|
|
|
func (this *IndexAction) RunPost(params struct {
|
|
|
|
|
WebId int64
|
|
|
|
|
AccessLogJSON []byte
|
|
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
}) {
|
2020-11-20 15:32:42 +08:00
|
|
|
// 日志
|
|
|
|
|
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的访问日志设置", params.WebId)
|
|
|
|
|
|
2020-09-20 11:56:49 +08:00
|
|
|
// TODO 检查参数
|
|
|
|
|
|
2020-09-21 19:51:50 +08:00
|
|
|
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{
|
2020-09-20 11:56:49 +08:00
|
|
|
WebId: params.WebId,
|
|
|
|
|
AccessLogJSON: params.AccessLogJSON,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|