Merge pull request #7167 from jwangyangls/userListShowInProjecAdmin

fix 6951 user permission is project Admin the user list donot show wh…
This commit is contained in:
jwangyangls 2019-03-19 14:12:45 +08:00 committed by GitHub
commit 9a1b5eac26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 34 deletions

View File

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

View File

@ -26,7 +26,7 @@ import {
import { Response } from '@angular/http';
import { NgForm } from '@angular/forms';
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;
}
if (hasProjectAdminRole) {
this.userService.getUsersNameList()
.subscribe(users => {
this.userLists = users;
});
this.nameChecker.pipe(
debounceTime(500),
distinctUntilChanged(), )
@ -108,32 +103,31 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
this.isMemberNameValid = cont.valid;
if (cont.valid) {
this.checkOnGoing = true;
this.memberService
.listMembers(this.projectId, cont.value)
.subscribe((members: Member[]) => {
if (members.filter(m => { return m.entity_name === cont.value; }).length > 0) {
this.isMemberNameValid = false;
this.memberTooltip = 'MEMBER.USERNAME_ALREADY_EXISTS';
}
this.checkOnGoing = false;
}, error => {
this.checkOnGoing = false;
});
// username autocomplete
if (this.userLists && this.userLists.length) {
this.selectUserName = [];
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);
forkJoin(this.userService.getUsersNameList(cont.value, 20), this.memberService
.listMembers(this.projectId, cont.value)).subscribe((res: Array<any>) => {
this.userLists = res[0];
if (res[1].filter(m => { return m.entity_name === cont.value; }).length > 0) {
this.isMemberNameValid = false;
this.memberTooltip = 'MEMBER.USERNAME_ALREADY_EXISTS';
}
this.checkOnGoing = false;
if (this.userLists && this.userLists.length) {
this.selectUserName = [];
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);
setTimeout(() => {
clearInterval(changeTimer);
}, 2000);
}
});
let changeTimer = setInterval(() => this.ref.detectChanges(), 200);
setTimeout(() => {
clearInterval(changeTimer);
}, 2000);
}
}, error => {
this.checkOnGoing = false;
});
} else {
this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED';
}

View File

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