diff --git a/lib/core/viewer/components/img-viewer.component.html b/lib/core/viewer/components/img-viewer.component.html index 26e8624263..522b74f27c 100644 --- a/lib/core/viewer/components/img-viewer.component.html +++ b/lib/core/viewer/components/img-viewer.component.html @@ -1,5 +1,5 @@
diff --git a/lib/core/viewer/components/img-viewer.component.ts b/lib/core/viewer/components/img-viewer.component.ts index 544c0ec3cc..7285493a24 100644 --- a/lib/core/viewer/components/img-viewer.component.ts +++ b/lib/core/viewer/components/img-viewer.component.ts @@ -23,7 +23,9 @@ import { ViewEncapsulation, ElementRef, OnInit, - OnDestroy + OnDestroy, + Output, + EventEmitter } from '@angular/core'; import { ContentService } from '../../services/content.service'; import { AppConfigService } from './../../app-config/app-config.service'; @@ -50,6 +52,9 @@ export class ImgViewerComponent implements OnInit, OnChanges, OnDestroy { @Input() nameFile: string; + @Output() + error = new EventEmitter(); + rotate: number = 0; scaleX: number = 1.0; scaleY: number = 1.0; @@ -216,4 +221,8 @@ export class ImgViewerComponent implements OnInit, OnChanges, OnDestroy { this.offsetX = 0; this.offsetY = 0; } + + onImageError() { + this.error.emit(); + } } diff --git a/lib/core/viewer/components/media-player.component.html b/lib/core/viewer/components/media-player.component.html index d79967452a..0c825b9da0 100644 --- a/lib/core/viewer/components/media-player.component.html +++ b/lib/core/viewer/components/media-player.component.html @@ -1,3 +1,3 @@ diff --git a/lib/core/viewer/components/media-player.component.ts b/lib/core/viewer/components/media-player.component.ts index 758a703dd3..3d6cfc9321 100644 --- a/lib/core/viewer/components/media-player.component.ts +++ b/lib/core/viewer/components/media-player.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation, Output, EventEmitter } from '@angular/core'; import { ContentService } from '../../services/content.service'; @Component({ @@ -39,6 +39,9 @@ export class MediaPlayerComponent implements OnChanges { @Input() nameFile: string; + @Output() + error = new EventEmitter(); + constructor(private contentService: ContentService ) {} ngOnChanges(changes: SimpleChanges) { @@ -52,4 +55,8 @@ export class MediaPlayerComponent implements OnChanges { throw new Error('Attribute urlFile or blobFile is required'); } } + + onMediaPlayerError() { + this.error.emit(); + } } diff --git a/lib/core/viewer/components/viewer.component.html b/lib/core/viewer/components/viewer.component.html index 106d635655..d3d4b98742 100644 --- a/lib/core/viewer/components/viewer.component.html +++ b/lib/core/viewer/components/viewer.component.html @@ -3,22 +3,26 @@ [class.adf-viewer-overlay-container]="overlayMode" [class.adf-viewer-inline-container]="!overlayMode"> -
+
- + - @@ -34,108 +38,108 @@ -
- - - {{ fileTitle }} -
- - - + - - - - - - + @@ -143,30 +147,45 @@
-
+
-
+
- + + - +
-
+
- + + - +
-
+
-
+

{{ 'ADF_VIEWER.LOADING' | translate }}

@@ -178,28 +197,48 @@
-
+
-
+
- + - + - + - + -
+

{{ 'ADF_VIEWER.LOADING' | translate }}

@@ -209,21 +248,20 @@ - + - - + + diff --git a/lib/core/viewer/components/viewer.component.spec.ts b/lib/core/viewer/components/viewer.component.spec.ts index 201145e161..f53c582cd6 100644 --- a/lib/core/viewer/components/viewer.component.spec.ts +++ b/lib/core/viewer/components/viewer.component.spec.ts @@ -878,6 +878,21 @@ describe('ViewerComponent', () => { component.ngOnChanges(); }); + it('should swicth to the unkwown template if the type specific viewers throw an error', (done) => { + component.urlFile = 'fake-url-file.icns'; + component.mimeType = 'image/png'; + component.ngOnChanges(); + fixture.detectChanges(); + + component.onUnsupportedFile(); + fixture.detectChanges(); + fixture.whenStable().then(() => { + fixture.detectChanges(); + expect(element.querySelector('adf-viewer-unknown-format')).toBeDefined(); + done(); + }); + }); + }); describe('Events', () => { diff --git a/lib/core/viewer/components/viewer.component.ts b/lib/core/viewer/components/viewer.component.ts index ab66fbff0e..8da0cc79e5 100644 --- a/lib/core/viewer/components/viewer.component.ts +++ b/lib/core/viewer/components/viewer.component.ts @@ -669,6 +669,10 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy { } + onUnsupportedFile() { + this.viewerType = 'unknown'; + } + private generateCacheBusterNumber() { this.cacheBusterNumber = Date.now(); }