[ADF-3309] solve rendition preview (#3573)

* solve rendition preview

* fix tslint

* missing semicolon

* solve packaging issues

* reinsert maxretry logic
This commit is contained in:
Eugenio Romano
2018-07-10 19:43:10 +01:00
committed by Eugenio Romano
parent 809f4c06d3
commit 9b804f72f2

View File

@@ -175,7 +175,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
* There is a delay of at least one second between attempts. * There is a delay of at least one second between attempts.
*/ */
@Input() @Input()
maxRetries = 5; maxRetries = 10;
/** Emitted when user clicks the 'Back' button. */ /** Emitted when user clicks the 'Back' button. */
@Output() @Output()
@@ -678,28 +678,31 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
} }
private async waitRendition(nodeId: string, renditionId: string, retries: number): Promise<RenditionEntry> { private async waitRendition(nodeId: string, renditionId: string, retries: number): Promise<RenditionEntry> {
let currentRetry = 0;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let intervalId = setInterval(() => { let intervalId = setInterval(() => {
this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => { currentRetry++;
const status = rendition.entry.status.toString(); if (this.maxRetries >= currentRetry) {
if (status === 'CREATED') { this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => {
const status = rendition.entry.status.toString();
if (status === 'CREATED') {
if (renditionId === 'pdf') { if (renditionId === 'pdf') {
this.viewerType = 'pdf'; this.viewerType = 'pdf';
} else if (renditionId === 'imgpreview') { } else if (renditionId === 'imgpreview') {
this.viewerType = 'image'; this.viewerType = 'image';
}
this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId);
clearInterval(intervalId);
return resolve(rendition);
} }
}, () => {
this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId); this.viewerType = 'error_in_creation';
return reject();
clearInterval(intervalId); });
return resolve(rendition); }
}
}, () => {
this.viewerType = 'error_in_creation';
return reject();
});
}, 1000); }, 1000);
}); });
} }