mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-24 14:31:41 +00:00
AAE-35649 Fix missing spinner when loading in ViewerRenderComponent
This commit is contained in:
@@ -257,7 +257,10 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
||||
.then(() => {
|
||||
setTimeout(() => this.scalePage('init'));
|
||||
})
|
||||
.catch(() => this.error.emit());
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
this.error.emit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,17 @@
|
||||
<div *ngIf="isLoading" class="adf-viewer-render-main-loader">
|
||||
<div class="adf-viewer-render-layout-content adf-viewer__fullscreen-container">
|
||||
<div class="adf-viewer-render-content-container">
|
||||
<div class="adf-viewer-render__loading-screen">
|
||||
<h2>{{ 'ADF_VIEWER.LOADING' | translate }}</h2>
|
||||
<div>
|
||||
<mat-spinner class="adf-viewer-render__loading-screen__spinner" />
|
||||
@if (isLoading || isFileLoading) {
|
||||
<div class="adf-viewer-render-main-loader">
|
||||
<div class="adf-viewer-render-layout-content adf-viewer__fullscreen-container">
|
||||
<div class="adf-viewer-render-content-container">
|
||||
<div class="adf-viewer-render__loading-screen">
|
||||
<h2>{{ 'ADF_VIEWER.LOADING' | translate }}</h2>
|
||||
<div>
|
||||
<mat-spinner class="adf-viewer-render__loading-screen__spinner" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (urlFile || blobFile) {
|
||||
<div [hidden]="isLoading" class="adf-viewer-render-main">
|
||||
|
@@ -489,6 +489,12 @@ describe('ViewerComponent', () => {
|
||||
expect(getMainLoader()).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should show spinner when isFileLoading is true', () => {
|
||||
component.isFileLoading = true;
|
||||
fixture.detectChanges();
|
||||
expect(getMainLoader()).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should show spinner until content is ready when viewerType is media', () => {
|
||||
component.isLoading = false;
|
||||
component.urlFile = 'some-file.mp4';
|
||||
@@ -545,5 +551,21 @@ describe('ViewerComponent', () => {
|
||||
|
||||
expect(getMainLoader()).toBeNull();
|
||||
});
|
||||
|
||||
it('should not show spinner after url file is set', () => {
|
||||
component.urlFile = 'some-url.txt';
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getMainLoader()).toBeNull();
|
||||
});
|
||||
|
||||
it('should not show spinner after blob file is set', () => {
|
||||
component.blobFile = new Blob(['This is my blob content'], { type: 'text/plain' });
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getMainLoader()).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -139,6 +139,7 @@ export class ViewerRenderComponent implements OnChanges, OnInit {
|
||||
internalFileName: string;
|
||||
viewerType: string = 'unknown';
|
||||
isLoading = false;
|
||||
isFileLoading = false;
|
||||
|
||||
/**
|
||||
* Returns a list of the active Viewer content extensions.
|
||||
@@ -182,6 +183,8 @@ export class ViewerRenderComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.isFileLoading = !this.blobFile && !this.urlFile;
|
||||
|
||||
if (this.blobFile) {
|
||||
this.setUpBlobData();
|
||||
} else if (this.urlFile) {
|
||||
|
Reference in New Issue
Block a user