mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3309] solve rendition preview (#3573)
* solve rendition preview * fix tslint * missing semicolon * solve packaging issues * reinsert maxretry logic
This commit is contained in:
committed by
Eugenio Romano
parent
809f4c06d3
commit
9b804f72f2
@@ -175,7 +175,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
* There is a delay of at least one second between attempts.
|
||||
*/
|
||||
@Input()
|
||||
maxRetries = 5;
|
||||
maxRetries = 10;
|
||||
|
||||
/** Emitted when user clicks the 'Back' button. */
|
||||
@Output()
|
||||
@@ -678,28 +678,31 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private async waitRendition(nodeId: string, renditionId: string, retries: number): Promise<RenditionEntry> {
|
||||
|
||||
let currentRetry = 0;
|
||||
return new Promise((resolve, reject) => {
|
||||
let intervalId = setInterval(() => {
|
||||
this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => {
|
||||
const status = rendition.entry.status.toString();
|
||||
if (status === 'CREATED') {
|
||||
currentRetry++;
|
||||
if (this.maxRetries >= currentRetry) {
|
||||
this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => {
|
||||
const status = rendition.entry.status.toString();
|
||||
if (status === 'CREATED') {
|
||||
|
||||
if (renditionId === 'pdf') {
|
||||
this.viewerType = 'pdf';
|
||||
} else if (renditionId === 'imgpreview') {
|
||||
this.viewerType = 'image';
|
||||
if (renditionId === 'pdf') {
|
||||
this.viewerType = 'pdf';
|
||||
} else if (renditionId === 'imgpreview') {
|
||||
this.viewerType = 'image';
|
||||
}
|
||||
|
||||
this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId);
|
||||
|
||||
clearInterval(intervalId);
|
||||
return resolve(rendition);
|
||||
}
|
||||
|
||||
this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId);
|
||||
|
||||
clearInterval(intervalId);
|
||||
return resolve(rendition);
|
||||
}
|
||||
}, () => {
|
||||
this.viewerType = 'error_in_creation';
|
||||
return reject();
|
||||
});
|
||||
}, () => {
|
||||
this.viewerType = 'error_in_creation';
|
||||
return reject();
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user