mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-5392] - Add find people api call (#7119)
* [AAE-5392] - Add find people api call * Add documentation
This commit is contained in:
@@ -19,7 +19,7 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { PersonEntry, PeopleApi, PersonBodyCreate, Pagination } from '@alfresco/js-api';
|
||||
import { PersonEntry, PeopleApi, PersonBodyCreate, Pagination, QueriesApi } from '@alfresco/js-api';
|
||||
import { EcmUserModel } from '../models/ecm-user.model';
|
||||
import { LogService } from './log.service';
|
||||
|
||||
@@ -45,6 +45,7 @@ export class PeopleContentService {
|
||||
hasCheckedIsContentAdmin: boolean = false;
|
||||
|
||||
private _peopleApi: PeopleApi;
|
||||
private _queriesApi: QueriesApi;
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {}
|
||||
|
||||
@@ -52,6 +53,10 @@ export class PeopleContentService {
|
||||
return this._peopleApi || (this._peopleApi = new PeopleApi(this.apiService.getInstance()));
|
||||
}
|
||||
|
||||
get queriesApi() {
|
||||
return this._queriesApi || (this._queriesApi = new QueriesApi(this.apiService.getInstance()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about a user identified by their username.
|
||||
* @param personId ID of the target user
|
||||
@@ -91,6 +96,25 @@ export class PeopleContentService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of people that match the given search criteria.
|
||||
* @param searchTerm The term to search for
|
||||
* @param requestQuery maxItems and skipCount parameters supported by JS-API
|
||||
* @returns Response containing pagination and list of entries
|
||||
*/
|
||||
findPeople(searchTerm: string, requestQuery?: PeopleContentQueryRequestModel): Observable<PeopleContentQueryResponse> {
|
||||
const promise = this.queriesApi.findPeople(searchTerm, { ...requestQuery });
|
||||
return from(promise).pipe(
|
||||
map(response => {
|
||||
return {
|
||||
pagination: response.list.pagination,
|
||||
entries: response.list.entries.map((person: PersonEntry) => <EcmUserModel> person.entry)
|
||||
};
|
||||
}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new person.
|
||||
* @param newPerson Object containing the new person details.
|
||||
|
Reference in New Issue
Block a user