[MNT-21595] Content - Expose a group service for content (#5833)

* Expose a group service for content

* Use nx command and remove smart-build
This commit is contained in:
Maurizio Vitale
2020-07-13 12:22:54 +01:00
committed by GitHub
parent 179ce2e8eb
commit 42d88fdaa9
8 changed files with 85 additions and 94 deletions

View File

@@ -0,0 +1,43 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { GroupEntry } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';
@Injectable({
providedIn: 'root'
})
export class GroupService {
constructor(
private alfrescoApiService: AlfrescoApiService
) {}
async listAllGroupMembershipsForPerson(personId: string, opts?: any, accumulator = []): Promise<GroupEntry[]> {
const groupsPaginated = await this.alfrescoApiService.groupsApi.listGroupMembershipsForPerson(personId, opts);
accumulator = [...accumulator, ...groupsPaginated.list.entries];
if (groupsPaginated.list.pagination.hasMoreItems) {
const skip = groupsPaginated.list.pagination.skipCount + groupsPaginated.list.pagination.count;
return this.listAllGroupMembershipsForPerson(personId, {
maxItems: opts.maxItems,
skipCount: skip
}, accumulator);
} else {
return accumulator;
}
}
}