节点选择认证时增加推荐

This commit is contained in:
GoEdgeLab
2021-08-14 21:33:48 +08:00
parent 7ffdfc62f9
commit cbdbe6b9c9
23 changed files with 238 additions and 26 deletions

View File

@@ -16,7 +16,10 @@ func (this *SelectPopupAction) Init() {
this.Nav("", "", "")
}
func (this *SelectPopupAction) RunGet(params struct{}) {
func (this *SelectPopupAction) RunGet(params struct {
NodeClusterId int64
NsClusterId int64
}) {
// 所有的认证
grantsResp, err := this.RPC().NodeGrantRPC().FindAllEnabledNodeGrants(this.AdminContext(), &pb.FindAllEnabledNodeGrantsRequest{})
if err != nil {
@@ -37,6 +40,28 @@ func (this *SelectPopupAction) RunGet(params struct{}) {
}
this.Data["grants"] = grantMaps
// 推荐的认证
suggestGrantsResp, err := this.RPC().NodeGrantRPC().FindSuggestNodeGrants(this.AdminContext(), &pb.FindSuggestNodeGrantsRequest{
NodeClusterId: params.NodeClusterId,
NsClusterId: params.NsClusterId,
})
if err != nil {
this.ErrorPage(err)
return
}
var suggestGrantMaps = []maps.Map{}
for _, grant := range suggestGrantsResp.NodeGrants {
suggestGrantMaps = append(suggestGrantMaps, maps.Map{
"id": grant.Id,
"name": grant.Name,
"method": grant.Method,
"methodName": grantutils.FindGrantMethodName(grant.Method),
"username": grant.Username,
"description": grant.Description,
})
}
this.Data["suggestGrants"] = suggestGrantMaps
this.Show()
}