fix 6951 user permission is project Admin the user list donot show when user input

Signed-off-by: Yogi_Wang <yawang@vmware.com>
This commit is contained in:
Yogi_Wang 2019-03-19 12:57:31 +08:00
parent 7ae7f9f23f
commit c84d55f1f8
3 changed files with 33 additions and 34 deletions

View File

@ -24,3 +24,8 @@
background-image: linear-gradient(180deg,#f5f5f5 0,#e8e8e8); background-image: linear-gradient(180deg,#f5f5f5 0,#e8e8e8);
background-repeat: repeat-x; background-repeat: repeat-x;
} }
.modal-body{
overflow: visible;
}

View File

@ -26,7 +26,7 @@ import {
import { Response } from '@angular/http'; import { Response } from '@angular/http';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import { Subject } from "rxjs"; import { Subject, forkJoin } from "rxjs";
@ -94,11 +94,6 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
hasProjectAdminRole = (<Project>resolverData['projectResolver']).has_project_admin_role; hasProjectAdminRole = (<Project>resolverData['projectResolver']).has_project_admin_role;
} }
if (hasProjectAdminRole) { if (hasProjectAdminRole) {
this.userService.getUsersNameList()
.subscribe(users => {
this.userLists = users;
});
this.nameChecker.pipe( this.nameChecker.pipe(
debounceTime(500), debounceTime(500),
distinctUntilChanged(), ) distinctUntilChanged(), )
@ -108,32 +103,31 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
this.isMemberNameValid = cont.valid; this.isMemberNameValid = cont.valid;
if (cont.valid) { if (cont.valid) {
this.checkOnGoing = true; this.checkOnGoing = true;
this.memberService forkJoin(this.userService.getUsersNameList(cont.value, 20), this.memberService
.listMembers(this.projectId, cont.value) .listMembers(this.projectId, cont.value)).subscribe((res: Array<any>) => {
.subscribe((members: Member[]) => { this.userLists = res[0];
if (members.filter(m => { return m.entity_name === cont.value; }).length > 0) { if (res[1].filter(m => { return m.entity_name === cont.value; }).length > 0) {
this.isMemberNameValid = false; this.isMemberNameValid = false;
this.memberTooltip = 'MEMBER.USERNAME_ALREADY_EXISTS'; this.memberTooltip = 'MEMBER.USERNAME_ALREADY_EXISTS';
} }
this.checkOnGoing = false; this.checkOnGoing = false;
}, error => { if (this.userLists && this.userLists.length) {
this.checkOnGoing = false; this.selectUserName = [];
}); this.userLists.forEach(data => {
// username autocomplete if (data.username.startsWith(cont.value) && !this.memberList.find(mem => mem.entity_name === data.username)) {
if (this.userLists && this.userLists.length) { if (this.selectUserName.length < 10) {
this.selectUserName = []; this.selectUserName.push(data.username);
this.userLists.forEach(data => { }
if (data.username.startsWith(cont.value) && !this.memberList.find(mem => mem.entity_name === data.username)) {
if (this.selectUserName.length < 10) {
this.selectUserName.push(data.username);
} }
} });
}); let changeTimer = setInterval(() => this.ref.detectChanges(), 200);
let changeTimer = setInterval(() => this.ref.detectChanges(), 200); setTimeout(() => {
setTimeout(() => { clearInterval(changeTimer);
clearInterval(changeTimer); }, 2000);
}, 2000); }
} }, error => {
this.checkOnGoing = false;
});
} else { } else {
this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED'; this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED';
} }

View File

@ -21,7 +21,7 @@ import { User, LDAPUser } from './user';
import LDAPUsertoUser from './user'; import LDAPUsertoUser from './user';
const userMgmtEndpoint = '/api/users'; const userMgmtEndpoint = '/api/users';
const userListSearch = '/api/users/search'; const userListSearch = '/api/users/search?';
const ldapUserEndpoint = '/api/ldap/users'; const ldapUserEndpoint = '/api/ldap/users';
/** /**
@ -41,8 +41,8 @@ export class UserService {
} }
// Get the user list // Get the user list
getUsersNameList(): Observable<User[]> { getUsersNameList(name: string, page_size: number): Observable<User[]> {
return this.http.get(userListSearch, HTTP_GET_OPTIONS) return this.http.get(`${userListSearch}page_size=${page_size}&username=${name}`, HTTP_GET_OPTIONS)
.pipe(map(response => response.json() as User[]) .pipe(map(response => response.json() as User[])
, catchError(error => this.handleError(error))); , catchError(error => this.handleError(error)));
} }