服务没有设置所属用户时可以设置一个用户

This commit is contained in:
GoEdgeLab
2022-12-21 16:13:39 +08:00
parent ccf69d4728
commit 0d92e9fb09
3 changed files with 34 additions and 7 deletions

View File

@@ -121,6 +121,7 @@ func (this *IndexAction) RunGet(params struct {
// RunPost 保存
func (this *IndexAction) RunPost(params struct {
ServerId int64
UserId int64
Name string
Description string
ClusterId int64
@@ -157,16 +158,28 @@ 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 params.UserId > 0 {
_, err = this.RPC().ServerRPC().UpdateServerUser(this.AdminContext(), &pb.UpdateServerUserRequest{
ServerId: params.ServerId,
UserId: params.UserId,
})
if err != nil {
this.ErrorPage(err)
return
}
} else {
// 修改套餐
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

@@ -10,7 +10,15 @@
<td>所属用户</td>
<td>
<span v-if="user != null">{{user.fullname}} <span class="small">{{user.username}}</span><link-icon :href="'/users/user?userId=' + user.id"></link-icon></span>
<span v-else class="disabled">-</span>
<div v-if="user == null">
<div v-show="!userSelectorVisible">
<span class="disabled">没有指定用户</span> &nbsp; <a href="" @click.prevent="showUserSelector">[指定用户]</a>
</div>
<div v-show="userSelectorVisible">
<user-selector style="display:inline-block"></user-selector>
<p class="comment"><span class="red">修改服务所属用户时需要同时保证证书、域名等信息也属于该用户,否则可能产生难以预料的结果。</span></p>
</div>
</div>
</td>
</tr>
<tr>
@@ -66,7 +74,7 @@
</td>
</tr>
<tr>
<td>是否启用</td>
<td>启用当前服务</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="server.isOn"/>

View File

@@ -4,6 +4,12 @@ Tea.context(function () {
/**
* 用户相关
*/
this.userSelectorVisible = false
this.showUserSelector = function () {
this.userSelectorVisible = !this.userSelectorVisible
}
this.userId = 0
this.plans = []
this.userPlanId = 0