[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,9 +678,11 @@ 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(() => {
currentRetry++;
if (this.maxRetries >= currentRetry) {
this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => { this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => {
const status = rendition.entry.status.toString(); const status = rendition.entry.status.toString();
if (status === 'CREATED') { if (status === 'CREATED') {
@@ -700,6 +702,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
this.viewerType = 'error_in_creation'; this.viewerType = 'error_in_creation';
return reject(); return reject();
}); });
}
}, 1000); }, 1000);
}); });
} }