mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-11889] move sites service to content lib (#8073)
* move sites service to content lib * update migration guide * update imports
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { NodeEntry, Node, SitePaging, Site } from '@alfresco/js-api';
|
||||
import { AppConfigService, SitesService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { DocumentListService } from '../document-list/services/document-list.service';
|
||||
import { ContentNodeDialogService } from './content-node-dialog.service';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
@@ -25,6 +25,7 @@ import { Subject, of } from 'rxjs';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NodeAction } from '../document-list/models/node-action.enum';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
const fakeNodeEntry = {
|
||||
entry: {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { EventEmitter, Injectable, Output } from '@angular/core';
|
||||
import { ContentService, ThumbnailService, SitesService, TranslationService, AllowableOperationsEnum } from '@alfresco/adf-core';
|
||||
import { ContentService, ThumbnailService, TranslationService, AllowableOperationsEnum } from '@alfresco/adf-core';
|
||||
import { Subject, Observable, throwError } from 'rxjs';
|
||||
import { ShareDataRow } from '../document-list/data/share-data-row.model';
|
||||
import { Node, NodeEntry, SitePaging } from '@alfresco/js-api';
|
||||
@@ -27,6 +27,7 @@ import { ContentNodeSelectorComponentData } from './content-node-selector.compon
|
||||
import { NodeAction } from '../document-list/models/node-action.enum';
|
||||
import { NodeLockDialogComponent } from '../dialogs/node-lock.dialog';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@@ -28,12 +28,7 @@ import {
|
||||
SiteEntry,
|
||||
SitePaging
|
||||
} from '@alfresco/js-api';
|
||||
import {
|
||||
|
||||
NodesApiService,
|
||||
setupTestBed,
|
||||
SitesService
|
||||
} from '@alfresco/adf-core';
|
||||
import { NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
@@ -44,6 +39,7 @@ import { NodeEntryEvent, ShareDataRow } from '../document-list';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SearchQueryBuilderService } from '../search';
|
||||
import { mockQueryBody } from '../mock/search-query.mock';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
const fakeResultSetPaging: ResultSetPaging = {
|
||||
list: {
|
||||
|
@@ -34,7 +34,6 @@ import {
|
||||
FileUploadStatus,
|
||||
NodesApiService,
|
||||
setupTestBed,
|
||||
SitesService,
|
||||
UploadService,
|
||||
FileUploadCompleteEvent,
|
||||
DataRow,
|
||||
@@ -53,6 +52,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SearchQueryBuilderService } from '../search';
|
||||
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
||||
import { mockContentModelTextProperty } from '../mock/content-model.mock';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
const fakeResultSetPaging: ResultSetPaging = {
|
||||
list: {
|
||||
|
@@ -32,7 +32,6 @@ import {
|
||||
UserPreferenceValues,
|
||||
InfinitePaginationComponent, PaginatedComponent,
|
||||
NodesApiService,
|
||||
SitesService,
|
||||
UploadService,
|
||||
FileUploadCompleteEvent,
|
||||
FileUploadDeleteEvent,
|
||||
@@ -53,6 +52,7 @@ import { SEARCH_QUERY_SERVICE_TOKEN } from '../search/search-query-service.token
|
||||
import { SearchQueryBuilderService } from '../search/services/search-query-builder.service';
|
||||
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
||||
import { NodeEntryEvent } from '../document-list/components/node.event';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
export type ValidationFunction = (entry: Node) => boolean;
|
||||
|
||||
|
@@ -21,7 +21,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ContentNodeSelectorComponent } from './content-node-selector.component';
|
||||
import { Node, NodeEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { SitesService, ContentService, UploadService, FileModel, FileUploadEvent } from '@alfresco/adf-core';
|
||||
import { ContentService, UploadService, FileModel, FileUploadEvent } from '@alfresco/adf-core';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { DocumentListService } from '../document-list/services/document-list.service';
|
||||
@@ -30,6 +30,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { UploadModule } from '../upload';
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||
import { NodeAction } from '../document-list/models/node-action.enum';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
describe('ContentNodeSelectorComponent', () => {
|
||||
let component: ContentNodeSelectorComponent;
|
||||
|
@@ -19,12 +19,13 @@ import { LibraryDialogComponent } from './library.dialog';
|
||||
import { TestBed, fakeAsync, tick, flush, ComponentFixture, flushMicrotasks } from '@angular/core/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { setupTestBed, SitesService } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { delay } from 'rxjs/operators';
|
||||
import { SiteEntry } from '@alfresco/js-api';
|
||||
import { SitesService } from '../../services/sites.service';
|
||||
|
||||
describe('LibraryDialogComponent', () => {
|
||||
let fixture: ComponentFixture<LibraryDialogComponent>;
|
||||
|
@@ -33,8 +33,9 @@ import {
|
||||
} from '@angular/forms';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { QueriesApi, SiteBodyCreate, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService, SitesService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { debounceTime, finalize, mergeMap, takeUntil } from 'rxjs/operators';
|
||||
import { SitesService } from '../../services/sites.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-dialog',
|
||||
|
@@ -20,8 +20,9 @@ import { LibraryMembershipDirective } from './library-membership.directive';
|
||||
import { NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { of, throwError, Subject } from 'rxjs';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AlfrescoApiService, CoreModule, CoreTestingModule, SitesService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, CoreModule, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { ContentDirectiveModule } from './content-directive.module';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
describe('LibraryMembershipDirective', () => {
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
|
@@ -24,10 +24,11 @@ import {
|
||||
SitesApi
|
||||
} from '@alfresco/js-api';
|
||||
import { BehaviorSubject, from, Observable } from 'rxjs';
|
||||
import { SitesService, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { LibraryMembershipToggleEvent } from '../interfaces/library-membership-toggle-event.interface';
|
||||
import { LibraryMembershipErrorEvent} from '../interfaces/library-membership-error-event.interface';
|
||||
import { VersionCompatibilityService } from '../version-compatibility/version-compatibility.service';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
@Directive({
|
||||
selector: '[adf-library-membership]',
|
||||
|
@@ -16,3 +16,4 @@
|
||||
*/
|
||||
|
||||
export * from './card-view-content-update.service';
|
||||
export * from './sites.service';
|
||||
|
158
lib/content-services/src/lib/services/sites.service.spec.ts
Normal file
158
lib/content-services/src/lib/services/sites.service.spec.ts
Normal file
@@ -0,0 +1,158 @@
|
||||
/*!
|
||||
* @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 { TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService, setupTestBed, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { SitesService } from './sites.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('Sites service', () => {
|
||||
|
||||
let service;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||
appConfig.config = {
|
||||
ecmHost: 'http://localhost:9876/ecm',
|
||||
files: {
|
||||
excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git']
|
||||
}
|
||||
};
|
||||
|
||||
service = TestBed.inject(SitesService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should get a list of users sites', (done) => {
|
||||
service.getSites().subscribe((data) => {
|
||||
expect(data.list.entries[0].entry.title).toBe('FAKE');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 1,
|
||||
hasMoreItems: false,
|
||||
totalItems: 1,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
title: 'FAKE'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get single sites via siteId', (done) => {
|
||||
service.getSite('fake-site-id').subscribe((data) => {
|
||||
expect(data.entry.title).toBe('FAKE-SINGLE-TITLE');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-SINGLE-TITLE'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a list of membership requests', (done) => {
|
||||
service.getSiteMembershipRequests().subscribe((data) => {
|
||||
expect(data.list.entries[0].entry.site.id).toBe('site-id');
|
||||
expect(data.list.entries[0].entry.person.id).toBe('user-id');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 1,
|
||||
hasMoreItems: false,
|
||||
totalItems: 1,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: 'site-id',
|
||||
createdAt: '2020-05-13T07:46:36.180Z',
|
||||
site: {
|
||||
id: 'site-id',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
title: 'Sample Site',
|
||||
description: '',
|
||||
visibility: 'MODERATED',
|
||||
preset: 'preset',
|
||||
role: 'Manager'
|
||||
},
|
||||
person: {
|
||||
id: 'user-id',
|
||||
firstName: 'string',
|
||||
lastName: 'string',
|
||||
displayName: 'string'
|
||||
},
|
||||
message: 'message'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
334
lib/content-services/src/lib/services/sites.service.ts
Normal file
334
lib/content-services/src/lib/services/sites.service.ts
Normal file
@@ -0,0 +1,334 @@
|
||||
/*!
|
||||
* @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 { from, Observable, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import {
|
||||
MinimalNode,
|
||||
SiteBodyCreate,
|
||||
SiteEntry,
|
||||
SiteGroupEntry,
|
||||
SiteGroupPaging,
|
||||
SiteMemberEntry,
|
||||
SiteMemberPaging,
|
||||
SiteMembershipBodyCreate,
|
||||
SiteMembershipBodyUpdate,
|
||||
SiteMembershipRequestWithPersonPaging,
|
||||
SitePaging,
|
||||
SitesApi
|
||||
} from '@alfresco/js-api';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SitesService {
|
||||
|
||||
private _sitesApi: SitesApi;
|
||||
get sitesApi(): SitesApi {
|
||||
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
|
||||
return this._sitesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a site
|
||||
*
|
||||
* @param siteBody SiteBodyCreate to create site
|
||||
* @returns site SiteEntry
|
||||
*/
|
||||
createSite(siteBody: SiteBodyCreate): Observable<SiteEntry> {
|
||||
return from(this.sitesApi.createSite(siteBody))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all sites in the repository.
|
||||
*
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns List of sites
|
||||
*/
|
||||
getSites(opts: any = {}): Observable<SitePaging> {
|
||||
const defaultOptions = {
|
||||
skipCount: 0,
|
||||
include: ['properties']
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.sitesApi.listSites(queryOptions))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the details for a site.
|
||||
*
|
||||
* @param siteId ID of the target site
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Information about the site
|
||||
*/
|
||||
getSite(siteId: string, opts?: any): Observable<SiteEntry | any> {
|
||||
return from(this.sitesApi.getSite(siteId, opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a site.
|
||||
*
|
||||
* @param siteId Site to delete
|
||||
* @param permanentFlag True: deletion is permanent; False: site is moved to the trash
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
||||
const options: any = {};
|
||||
options.permanent = permanentFlag;
|
||||
return from(this.sitesApi.deleteSite(siteId, options))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a site's content.
|
||||
*
|
||||
* @param siteId ID of the target site
|
||||
* @returns Site content
|
||||
*/
|
||||
getSiteContent(siteId: string): Observable<SiteEntry | any> {
|
||||
return this.getSite(siteId, { relations: ['containers'] });
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all a site's members.
|
||||
*
|
||||
* @param siteId ID of the target site
|
||||
* @returns Site members
|
||||
*/
|
||||
getSiteMembers(siteId: string): Observable<SiteEntry | any> {
|
||||
return this.getSite(siteId, { relations: ['members'] });
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all a site's members.
|
||||
*
|
||||
* @param siteId ID of the target site
|
||||
* @param opts Optional parameters supported by JS-API
|
||||
* @returns Observable<SiteMemberPaging>
|
||||
*/
|
||||
listSiteMemberships(siteId: string, opts: any): Observable<SiteMemberPaging> {
|
||||
return from(this.sitesApi.listSiteMemberships(siteId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username of the user currently logged into ACS.
|
||||
*
|
||||
* @returns Username string
|
||||
*/
|
||||
getEcmCurrentLoggedUserName(): string {
|
||||
return this.apiService.getInstance().getEcmUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a site inside the path of a Node and returns its guid if it finds one.
|
||||
* (return an empty string if no site is found)
|
||||
*
|
||||
* @param node Node to look for parent site
|
||||
* @returns Site guid
|
||||
*/
|
||||
getSiteNameFromNodePath(node: MinimalNode): string {
|
||||
let siteName = '';
|
||||
if (node.path && node.path.elements) {
|
||||
const foundNode = node.path
|
||||
.elements.find((pathNode: MinimalNode) =>
|
||||
pathNode.nodeType === 'st:site' &&
|
||||
pathNode.name !== 'Sites');
|
||||
siteName = foundNode ? foundNode.name : '';
|
||||
}
|
||||
return siteName.toLocaleLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of site membership requests.
|
||||
*
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Site membership requests
|
||||
*/
|
||||
getSiteMembershipRequests(opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||
return from(this.sitesApi.getSiteMembershipRequests(opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a site membership for person **personId** on site **siteId**.
|
||||
*
|
||||
* @param siteId The identifier of a site
|
||||
* @param siteMembershipBodyCreate The person to add and their role
|
||||
* @param opts Optional parameters
|
||||
* @return Observable<SiteMemberEntry>
|
||||
*/
|
||||
createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable<SiteMemberEntry> {
|
||||
return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a site membership
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param personId The identifier of a person.
|
||||
* @param siteMembershipBodyUpdate The persons new role
|
||||
* @param opts Optional parameters
|
||||
* @return Observable<SiteMemberEntry>
|
||||
*/
|
||||
updateSiteMembership(siteId: string, personId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate, opts?: any): Observable<SiteMemberEntry> {
|
||||
return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a site membership
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param personId The identifier of a person.
|
||||
* @return Null response notifying when the operation is complete
|
||||
*/
|
||||
deleteSiteMembership(siteId: string, personId: string): Observable<void> {
|
||||
return from(this.sitesApi.deleteSiteMembership(siteId, personId))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept site membership requests.
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param inviteeId The invitee user name.
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||
return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject site membership requests.
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param inviteeId The invitee user name.
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List group membership for site
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Observable<SiteGroupPaging>
|
||||
*/
|
||||
listSiteGroups(siteId: string, opts?: any): Observable<SiteGroupPaging> {
|
||||
return from(this.sitesApi.listSiteGroups(siteId, opts))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a site membership for group
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param siteMembershipBodyCreate The Group to add and its role
|
||||
* @returns Observable<SiteGroupEntry>
|
||||
*/
|
||||
createSiteGroupMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate): Observable<SiteGroupEntry> {
|
||||
return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about site membership of group
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param groupId The authorityId of a group.
|
||||
* @return Observable<SiteGroupEntry>
|
||||
*/
|
||||
getSiteGroupMembership(siteId: string, groupId: string): Observable<SiteGroupEntry> {
|
||||
return from(this.sitesApi.getSiteGroupMembership(siteId, groupId))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update site membership of group
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param groupId The authorityId of a group.
|
||||
* @param siteMembershipBodyUpdate The group new role
|
||||
* @return Observable<SiteGroupEntry>
|
||||
*/
|
||||
updateSiteGroupMembership(siteId: string, groupId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate): Observable<SiteGroupEntry> {
|
||||
return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a group membership for site
|
||||
*
|
||||
* @param siteId The identifier of a site.
|
||||
* @param groupId The authorityId of a group.
|
||||
* @return Observable<void>
|
||||
*/
|
||||
deleteSiteGroupMembership(siteId: string, groupId: string): Observable<void> {
|
||||
return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any): Observable<never> {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ import { DebugElement } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DropdownSitesComponent, Relations } from './sites-dropdown.component';
|
||||
import { SitesService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { of } from 'rxjs';
|
||||
import { getFakeSitePaging,
|
||||
getFakeSitePagingNoMoreItems,
|
||||
@@ -29,6 +29,7 @@ import { getFakeSitePaging,
|
||||
} from '../mock';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
const customSiteList = {
|
||||
list: {
|
||||
|
@@ -16,11 +16,12 @@
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { SitesService, LogService, InfiniteSelectScrollDirective } from '@alfresco/adf-core';
|
||||
import { LogService, InfiniteSelectScrollDirective } from '@alfresco/adf-core';
|
||||
import { SitePaging, SiteEntry } from '@alfresco/js-api';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import {LiveAnnouncer} from '@angular/cdk/a11y';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import { SitesService } from '../services/sites.service';
|
||||
|
||||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
Reference in New Issue
Block a user