// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . package servers import ( "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" ) // UpdateNamePopupAction 修改服务名称 type UpdateNamePopupAction struct { actionutils.ParentAction } func (this *UpdateNamePopupAction) Init() { this.Nav("", "", "") } func (this *UpdateNamePopupAction) RunGet(params struct { ServerId int64 }) { serverResp, err := this.RPC().ServerRPC().FindEnabledUserServerBasic(this.UserContext(), &pb.FindEnabledUserServerBasicRequest{ServerId: params.ServerId}) if err != nil { this.ErrorPage(err) return } var server = serverResp.Server if server == nil { this.NotFound("server", params.ServerId) return } this.Data["server"] = maps.Map{ "id": server.Id, "name": server.Name, } this.Show() } func (this *UpdateNamePopupAction) RunPost(params struct { ServerId int64 Name string Must *actions.Must CSRF *actionutils.CSRF }) { defer this.CreateLogInfo(codes.Server_LogUpdateServerName, params.ServerId) params.Must. Field("name", params.Name). Require("请输入服务名称") _, err := this.RPC().ServerRPC().UpdateServerName(this.UserContext(), &pb.UpdateServerNameRequest{ ServerId: params.ServerId, Name: params.Name, }) if err != nil { this.ErrorPage(err) return } this.Success() }