mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
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:
committed by
Eugenio Romano
parent
f0ee0bda2f
commit
e7b2daa1fe
@@ -168,6 +168,15 @@
|
||||
<adf-txt-viewer [urlFile]="urlFileContent" [blobFile]="blobFile"></adf-txt-viewer>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngSwitchCase="'in_creation'">
|
||||
<div class="adf-viewer__loading-screen" fxFlex="1 1 auto">
|
||||
<h2>{{ 'ADF_VIEWER.LOADING' | translate }}</h2>
|
||||
<div>
|
||||
<mat-spinner></mat-spinner>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngSwitchCase="'custom'">
|
||||
<span class="adf-viewer-custom-content" *ngFor="let extensionTemplate of extensionTemplates">
|
||||
<ng-template *ngIf="extensionTemplate.isVisible" [ngTemplateOutlet]="extensionTemplate.template" [ngTemplateOutletContext]="{ urlFileContent: urlFileContent, extension:extension }">
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user