mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 23:30:26 +08:00
67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
|
|
package waf
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||
|
|
"github.com/iwind/TeaGo/actions"
|
||
|
|
"github.com/iwind/TeaGo/maps"
|
||
|
|
)
|
||
|
|
|
||
|
|
type UpdateGroupPopupAction struct {
|
||
|
|
actionutils.ParentAction
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *UpdateGroupPopupAction) Init() {
|
||
|
|
this.Nav("", "", "")
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *UpdateGroupPopupAction) RunGet(params struct {
|
||
|
|
GroupId int64
|
||
|
|
}) {
|
||
|
|
groupConfig, err := models.SharedHTTPFirewallRuleGroupDAO.FindRuleGroupConfig(this.AdminContext(), params.GroupId)
|
||
|
|
if err != nil {
|
||
|
|
this.ErrorPage(err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if groupConfig == nil {
|
||
|
|
this.NotFound("ruleGroup", params.GroupId)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
this.Data["group"] = maps.Map{
|
||
|
|
"id": groupConfig.Id,
|
||
|
|
"name": groupConfig.Name,
|
||
|
|
"description": groupConfig.Description,
|
||
|
|
"isOn": groupConfig.IsOn,
|
||
|
|
}
|
||
|
|
|
||
|
|
this.Show()
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *UpdateGroupPopupAction) RunPost(params struct {
|
||
|
|
GroupId int64
|
||
|
|
Name string
|
||
|
|
Description string
|
||
|
|
IsOn bool
|
||
|
|
|
||
|
|
Must *actions.Must
|
||
|
|
}) {
|
||
|
|
params.Must.
|
||
|
|
Field("name", params.Name).
|
||
|
|
Require("请输入分组名称")
|
||
|
|
|
||
|
|
_, err := this.RPC().HTTPFirewallRuleGroupRPC().UpdateHTTPFirewallRuleGroup(this.AdminContext(), &pb.UpdateHTTPFirewallRuleGroupRequest{
|
||
|
|
FirewallRuleGroupId: params.GroupId,
|
||
|
|
IsOn: params.IsOn,
|
||
|
|
Name: params.Name,
|
||
|
|
Description: params.Description,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
this.ErrorPage(err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
this.Success()
|
||
|
|
}
|