2020-08-21 21:09:42 +08:00
|
|
|
package stat
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"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 14:48:35 +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("stat")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.HasStatConfig
|
|
|
|
|
this.Data["groupSettingURL"] = "/servers/groups/group/settings/stat?groupId=" + types.String(groupResp.ServerGroupId)
|
|
|
|
|
|
2021-01-03 20:25:15 +08:00
|
|
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
2020-09-20 14:48:35 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Data["webId"] = webConfig.Id
|
2020-09-20 16:28:16 +08:00
|
|
|
this.Data["statConfig"] = webConfig.StatRef
|
2020-08-21 21:09:42 +08:00
|
|
|
|
|
|
|
|
this.Show()
|
|
|
|
|
}
|
2020-09-20 14:48:35 +08:00
|
|
|
|
|
|
|
|
func (this *IndexAction) RunPost(params struct {
|
|
|
|
|
WebId int64
|
|
|
|
|
StatJSON []byte
|
|
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
}) {
|
2020-11-20 15:32:42 +08:00
|
|
|
defer this.CreateLogInfo("修改Web %d 的统计设置", params.WebId)
|
|
|
|
|
|
2020-09-20 14:48:35 +08:00
|
|
|
// TODO 校验配置
|
|
|
|
|
|
2020-09-21 19:51:50 +08:00
|
|
|
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.AdminContext(), &pb.UpdateHTTPWebStatRequest{
|
2021-11-24 11:58:01 +08:00
|
|
|
HttpWebId: params.WebId,
|
|
|
|
|
StatJSON: params.StatJSON,
|
2020-09-20 14:48:35 +08:00
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|