mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 04:10:26 +08:00
40 lines
935 B
Go
40 lines
935 B
Go
|
|
package conds
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils"
|
||
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||
|
|
"github.com/iwind/TeaGo/actions"
|
||
|
|
)
|
||
|
|
|
||
|
|
type AddCondPopupAction struct {
|
||
|
|
actionutils.ParentAction
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *AddCondPopupAction) Init() {
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *AddCondPopupAction) RunGet(params struct{}) {
|
||
|
|
this.Data["components"] = condutils.ReadAllAvailableCondTypes()
|
||
|
|
|
||
|
|
this.Show()
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *AddCondPopupAction) RunPost(params struct {
|
||
|
|
CondType string
|
||
|
|
CondJSON []byte
|
||
|
|
|
||
|
|
Must *actions.Must
|
||
|
|
}) {
|
||
|
|
condConfig := &shared.HTTPRequestCond{}
|
||
|
|
err := json.Unmarshal(params.CondJSON, condConfig)
|
||
|
|
if err != nil {
|
||
|
|
this.Fail("解析条件设置时发生了错误:" + err.Error())
|
||
|
|
}
|
||
|
|
condConfig.Type = params.CondType
|
||
|
|
|
||
|
|
this.Data["cond"] = condConfig
|
||
|
|
this.Success()
|
||
|
|
}
|