2021-09-22 19:39:38 +08:00
|
|
|
package group
|
2020-10-29 20:53:08 +08:00
|
|
|
|
|
|
|
|
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"
|
2021-09-22 19:39:38 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/groups/group/servergrouputils"
|
2020-10-29 20:53:08 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/iwind/TeaGo/actions"
|
|
|
|
|
"github.com/iwind/TeaGo/maps"
|
|
|
|
|
)
|
|
|
|
|
|
2021-09-22 19:39:38 +08:00
|
|
|
type UpdateAction struct {
|
2020-10-29 20:53:08 +08:00
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-22 19:39:38 +08:00
|
|
|
func (this *UpdateAction) Init() {
|
|
|
|
|
this.Nav("", "", "group.update")
|
2020-10-29 20:53:08 +08:00
|
|
|
}
|
|
|
|
|
|
2021-09-22 19:39:38 +08:00
|
|
|
func (this *UpdateAction) RunGet(params struct {
|
2020-10-29 20:53:08 +08:00
|
|
|
GroupId int64
|
|
|
|
|
}) {
|
2021-09-22 19:39:38 +08:00
|
|
|
group, err := servergrouputils.InitGroup(this.Parent(), params.GroupId, "")
|
2020-10-29 20:53:08 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Data["group"] = maps.Map{
|
|
|
|
|
"id": group.Id,
|
|
|
|
|
"name": group.Name,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Show()
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-22 19:39:38 +08:00
|
|
|
func (this *UpdateAction) RunPost(params struct {
|
2020-10-29 20:53:08 +08:00
|
|
|
GroupId int64
|
|
|
|
|
Name string
|
|
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
}) {
|
2020-11-10 21:37:48 +08:00
|
|
|
// 创建日志
|
2020-11-20 15:32:42 +08:00
|
|
|
defer this.CreateLog(oplogs.LevelInfo, "修改代理服务分组 %d", params.GroupId)
|
2020-11-10 21:37:48 +08:00
|
|
|
|
2020-10-29 20:53:08 +08:00
|
|
|
params.Must.
|
|
|
|
|
Field("name", params.Name).
|
|
|
|
|
Require("请输入分组名称")
|
|
|
|
|
_, err := this.RPC().ServerGroupRPC().UpdateServerGroup(this.AdminContext(), &pb.UpdateServerGroupRequest{
|
2021-05-25 17:48:51 +08:00
|
|
|
ServerGroupId: params.GroupId,
|
|
|
|
|
Name: params.Name,
|
2020-10-29 20:53:08 +08:00
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|