Files
EdgeAdmin/internal/web/actions/default/servers/components/groups/createPopup.go

49 lines
1.0 KiB
Go
Raw Normal View History

2020-10-29 20:53:08 +08:00
package groups
import (
2020-11-10 21:37:48 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
2020-10-29 20:53:08 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type CreatePopupAction struct {
actionutils.ParentAction
}
func (this *CreatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *CreatePopupAction) RunGet(params struct{}) {
this.Show()
}
2020-11-10 21:37:48 +08:00
func (this *CreatePopupAction) RunPost(params struct {
2020-10-29 20:53:08 +08:00
Name string
Must *actions.Must
}) {
params.Must.
Field("name", params.Name).
Require("请输入分组名称")
createResp, err := this.RPC().ServerGroupRPC().CreateServerGroup(this.AdminContext(), &pb.CreateServerGroupRequest{
2020-11-10 21:37:48 +08:00
Name: params.Name,
2020-10-29 20:53:08 +08:00
})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["group"] = maps.Map{
"id": createResp.GroupId,
"name": params.Name,
}
2020-11-10 21:37:48 +08:00
// 创建日志
2020-11-20 15:32:42 +08:00
defer this.CreateLog(oplogs.LevelInfo, "创建代理服务分组 %d", createResp.GroupId)
2020-11-10 21:37:48 +08:00
2020-10-29 20:53:08 +08:00
this.Success()
}