From 1edab7c304432ecdb072ff553e8e5ca936e56759 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 20 May 2022 13:26:01 +0300 Subject: [PATCH] RED-3988: remove old pdf viewer stuff --- apps/red-ui/src/app/app.component.html | 4 +- apps/red-ui/src/app/app.component.ts | 4 +- apps/red-ui/src/app/app.module.ts | 4 +- .../annotations-list.component.ts | 9 +- .../file-workload/file-workload.component.ts | 36 +++--- .../pdf-paginator.component.html} | 14 +-- .../pdf-paginator.component.scss} | 0 .../pdf-paginator.component.ts} | 45 ++++---- .../file-preview/file-preview-providers.ts | 5 +- .../file-preview-screen.component.html | 2 +- .../file-preview-screen.component.ts | 24 ++-- .../file-preview/file-preview.module.ts | 4 +- .../services/annotation-actions.service.ts | 32 +++--- .../services/annotation-draw.service.ts | 36 +++--- .../services/annotations-listing.service.ts | 42 +++++++ .../services/page-rotation.service.ts | 10 +- .../services/pdf-viewer.service.ts | 103 ------------------ .../file-preview/services/stamp.service.ts | 17 ++- .../file-preview/services/tooltips.service.ts | 8 +- .../services/viewer-header-config.service.ts | 16 ++- ...r.component.ts => pdf-viewer.component.ts} | 10 +- ...iewer.service.ts => pdf-viewer.service.ts} | 78 ++++++++++--- libs/red-domain/src/lib/files/file.model.ts | 4 + 23 files changed, 242 insertions(+), 265 deletions(-) rename apps/red-ui/src/app/modules/file-preview/components/{pdf-viewer/pdf-viewer.component.html => pdf-paginator/pdf-paginator.component.html} (57%) rename apps/red-ui/src/app/modules/file-preview/components/{pdf-viewer/pdf-viewer.component.scss => pdf-paginator/pdf-paginator.component.scss} (100%) rename apps/red-ui/src/app/modules/file-preview/components/{pdf-viewer/pdf-viewer.component.ts => pdf-paginator/pdf-paginator.component.ts} (93%) delete mode 100644 apps/red-ui/src/app/modules/file-preview/services/pdf-viewer.service.ts rename apps/red-ui/src/app/modules/shared/components/reusable-pdf-viewer/{reusable-pdf-viewer.component.ts => pdf-viewer.component.ts} (67%) rename apps/red-ui/src/app/modules/shared/components/reusable-pdf-viewer/{reusable-pdf-viewer.service.ts => pdf-viewer.service.ts} (73%) diff --git a/apps/red-ui/src/app/app.component.html b/apps/red-ui/src/app/app.component.html index 682af5b9b..00bfde5e4 100644 --- a/apps/red-ui/src/app/app.component.html +++ b/apps/red-ui/src/app/app.component.html @@ -1,8 +1,6 @@ - + diff --git a/apps/red-ui/src/app/app.component.ts b/apps/red-ui/src/app/app.component.ts index d63edc783..73a852ee1 100644 --- a/apps/red-ui/src/app/app.component.ts +++ b/apps/red-ui/src/app/app.component.ts @@ -1,7 +1,7 @@ import { Component, ViewContainerRef } from '@angular/core'; import { RouterHistoryService } from '@services/router-history.service'; import { UserService } from '@services/user.service'; -import { ReusablePdfViewer } from './modules/shared/components/reusable-pdf-viewer/reusable-pdf-viewer.service'; +import { PdfViewer } from '@shared/components/reusable-pdf-viewer/pdf-viewer.service'; @Component({ selector: 'redaction-root', @@ -15,6 +15,6 @@ export class AppComponent { public viewContainerRef: ViewContainerRef, private readonly _routerHistoryService: RouterHistoryService, private readonly _userService: UserService, - readonly reusablePdfViewer: ReusablePdfViewer, + readonly pdf: PdfViewer, ) {} } diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index 21308feca..ae1fcb6f4 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -52,7 +52,7 @@ import { LoggerModule, NgxLoggerLevel, TOKEN_LOGGER_CONFIG, TOKEN_LOGGER_RULES_S import { LoggerRulesService } from '@services/logger-rules.service'; import { ILoggerConfig } from '@red/domain'; import { SystemPreferencesService } from '@services/system-preferences.service'; -import { ReusablePdfViewerComponent } from './modules/shared/components/reusable-pdf-viewer/reusable-pdf-viewer.component'; +import { PdfViewerComponent } from '@shared/components/reusable-pdf-viewer/pdf-viewer.component'; export function httpLoaderFactory(httpClient: HttpClient, configService: ConfigService): PruningTranslationLoader { return new PruningTranslationLoader(httpClient, '/assets/i18n/', `.json?version=${configService.values.FRONTEND_APP_VERSION}`); @@ -72,7 +72,7 @@ const screens = [BaseScreenComponent, DownloadsListScreenComponent]; const components = [ AppComponent, - ReusablePdfViewerComponent, + PdfViewerComponent, AuthErrorComponent, NotificationsComponent, SpotlightSearchComponent, diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts index de46fc867..d0621b5b9 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts @@ -10,15 +10,15 @@ import { TemplateRef, } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { FilterService, HasScrollbarDirective, IqserEventTarget, ListingService } from '@iqser/common-ui'; +import { FilterService, HasScrollbarDirective, IqserEventTarget } from '@iqser/common-ui'; import { MultiSelectService } from '../../services/multi-select.service'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { UserPreferenceService } from '@services/user-preference.service'; import { ViewModeService } from '../../services/view-mode.service'; import { BehaviorSubject } from 'rxjs'; import { TextHighlightsGroup } from '@red/domain'; -import { PdfViewer } from '../../services/pdf-viewer.service'; import { REDAnnotationManager } from '../../../shared/components/reusable-pdf-viewer/annotation-manager.service'; +import { AnnotationsListingService } from '../../services/annotations-listing.service'; @Component({ selector: 'redaction-annotations-list', @@ -41,9 +41,8 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O private readonly _filterService: FilterService, private readonly _userPreferenceService: UserPreferenceService, private readonly _viewModeService: ViewModeService, - private readonly _pdf: PdfViewer, private readonly _annotationManager: REDAnnotationManager, - private readonly _listingService: ListingService, + private readonly _listingService: AnnotationsListingService, readonly annotationReferencesService: AnnotationReferencesService, ) { super(_elementRef, _changeDetector); @@ -77,7 +76,7 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O if (canMultiSelect && ($event?.ctrlKey || $event?.metaKey) && this._listingService.selected.length > 0) { this._multiSelectService.activate(); } - this._pdf.selectAnnotations([annotation]); + this._listingService.selectAnnotations([annotation]); } } diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index 01942f2c1..9b3ddd6f0 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -21,7 +21,6 @@ import { IconButtonTypes, INestedFilter, IqserEventTarget, - ListingService, shareDistinctLast, shareLast, } from '@iqser/common-ui'; @@ -36,9 +35,9 @@ import { FilePreviewStateService } from '../../services/file-preview-state.servi import { ViewModeService } from '../../services/view-mode.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { FileDataService } from '../../services/file-data.service'; -import { PdfViewer } from '../../services/pdf-viewer.service'; -import { ReusablePdfViewer } from '../../../shared/components/reusable-pdf-viewer/reusable-pdf-viewer.service'; +import { PdfViewer } from '../../../shared/components/reusable-pdf-viewer/pdf-viewer.service'; import { REDAnnotationManager } from '../../../shared/components/reusable-pdf-viewer/annotation-manager.service'; +import { AnnotationsListingService } from '../../services/annotations-listing.service'; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -73,19 +72,18 @@ export class FileWorkloadComponent { readonly filterService: FilterService, readonly skippedService: SkippedService, readonly state: FilePreviewStateService, - readonly multiSelectService: MultiSelectService, - readonly documentInfoService: DocumentInfoService, - readonly excludedPagesService: ExcludedPagesService, + readonly pdf: PdfViewer, readonly fileDataService: FileDataService, readonly viewModeService: ViewModeService, - readonly listingService: ListingService, - readonly pdf: PdfViewer, - readonly reusablePdf: ReusablePdfViewer, + readonly multiSelectService: MultiSelectService, readonly annotationManager: REDAnnotationManager, + readonly documentInfoService: DocumentInfoService, + readonly listingService: AnnotationsListingService, + readonly excludedPagesService: ExcludedPagesService, private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _annotationProcessingService: AnnotationProcessingService, ) { - this.reusablePdf.currentPage$.pipe(takeWhile(() => !!this)).subscribe(pageNumber => { + this.pdf.currentPage$.pipe(takeWhile(() => !!this)).subscribe(pageNumber => { this._scrollViews(); this.scrollAnnotationsToPage(pageNumber, 'always'); }); @@ -183,7 +181,7 @@ export class FileWorkloadComponent { } selectAllOnActivePage() { - this.pdf.selectAnnotations(this.activeAnnotations); + this.listingService.selectAnnotations(this.activeAnnotations); } deselectAllOnActivePage(): void { @@ -295,19 +293,19 @@ export class FileWorkloadComponent { if (!this._firstSelectedAnnotation || this.activeViewerPage !== this._firstSelectedAnnotation.pageNumber) { if (this.displayedPages.indexOf(this.activeViewerPage) !== -1) { // Displayed page has annotations - return this.pdf.selectAnnotations(this.activeAnnotations ? [this.activeAnnotations[0]] : null); + return this.listingService.selectAnnotations(this.activeAnnotations ? [this.activeAnnotations[0]] : null); } // Displayed page doesn't have annotations if ($event.key === 'ArrowDown') { const nextPage = this._nextPageWithAnnotations(); - return this.pdf.selectAnnotations([this.displayedAnnotations.get(nextPage)[0]]); + return this.listingService.selectAnnotations([this.displayedAnnotations.get(nextPage)[0]]); } const prevPage = this._prevPageWithAnnotations(); const prevPageAnnotations = this.displayedAnnotations.get(prevPage); - return this.pdf.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]); + return this.listingService.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]); } const page = this._firstSelectedAnnotation.pageNumber; @@ -320,13 +318,13 @@ export class FileWorkloadComponent { if ($event.key === 'ArrowDown') { if (idx + 1 !== annotationsOnPage.length) { // If not last item in page - this.pdf.selectAnnotations([annotationsOnPage[idx + 1]]); + this.listingService.selectAnnotations([annotationsOnPage[idx + 1]]); } else if (nextPageIdx < this.displayedPages.length) { // If not last page for (let i = nextPageIdx; i < this.displayedPages.length; i++) { const nextPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]); if (nextPageAnnotations) { - this.pdf.selectAnnotations([nextPageAnnotations[0]]); + this.listingService.selectAnnotations([nextPageAnnotations[0]]); break; } } @@ -336,7 +334,7 @@ export class FileWorkloadComponent { if (idx !== 0) { // If not first item in page - return this.pdf.selectAnnotations([annotationsOnPage[idx - 1]]); + return this.listingService.selectAnnotations([annotationsOnPage[idx - 1]]); } if (pageIdx) { @@ -344,7 +342,7 @@ export class FileWorkloadComponent { for (let i = previousPageIdx; i >= 0; i--) { const prevPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]); if (prevPageAnnotations) { - this.pdf.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]); + this.listingService.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]); break; } } @@ -398,7 +396,7 @@ export class FileWorkloadComponent { this.displayedPages.indexOf(this.activeViewerPage) >= 0 && this.activeAnnotations.length > 0 ) { - this.pdf.selectAnnotations([this.activeAnnotations[0]]); + this.listingService.selectAnnotations([this.activeAnnotations[0]]); } } diff --git a/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.html b/apps/red-ui/src/app/modules/file-preview/components/pdf-paginator/pdf-paginator.component.html similarity index 57% rename from apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.html rename to apps/red-ui/src/app/modules/file-preview/components/pdf-paginator/pdf-paginator.component.html index 969536f81..87b500f04 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/pdf-paginator/pdf-paginator.component.html @@ -1,16 +1,16 @@ -