mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
fix error in preview (#6009)
This commit is contained in:
parent
4bf7a758ca
commit
6384b8148c
@ -219,15 +219,21 @@ export class ViewUtilService {
|
|||||||
if (status === 'NOT_CREATED') {
|
if (status === 'NOT_CREATED') {
|
||||||
try {
|
try {
|
||||||
if (versionId) {
|
if (versionId) {
|
||||||
await this.apiService.versionsApi.createVersionRendition(nodeId, versionId, {id: renditionId}).then(() => {
|
await this.apiService.versionsApi.createVersionRendition(nodeId, versionId, { id: renditionId }).then(() => {
|
||||||
this.viewerTypeChange.next('in_creation');
|
this.viewerTypeChange.next('in_creation');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await this.apiService.renditionsApi.createRendition(nodeId, {id: renditionId}).then(() => {
|
await this.apiService.renditionsApi.createRendition(nodeId, { id: renditionId }).then(() => {
|
||||||
this.viewerTypeChange.next('in_creation');
|
this.viewerTypeChange.next('in_creation');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
rendition = versionId ? await this.waitNodeRendition(nodeId, renditionId, versionId) : await this.waitNodeRendition(nodeId, renditionId);
|
try {
|
||||||
|
rendition = versionId ? await this.waitNodeRendition(nodeId, renditionId, versionId) : await this.waitNodeRendition(nodeId, renditionId);
|
||||||
|
} catch (e) {
|
||||||
|
this.viewerTypeChange.next('error_in_creation');
|
||||||
|
rendition = null;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logService.error(err);
|
this.logService.error(err);
|
||||||
}
|
}
|
||||||
@ -245,45 +251,47 @@ export class ViewUtilService {
|
|||||||
if (this.maxRetries >= currentRetry) {
|
if (this.maxRetries >= currentRetry) {
|
||||||
if (versionId) {
|
if (versionId) {
|
||||||
this.apiService.versionsApi.getVersionRendition(nodeId, versionId, renditionId).then((rendition: RenditionEntry) => {
|
this.apiService.versionsApi.getVersionRendition(nodeId, versionId, renditionId).then((rendition: RenditionEntry) => {
|
||||||
this.handleNodeRendition(rendition, nodeId, renditionId, versionId);
|
const status: string = rendition.entry.status.toString();
|
||||||
clearInterval(intervalId);
|
|
||||||
return resolve(rendition);
|
if (status === 'CREATED') {
|
||||||
|
this.handleNodeRendition(nodeId, renditionId, versionId);
|
||||||
|
clearInterval(intervalId);
|
||||||
|
return resolve(rendition);
|
||||||
|
}
|
||||||
}, () => {
|
}, () => {
|
||||||
this.viewerTypeChange.next('error_in_creation');
|
|
||||||
return reject();
|
return reject();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition: RenditionEntry) => {
|
this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition: RenditionEntry) => {
|
||||||
this.handleNodeRendition(rendition, nodeId, renditionId);
|
const status: string = rendition.entry.status.toString();
|
||||||
clearInterval(intervalId);
|
|
||||||
return resolve(rendition);
|
if (status === 'CREATED') {
|
||||||
|
this.handleNodeRendition(nodeId, renditionId);
|
||||||
|
clearInterval(intervalId);
|
||||||
|
return resolve(rendition);
|
||||||
|
}
|
||||||
}, () => {
|
}, () => {
|
||||||
this.viewerTypeChange.next('error_in_creation');
|
|
||||||
return reject();
|
return reject();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.viewerTypeChange.next('error_in_creation');
|
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
|
return reject();
|
||||||
}
|
}
|
||||||
}, this.TRY_TIMEOUT);
|
}, this.TRY_TIMEOUT);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleNodeRendition(rendition: RenditionEntry, nodeId: string, renditionId: string, versionId?: string) {
|
private async handleNodeRendition(nodeId: string, renditionId: string, versionId?: string) {
|
||||||
const status: string = rendition.entry.status.toString();
|
if (renditionId === 'pdf') {
|
||||||
if (status === 'CREATED') {
|
this.viewerTypeChange.next('pdf');
|
||||||
|
} else if (renditionId === 'imgpreview') {
|
||||||
if (renditionId === 'pdf') {
|
this.viewerTypeChange.next('image');
|
||||||
this.viewerTypeChange.next('pdf');
|
|
||||||
} else if (renditionId === 'imgpreview') {
|
|
||||||
this.viewerTypeChange.next('image');
|
|
||||||
}
|
|
||||||
|
|
||||||
const urlFileContent = versionId ? this.apiService.contentApi.getVersionRenditionUrl(nodeId, versionId, renditionId) :
|
|
||||||
this.apiService.contentApi.getRenditionUrl(nodeId, renditionId);
|
|
||||||
this.urlFileContentChange.next(urlFileContent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const urlFileContent = versionId ? this.apiService.contentApi.getVersionRenditionUrl(nodeId, versionId, renditionId) :
|
||||||
|
this.apiService.contentApi.getRenditionUrl(nodeId, renditionId);
|
||||||
|
this.urlFileContentChange.next(urlFileContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user