Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-5184] Show progress spinner on file navigation #10596

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/core/src/lib/viewer/components/viewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ describe('ViewerComponent', () => {
expect(thumbnailService.getMimeTypeIcon).toHaveBeenCalledWith('application/pdf');
expect(component.mimeTypeIconUrl).toBe('application/pdf');
});

it('should reset urlFile and blobFile on onNavigateBeforeClick', () => {
component.urlFile = 'some-url';
component.blobFile = new Blob(['content'], { type: 'text/plain' });

component.onNavigateBeforeClick(new MouseEvent('click'));

expect(component.urlFile).toBe('');
expect(component.blobFile).toBeNull();
});

it('should reset urlFile and blobFile on onNavigateNextClick', () => {
component.urlFile = 'some-url';
component.blobFile = new Blob(['content'], { type: 'text/plain' });

component.onNavigateNextClick(new MouseEvent('click'));

expect(component.urlFile).toBe('');
expect(component.blobFile).toBeNull();
});
});

describe('File Name Test', () => {
Expand Down
18 changes: 10 additions & 8 deletions lib/core/src/lib/viewer/components/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
}

onNavigateBeforeClick(event: MouseEvent | KeyboardEvent) {
this.resetLoadingSpinner();
this.navigateBefore.next(event);
}

onNavigateNextClick(event: MouseEvent | KeyboardEvent) {
this.resetLoadingSpinner();
this.navigateNext.next(event);
}

Expand All @@ -392,22 +394,17 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
return;
}

const key = event.keyCode;

// Left arrow
if (key === 37 && this.canNavigateBefore) {
if (event.key === 'ArrowLeft' && this.canNavigateBefore) {
event.preventDefault();
this.onNavigateBeforeClick(event);
}

// Right arrow
if (key === 39 && this.canNavigateNext) {
if (event.key === 'ArrowRight' && this.canNavigateNext) {
event.preventDefault();
this.onNavigateNextClick(event);
}

// Ctrl+F
if (key === 70 && event.ctrlKey) {
if (event.code === 'KeyF' && event.ctrlKey) {
event.preventDefault();
this.enterFullScreen();
}
Expand Down Expand Up @@ -503,4 +500,9 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
});
}
}

private resetLoadingSpinner() {
this.urlFile = '';
this.blobFile = null;
}
}
Loading