主分支代码
This commit is contained in:
@@ -87,8 +87,13 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Field("type", params.Type).
|
||||
Require("请选择存储类型")
|
||||
|
||||
baseType, writeTargets := serverconfigs.ParseStorageTypeAndWriteTargets(params.Type)
|
||||
if writeTargets == nil {
|
||||
writeTargets = &serverconfigs.AccessLogWriteTargets{File: true, MySQL: true}
|
||||
}
|
||||
|
||||
var options any = nil
|
||||
switch params.Type {
|
||||
switch baseType {
|
||||
case serverconfigs.AccessLogStorageTypeFile:
|
||||
params.Must.
|
||||
Field("filePath", params.FilePath).
|
||||
@@ -170,14 +175,21 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
writeTargetsMap := map[string]bool{
|
||||
"file": writeTargets.File,
|
||||
"mysql": writeTargets.MySQL,
|
||||
"clickhouse": writeTargets.ClickHouse,
|
||||
}
|
||||
writeTargetsJSON, _ := json.Marshal(writeTargetsMap)
|
||||
createResp, err := this.RPC().HTTPAccessLogPolicyRPC().CreateHTTPAccessLogPolicy(this.AdminContext(), &pb.CreateHTTPAccessLogPolicyRequest{
|
||||
Name: params.Name,
|
||||
Type: params.Type,
|
||||
Type: baseType,
|
||||
OptionsJSON: optionsJSON,
|
||||
CondsJSON: nil, // TODO
|
||||
IsPublic: params.IsPublic,
|
||||
FirewallOnly: params.FirewallOnly,
|
||||
DisableDefaultDB: params.DisableDefaultDB,
|
||||
WriteTargetsJSON: writeTargetsJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -46,11 +46,16 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
writeTargets := serverconfigs.ParseWriteTargetsFromPolicy(policy.WriteTargetsJSON, policy.Type, policy.DisableDefaultDB)
|
||||
typeDisplay := serverconfigs.ComposeStorageTypeDisplay(policy.Type, writeTargets)
|
||||
if typeDisplay == "" {
|
||||
typeDisplay = policy.Type
|
||||
}
|
||||
policyMaps = append(policyMaps, maps.Map{
|
||||
"id": policy.Id,
|
||||
"name": policy.Name,
|
||||
"type": policy.Type,
|
||||
"typeName": serverconfigs.FindAccessLogStorageTypeName(policy.Type),
|
||||
"typeName": serverconfigs.FindAccessLogStorageTypeName(typeDisplay),
|
||||
"isOn": policy.IsOn,
|
||||
"isPublic": policy.IsPublic,
|
||||
"firewallOnly": policy.FirewallOnly,
|
||||
|
||||
@@ -36,11 +36,18 @@ func InitPolicy(parent *actionutils.ParentAction, policyId int64) error {
|
||||
}
|
||||
}
|
||||
|
||||
writeTargets := serverconfigs.ParseWriteTargetsFromPolicy(policy.WriteTargetsJSON, policy.Type, policy.DisableDefaultDB)
|
||||
typeDisplay := serverconfigs.ComposeStorageTypeDisplay(policy.Type, writeTargets)
|
||||
if typeDisplay == "" {
|
||||
typeDisplay = policy.Type
|
||||
}
|
||||
|
||||
parent.Data["policy"] = maps.Map{
|
||||
"id": policy.Id,
|
||||
"name": policy.Name,
|
||||
"type": policy.Type,
|
||||
"typeName": serverconfigs.FindAccessLogStorageTypeName(policy.Type),
|
||||
"typeDisplay": typeDisplay,
|
||||
"typeName": serverconfigs.FindAccessLogStorageTypeName(typeDisplay),
|
||||
"isOn": policy.IsOn,
|
||||
"isPublic": policy.IsPublic,
|
||||
"firewallOnly": policy.FirewallOnly,
|
||||
|
||||
@@ -39,6 +39,7 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
func (this *UpdateAction) RunPost(params struct {
|
||||
PolicyId int64
|
||||
Name string
|
||||
Type string // 存储类型(含组合:file / file_mysql / file_clickhouse / file_mysql_clickhouse / es / tcp / syslog / command)
|
||||
|
||||
// file
|
||||
FilePath string
|
||||
@@ -101,10 +102,17 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入日志策略的名称")
|
||||
Require("请输入日志策略的名称").
|
||||
Field("type", params.Type).
|
||||
Require("请选择存储类型")
|
||||
|
||||
baseType, writeTargets := serverconfigs.ParseStorageTypeAndWriteTargets(params.Type)
|
||||
if writeTargets == nil {
|
||||
writeTargets = &serverconfigs.AccessLogWriteTargets{File: true, MySQL: true}
|
||||
}
|
||||
|
||||
var options interface{} = nil
|
||||
switch policy.Type {
|
||||
switch baseType {
|
||||
case serverconfigs.AccessLogStorageTypeFile:
|
||||
params.Must.
|
||||
Field("filePath", params.FilePath).
|
||||
@@ -187,15 +195,23 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
writeTargetsMap := map[string]bool{
|
||||
"file": writeTargets.File,
|
||||
"mysql": writeTargets.MySQL,
|
||||
"clickhouse": writeTargets.ClickHouse,
|
||||
}
|
||||
writeTargetsJSON, _ := json.Marshal(writeTargetsMap)
|
||||
_, err = this.RPC().HTTPAccessLogPolicyRPC().UpdateHTTPAccessLogPolicy(this.AdminContext(), &pb.UpdateHTTPAccessLogPolicyRequest{
|
||||
HttpAccessLogPolicyId: params.PolicyId,
|
||||
Name: params.Name,
|
||||
Type: baseType,
|
||||
OptionsJSON: optionsJSON,
|
||||
CondsJSON: nil, // TODO
|
||||
IsOn: params.IsOn,
|
||||
IsPublic: params.IsPublic,
|
||||
FirewallOnly: params.FirewallOnly,
|
||||
DisableDefaultDB: params.DisableDefaultDB,
|
||||
WriteTargetsJSON: writeTargetsJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
Reference in New Issue
Block a user