From 21b59d9a71e10deb7b566bc3dcde38e0992267a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 12 Jul 2021 15:16:35 +0300 Subject: [PATCH] Fixes --- .../pdf-viewer/pdf-viewer.component.ts | 53 +++++++------------ .../file-preview-screen.component.ts | 8 ++- .../modules/dossier/utils/pdf-viewer.utils.ts | 20 +++---- .../services/file-upload.service.ts | 4 +- apps/red-ui/src/assets/config/config.json | 4 +- .../src/assets/styles/red-page-layout.scss | 1 + 6 files changed, 40 insertions(+), 50 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts index 7bcd4e824..5876cb115 100644 --- a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts @@ -1,5 +1,4 @@ import { - AfterViewInit, Component, ElementRef, EventEmitter, @@ -70,9 +69,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { private readonly _annotationActionsService: AnnotationActionsService, private readonly _appConfigService: AppConfigService, private readonly _loadingService: LoadingService - ) { - console.log(1); - } + ) {} private _viewMode: ViewMode = 'STANDARD'; @@ -86,14 +83,12 @@ export class PdfViewerComponent implements OnInit, OnChanges { } async ngOnInit() { - console.log(2); this._documentLoaded = this._documentLoaded.bind(this); await this._loadViewer(); } ngOnChanges(changes: SimpleChanges): void { if (this.instance) { - console.log('instance'); if (changes.fileData) { this._loadDocument(); } @@ -101,11 +96,9 @@ export class PdfViewerComponent implements OnInit, OnChanges { this._handleCustomActions(); } if (changes.multiSelectActive) { - console.log(this.utils); this.utils.multiSelectActive = this.multiSelectActive; } } - console.log(3); } setInitialViewerState() { @@ -144,8 +137,8 @@ export class PdfViewerComponent implements OnInit, OnChanges { const compareDocumentPageCount = await compareDocument.getPageCount(); const loadCompareDocument = async () => { - console.log('loadingservice'); this._loadingService.start(); + this.utils.ready = false; await loadCompareDocumentWrapper( currentDocumentPageCount, compareDocumentPageCount, @@ -204,27 +197,23 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.utils.navigateToPage(1); } + private _convertPath(path: string): string { + return this._baseHref + path; + } + private async _loadViewer() { - console.log('loadingviewer'); this.instance = await WebViewer( { licenseKey: environment.licenseKey ? atob(environment.licenseKey) : null, fullAPI: true, - path: '/assets/wv-resources', - css: '/assets/pdftron/stylesheet.css', + path: this._convertPath('/assets/wv-resources'), + css: this._convertPath('/assets/pdftron/stylesheet.css'), backendType: 'ems' }, this.viewer.nativeElement ); - this.utils = new PdfViewerUtils( - this.instance, - this.viewMode, - this.multiSelectActive, - this._baseHref - ); - - console.log(this.utils); + this.utils = new PdfViewerUtils(this.instance, this.viewMode, this.multiSelectActive); this._setSelectionMode(); this._disableElements(); @@ -357,7 +346,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { type: 'toolGroupButton', toolGroup: 'rectangleTools', dataElement: 'shapeToolGroupButton', - img: this.utils.convertPath('/assets/icons/general/rectangle.svg'), + img: this._convertPath('/assets/icons/general/rectangle.svg'), title: 'annotation.rectangle' }); if (this._userPreferenceService.areDevFeaturesEnabled) { @@ -365,7 +354,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { type: 'actionButton', element: 'compare', dataElement: 'compareButton', - img: this.utils.convertPath('/assets/icons/general/pdftron-action-compare.svg'), + img: this._convertPath('/assets/icons/general/pdftron-action-compare.svg'), title: 'Compare', onClick: () => { this.compareFileInput.nativeElement.click(); @@ -375,7 +364,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { type: 'actionButton', element: 'closeCompare', dataElement: 'closeCompareButton', - img: this.utils.convertPath( + img: this._convertPath( '/assets/icons/general/pdftron-action-close-compare.svg' ), title: 'Leave Compare Mode', @@ -430,8 +419,8 @@ export class PdfViewerComponent implements OnInit, OnChanges { { type: 'actionButton', img: allAreVisible - ? this.utils.convertPath('/assets/icons/general/visibility-off.svg') - : this.utils.convertPath('/assets/icons/general/visibility.svg'), + ? this._convertPath('/assets/icons/general/visibility-off.svg') + : this._convertPath('/assets/icons/general/visibility.svg'), title: this._translateService.instant('annotation-actions.hide'), onClick: () => { this._ngZone.run(() => { @@ -459,7 +448,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.instance.annotationPopup.add({ type: 'actionButton', dataElement: 'add-rectangle', - img: this.utils.convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'), + img: this._convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'), title: this._translateService.instant( this._manualAnnotationService.getTitle('REDACTION') ), @@ -495,7 +484,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { private _configureTextPopup() { this.instance.textPopup.add({ type: 'actionButton', - img: this.utils.convertPath('/assets/icons/general/pdftron-action-search.svg'), + img: this._convertPath('/assets/icons/general/pdftron-action-search.svg'), title: this._translateService.instant('pdf-viewer.text-popup.actions.search'), onClick: () => { const text = this.instance.docViewer.getSelectedText(); @@ -519,9 +508,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.instance.textPopup.add({ type: 'actionButton', dataElement: 'add-false-positive', - img: this.utils.convertPath( - '/assets/icons/general/pdftron-action-false-positive.svg' - ), + img: this._convertPath('/assets/icons/general/pdftron-action-false-positive.svg'), title: this._translateService.instant( this._manualAnnotationService.getTitle('FALSE_POSITIVE') ), @@ -543,7 +530,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.instance.textPopup.add({ type: 'actionButton', dataElement: 'add-dictionary', - img: this.utils.convertPath('/assets/icons/general/pdftron-action-add-dict.svg'), + img: this._convertPath('/assets/icons/general/pdftron-action-add-dict.svg'), title: this._translateService.instant( this._manualAnnotationService.getTitle('DICTIONARY') ), @@ -564,7 +551,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.instance.textPopup.add({ type: 'actionButton', dataElement: 'add-redaction', - img: this.utils.convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'), + img: this._convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'), title: this._translateService.instant( this._manualAnnotationService.getTitle('REDACTION') ), @@ -644,8 +631,8 @@ export class PdfViewerComponent implements OnInit, OnChanges { } private _documentLoaded(): void { - console.log('document loaded'); this._ngZone.run(() => { + this.utils.ready = true; this.viewerReady.emit(this.instance); this.setInitialViewerState(); }); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 8322dddb3..5e84a15f5 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -270,7 +270,9 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, await this._userPreferenceControllerService .savePreferences([this.fileId], key) .toPromise(); - } catch (error) {} + } catch (error) { + console.error(error); + } this._subscribeToFileUpdates(); this.viewReady = true; @@ -289,7 +291,9 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, imported: true, force: true }); - } catch (error) {} + } catch (error) { + console.error(error); + } } console.log( '[REDACTION] Delete previous annotations time: ' + diff --git a/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts b/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts index 7cf4124f1..fac4cb793 100644 --- a/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts +++ b/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts @@ -40,18 +40,12 @@ const DISABLED_HOTKEYS = [ export class PdfViewerUtils { instance: WebViewerInstance; viewMode: ViewMode; + ready = false; multiSelectActive: boolean; - private readonly _baseHref: string; - constructor( - instance: WebViewerInstance, - viewMode: ViewMode, - multiSelectActive: boolean, - baseHref: string - ) { + constructor(instance: WebViewerInstance, viewMode: ViewMode, multiSelectActive: boolean) { this.instance = instance; this.viewMode = viewMode; - this._baseHref = baseHref; this.multiSelectActive = multiSelectActive; } @@ -69,16 +63,22 @@ export class PdfViewerUtils { ? Math.ceil(this.instance?.docViewer?.getCurrentPage() / 2) : this.instance?.docViewer?.getCurrentPage(); } catch (e) { + console.error(e); return null; } } get totalPages() { + if (!this.ready) { + return null; + } + try { return this.isCompareMode ? Math.ceil(this.instance?.docViewer?.getPageCount() / 2) : this.instance?.docViewer?.getPageCount(); } catch (e) { + console.error(e); return null; } } @@ -178,10 +178,6 @@ export class PdfViewerUtils { this.instance.annotManager.deselectAnnotations(ann); } - convertPath(path: string): string { - return this._baseHref + path; - } - private _getAnnotationById(id: string): Annotations.Annotation { return this.instance.annotManager.getAnnotationById(id); } diff --git a/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts b/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts index b820098fd..fda32a8d5 100644 --- a/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts +++ b/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts @@ -215,7 +215,9 @@ export class FileUploadService { if (subscription) { try { subscription.unsubscribe(); - } catch (e) {} + } catch (e) { + console.error(e); + } } this._activeUploads.splice(index, 1); this.activeUploads--; diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 4b001a0b1..6cfc820ed 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,6 +1,6 @@ { - "OAUTH_URL": "https://red-staging.iqser.cloud/auth/realms/redaction", - "API_URL": "https://red-staging.iqser.cloud/redaction-gateway-v1", + "OAUTH_URL": "https://dev-06.iqser.cloud/auth/realms/redaction", + "API_URL": "https://dev-06.iqser.cloud/redaction-gateway-v1", "OAUTH_CLIENT_ID": "redaction", "BACKEND_APP_VERSION": "4.4.40", "FRONTEND_APP_VERSION": "1.1", diff --git a/apps/red-ui/src/assets/styles/red-page-layout.scss b/apps/red-ui/src/assets/styles/red-page-layout.scss index 436dc08f1..5cd71d2de 100644 --- a/apps/red-ui/src/assets/styles/red-page-layout.scss +++ b/apps/red-ui/src/assets/styles/red-page-layout.scss @@ -301,6 +301,7 @@ section.settings { display: flex; align-items: center; justify-content: center; + margin: 0 50px; } .app-name {