mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-9406] Add getContentRenditionTypePreview to process-content service (#10743)
* [ACS-9406] Add getContentRenditionTypePreview to process-content service * [ACS-9406] remove extra space * [ACS-9406] fix unit tests * [ACS-9406] fix unit tests * [ACS-9406] cr fixes
This commit is contained in:
committed by
GitHub
parent
c85245b241
commit
8e0ea373f0
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { ProcessContentService } from './process-content.service';
|
||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
@@ -176,10 +175,24 @@ describe('ProcessContentService', () => {
|
||||
});
|
||||
|
||||
it('should return a Blob as thumbnail', (done) => {
|
||||
const contentId: number = 999;
|
||||
const blob = createFakeBlob();
|
||||
spyOn(service, 'getContentThumbnail').and.returnValue(of(blob));
|
||||
const contentId = 999;
|
||||
spyOn(service.contentApi, 'getRawContent').and.returnValue(Promise.resolve(createFakeBlob()));
|
||||
|
||||
service.getContentThumbnail(contentId).subscribe((result) => {
|
||||
expect(service.contentApi.getRawContent).toHaveBeenCalledWith(contentId, 'thumbnail');
|
||||
expect(result).toEqual(jasmine.any(Blob));
|
||||
expect(result.size).toEqual(48);
|
||||
expect(result.type).toEqual('image/png');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a Blob as preview', (done) => {
|
||||
const contentId = 999;
|
||||
spyOn(service.contentApi, 'getRawContent').and.returnValue(Promise.resolve(createFakeBlob()));
|
||||
|
||||
service.getContentRenditionTypePreview(contentId).subscribe((result) => {
|
||||
expect(service.contentApi.getRawContent).toHaveBeenCalledWith(contentId, 'preview');
|
||||
expect(result).toEqual(jasmine.any(Blob));
|
||||
expect(result.size).toEqual(48);
|
||||
expect(result.type).toEqual('image/png');
|
||||
|
@@ -120,6 +120,16 @@ export class ProcessContentService {
|
||||
return from(this.contentApi.getRawContent(contentId, 'thumbnail')).pipe(catchError((err) => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preview rendition for a related content file.
|
||||
*
|
||||
* @param contentId ID of the related content
|
||||
* @returns Binary data of the related content
|
||||
*/
|
||||
getContentRenditionTypePreview(contentId: number): Observable<Blob> {
|
||||
return from(this.contentApi.getRawContent(contentId, 'preview')).pipe(catchError((err) => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets related content items for a task instance.
|
||||
*
|
||||
|
@@ -112,7 +112,7 @@ export class ContentWidgetComponent implements OnChanges {
|
||||
}
|
||||
|
||||
openViewer(content: ContentLinkModel): void {
|
||||
let fetch = this.processContentService.getContentPreview(content.id);
|
||||
let fetch = this.processContentService.getContentRenditionTypePreview(content.id);
|
||||
if (content.isTypeImage() || content.isTypePdf()) {
|
||||
fetch = this.processContentService.getFileRawContent(content.id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user