From 825ce7998d33b770a194de6641c63d20e8d84194 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:33:02 -0800 Subject: [PATCH] Loading indicator --- .../document-detail.component.html | 7 ++ .../document-detail.component.ts | 103 ++++++++++-------- 2 files changed, 62 insertions(+), 48 deletions(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 468c42514..b0a0ac4ba 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -240,6 +240,12 @@ +
+
+
+ Loading... +
+
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 5bc0c03e5..b1fc40893 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -154,6 +154,7 @@ export class DocumentDetailComponent previewCurrentPage: number = 1 previewNumPages: number = 1 previewZoomSetting: ZoomSetting = ZoomSetting.Width + previewLoading: boolean = true store: BehaviorSubject isDirty$: Observable @@ -445,6 +446,8 @@ export class DocumentDetailComponent .subscribe({ next: (result) => { this.metadata = result + if (this.getContentType() !== 'application/pdf') + this.previewLoading = false }, error: (error) => { this.metadata = null @@ -766,6 +769,10 @@ export class DocumentDetailComponent }) } + onPdfLoadingStarts() { + this.previewLoading = false + } + onPagesLoaded(event: PagesLoadedEvent) { this.previewNumPages = event.pagesCount } @@ -784,6 +791,54 @@ export class DocumentDetailComponent } } + onZoomSelect(event: Event) { + this.previewZoomSetting = (event.target as HTMLSelectElement) + ?.value as ZoomSetting + } + + get zoomSettings() { + return Object.values(ZoomSetting) + } + + getZoomSettingTitle(setting: ZoomSetting = null): string { + switch (setting) { + case ZoomSetting.Auto: + return $localize`Auto` + case ZoomSetting.Actual: + return $localize`Actual Size` + case ZoomSetting.Fit: + return $localize`Page Fit` + case ZoomSetting.Width: + return $localize`Page Width` + default: + return setting + } + } + + increaseZoom(): void { + let currentIndex = Object.values(ZoomSetting).indexOf( + this.previewZoomSetting + ) + if (currentIndex < 4) currentIndex = 7 + this.previewZoomSetting = + Object.values(ZoomSetting)[ + Math.min(Object.values(ZoomSetting).length - 1, currentIndex + 1) + ] + } + + decreaseZoom(): void { + let currentIndex = Object.values(ZoomSetting).indexOf( + this.previewZoomSetting + ) + if (currentIndex < 4) currentIndex = 7 + this.previewZoomSetting = + Object.values(ZoomSetting)[Math.max(4, currentIndex - 1)] + } + + print(): void { + this.printService.print() + } + get showPermissions(): boolean { return ( this.permissionsService.currentUserCan( @@ -937,52 +992,4 @@ export class DocumentDetailComponent this.updateFormForCustomFields(true) this.documentForm.updateValueAndValidity() } - - onZoomSelect(event: Event) { - this.previewZoomSetting = (event.target as HTMLSelectElement) - ?.value as ZoomSetting - } - - get zoomSettings() { - return Object.values(ZoomSetting) - } - - getZoomSettingTitle(setting: ZoomSetting = null): string { - switch (setting) { - case ZoomSetting.Auto: - return $localize`Auto` - case ZoomSetting.Actual: - return $localize`Actual Size` - case ZoomSetting.Fit: - return $localize`Page Fit` - case ZoomSetting.Width: - return $localize`Page Width` - default: - return setting - } - } - - increaseZoom(): void { - let currentIndex = Object.values(ZoomSetting).indexOf( - this.previewZoomSetting - ) - if (currentIndex < 4) currentIndex = 7 - this.previewZoomSetting = - Object.values(ZoomSetting)[ - Math.min(Object.values(ZoomSetting).length - 1, currentIndex + 1) - ] - } - - decreaseZoom(): void { - let currentIndex = Object.values(ZoomSetting).indexOf( - this.previewZoomSetting - ) - if (currentIndex < 4) currentIndex = 7 - this.previewZoomSetting = - Object.values(ZoomSetting)[Math.max(4, currentIndex - 1)] - } - - print(): void { - this.printService.print() - } }