mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ACA-1606] use new api siteservice (#5693)
* use new apu siteservice * refactor import * added getSiteMembershipRequests Co-authored-by: Cilibiu Bogdan <bogdan.cilibiu@ness.com>
This commit is contained in:
parent
6da489a7ff
commit
b76bb750dc
@ -105,4 +105,52 @@ describe('Sites service', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, from, throwError } from 'rxjs';
|
import { Observable, from, throwError } from 'rxjs';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { SitePaging, SiteEntry } from '@alfresco/js-api';
|
import { SitePaging, SiteEntry, SitesApi, SiteMembershipRequestWithPersonPaging } from '@alfresco/js-api';
|
||||||
import { catchError } from 'rxjs/operators';
|
import { catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -26,8 +26,10 @@ import { catchError } from 'rxjs/operators';
|
|||||||
})
|
})
|
||||||
export class SitesService {
|
export class SitesService {
|
||||||
|
|
||||||
constructor(
|
sitesApi: SitesApi;
|
||||||
private apiService: AlfrescoApiService) {
|
|
||||||
|
constructor(private apiService: AlfrescoApiService) {
|
||||||
|
this.sitesApi = new SitesApi(apiService.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +43,7 @@ export class SitesService {
|
|||||||
include: ['properties']
|
include: ['properties']
|
||||||
};
|
};
|
||||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||||
return from(this.apiService.getInstance().core.sitesApi.getSites(queryOptions))
|
return from(this.sitesApi.listSites(queryOptions))
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError((err: any) => this.handleError(err))
|
catchError((err: any) => this.handleError(err))
|
||||||
);
|
);
|
||||||
@ -54,7 +56,7 @@ export class SitesService {
|
|||||||
* @returns Information about the site
|
* @returns Information about the site
|
||||||
*/
|
*/
|
||||||
getSite(siteId: string, opts?: any): Observable<SiteEntry | {}> {
|
getSite(siteId: string, opts?: any): Observable<SiteEntry | {}> {
|
||||||
return from(this.apiService.getInstance().core.sitesApi.getSite(siteId, opts))
|
return from(this.sitesApi.getSite(siteId, opts))
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError((err: any) => this.handleError(err))
|
catchError((err: any) => this.handleError(err))
|
||||||
);
|
);
|
||||||
@ -69,7 +71,7 @@ export class SitesService {
|
|||||||
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
||||||
const options: any = {};
|
const options: any = {};
|
||||||
options.permanent = permanentFlag;
|
options.permanent = permanentFlag;
|
||||||
return from(this.apiService.getInstance().core.sitesApi.deleteSite(siteId, options))
|
return from(this.sitesApi.deleteSite(siteId, options))
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError((err: any) => this.handleError(err))
|
catchError((err: any) => this.handleError(err))
|
||||||
);
|
);
|
||||||
@ -101,6 +103,18 @@ export class SitesService {
|
|||||||
return this.apiService.getInstance().getEcmUsername();
|
return this.apiService.getInstance().getEcmUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private handleError(error: any): any {
|
private handleError(error: any): any {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return throwError(error || 'Server error');
|
return throwError(error || 'Server error');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user