Files
EdgeAdmin/internal/web/actions/default/clusters/regions/createPopup.go

54 lines
1.1 KiB
Go
Raw Normal View History

2020-12-10 15:02:55 +08:00
package regions
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
2023-06-30 18:08:30 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
2020-12-10 15:02:55 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
2020-12-10 16:11:41 +08:00
"github.com/iwind/TeaGo/maps"
2020-12-10 15:02:55 +08:00
)
type CreatePopupAction struct {
actionutils.ParentAction
}
func (this *CreatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *CreatePopupAction) RunGet(params struct{}) {
this.Show()
}
func (this *CreatePopupAction) RunPost(params struct {
2020-12-10 22:21:26 +08:00
Name string
Description string
2020-12-10 15:02:55 +08:00
Must *actions.Must
CSRF *actionutils.CSRF
}) {
params.Must.
Field("name", params.Name).
Require("请输入区域名称")
2020-12-10 22:21:26 +08:00
createResp, err := this.RPC().NodeRegionRPC().CreateNodeRegion(this.AdminContext(), &pb.CreateNodeRegionRequest{
Name: params.Name,
Description: params.Description,
})
2020-12-10 15:02:55 +08:00
if err != nil {
this.ErrorPage(err)
return
}
2020-12-10 16:11:41 +08:00
this.Data["region"] = maps.Map{
2020-12-10 22:21:26 +08:00
"id": createResp.NodeRegionId,
"name": params.Name,
"description": params.Description,
2020-12-10 16:11:41 +08:00
}
2020-12-10 15:02:55 +08:00
// 日志
2023-06-30 18:08:30 +08:00
defer this.CreateLogInfo(codes.NodeRegion_LogCreateNodeRegion, createResp.NodeRegionId)
2020-12-10 15:02:55 +08:00
this.Success()
}