Reinsert e2e tag test (#3574)

* solve rendition preview

* reinsert tag e2e

* fix tslint

* fix pack problem

* remove reload

* remove refresh
This commit is contained in:
Eugenio Romano
2018-07-10 17:15:48 +01:00
committed by Eugenio Romano
parent f0ee0bda2f
commit e7b2daa1fe
7 changed files with 3777 additions and 3714 deletions

View File

@@ -648,7 +648,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
}
private async resolveRendition(nodeId: string, renditionId: string): Promise<RenditionEntry> {
private async resolveRendition(nodeId: string, renditionId: string) {
renditionId = renditionId.toLowerCase();
const supported = await this.apiService.renditionsApi.getRenditions(nodeId);
@@ -664,7 +664,9 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
if (status === 'NOT_CREATED') {
try {
await this.apiService.renditionsApi.createRendition(nodeId, { id: renditionId });
await this.apiService.renditionsApi.createRendition(nodeId, { id: renditionId }).then(() => {
this.viewerType = 'in_creation';
});
rendition = await this.waitRendition(nodeId, renditionId, 0);
} catch (err) {
this.logService.error(err);
@@ -676,23 +678,30 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
private async waitRendition(nodeId: string, renditionId: string, retries: number): Promise<RenditionEntry> {
const rendition = await this.apiService.renditionsApi.getRendition(nodeId, renditionId);
if (this.maxRetries < retries) {
const status = rendition.entry.status.toString();
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') {
if (status === 'CREATED') {
return rendition;
} else {
retries += 1;
await this.wait(1000);
return await this.waitRendition(nodeId, renditionId, retries);
}
}
}
if (renditionId === 'pdf') {
this.viewerType = 'pdf';
} else if (renditionId === 'imgpreview') {
this.viewerType = 'image';
}
private wait(ms: number): Promise<any> {
return new Promise(resolve => setTimeout(resolve, ms));
this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId);
clearInterval(intervalId);
return resolve(rendition);
}
}, () => {
this.viewerType = 'error_in_creation';
return reject();
});
}, 1000);
});
}
getSideBarStyle(): string {