mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
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:
parent
7ae7f9f23f
commit
c84d55f1f8
@ -24,3 +24,8 @@
|
||||
background-image: linear-gradient(180deg,#f5f5f5 0,#e8e8e8);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.modal-body{
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user