[ADF-793] Ability to create PDF renditions in case of non supported formats (#1994)

* Style changes and button

* Convert to PDF button

* Convert to PDF button part II.

* Convert within the Not Supported Format component

* Rendition loading skeleton

* Conversion is working.

* Convert button behaviour tests

* Rebasing fix.
This commit is contained in:
Popovics András
2017-06-20 21:02:22 +01:00
committed by Eugenio Romano
parent 0ff4ff5f24
commit b457024cab
11 changed files with 331 additions and 49 deletions

View File

@@ -70,6 +70,7 @@ describe('RenditionsService', () => {
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
done();
});
@@ -81,6 +82,17 @@ describe('RenditionsService', () => {
});
});
describe('convert', () => {
it('should call the server with the ID passed and the asked encoding for creation', (done) => {
service.convert('fake-node-id', 'pdf');
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
done();
});
});
it('Get redition service should catch the error', (done) => {
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
}, (res) => {

View File

@@ -76,6 +76,19 @@ export class RenditionsService {
.catch(err => this.handleError(err));
}
convert(nodeId: string, encoding: string, pollingInterval: number|undefined) {
return this.createRendition(nodeId, encoding)
.concatMap(() => this.pollRendition(nodeId, encoding, pollingInterval));
}
private pollRendition(nodeId: string, encoding: string, interval: number = 1000) {
return Observable.interval(interval)
.switchMap(() => this.getRendition(nodeId, encoding))
.takeWhile((data) => {
return (data.entry.status !== 'CREATED');
});
}
private handleError(error: any): Observable<any> {
this.logService.error(error);
return Observable.throw(error || 'Server error');