支持套餐相关操作

This commit is contained in:
刘祥超
2021-11-09 15:36:18 +08:00
parent e814064403
commit e344e5b7e6
12 changed files with 294 additions and 23 deletions

View File

@@ -64,6 +64,36 @@ func (this *IndexAction) RunGet(params struct {
this.Data["user"] = nil
}
// 套餐
var userPlanMap = maps.Map{"id": server.UserPlanId, "dayTo": "", "plan": maps.Map{}}
if server.UserPlanId > 0 {
userPlanResp, err := this.RPC().UserPlanRPC().FindEnabledUserPlan(this.AdminContext(), &pb.FindEnabledUserPlanRequest{UserPlanId: server.UserPlanId})
if err != nil {
this.ErrorPage(err)
return
}
var userPlan = userPlanResp.UserPlan
if userPlan != nil {
planResp, err := this.RPC().PlanRPC().FindEnabledPlan(this.AdminContext(), &pb.FindEnabledPlanRequest{PlanId: userPlan.PlanId})
if err != nil {
this.ErrorPage(err)
return
}
var plan = planResp.Plan
if plan != nil {
userPlanMap = maps.Map{
"id": userPlan.Id,
"dayTo": userPlan.DayTo,
"plan": maps.Map{
"id": plan.Id,
"name": plan.Name,
},
}
}
}
}
this.Data["userPlan"] = userPlanMap
// 集群
clusterId := int64(0)
this.Data["clusterName"] = ""
@@ -123,6 +153,7 @@ func (this *IndexAction) RunPost(params struct {
ClusterId int64
GroupIds []int64
IsOn bool
UserPlanId int64
Must *actions.Must
}) {
@@ -137,6 +168,7 @@ func (this *IndexAction) RunPost(params struct {
this.Fail("请选择部署的集群")
}
// 修改基本信息
_, err := this.RPC().ServerRPC().UpdateServerBasic(this.AdminContext(), &pb.UpdateServerBasicRequest{
ServerId: params.ServerId,
Name: params.Name,
@@ -150,5 +182,17 @@ func (this *IndexAction) RunPost(params struct {
return
}
// 修改套餐
if params.UserPlanId > 0 {
_, err = this.RPC().ServerRPC().UpdateServerUserPlan(this.AdminContext(), &pb.UpdateServerUserPlanRequest{
ServerId: params.ServerId,
UserPlanId: params.UserPlanId,
})
if err != nil {
this.ErrorPage(err)
return
}
}
this.Success()
}

View File

@@ -98,7 +98,7 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
"name": "缓存",
"url": "/servers/server/settings/locations/cache?serverId=" + serverIdString + "&locationId=" + locationIdString,
"isActive": secondMenuItem == "cache",
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Cache != nil && locationConfig.Web.Cache.IsPrior && locationConfig.Web.Cache.IsOn && len(locationConfig.Web.Cache.CacheRefs) > 0,
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Cache != nil && locationConfig.Web.Cache.IsPrior && locationConfig.Web.Cache.IsOn,
})
menuItems = append(menuItems, maps.Map{
"name": "访问控制",