RED-3988: fix current route params
This commit is contained in:
parent
78e49d609e
commit
0ae4729b8a
@ -1,5 +1,3 @@
|
||||
<ng-container *ngIf="state.dossierFileChange$ | async"></ng-container>
|
||||
|
||||
<ng-container *ngIf="state.dossier$ | async as dossier">
|
||||
<section *ngIf="file$ | async as file" [class.fullscreen]="fullScreen">
|
||||
<div class="page-header">
|
||||
@ -62,7 +60,9 @@
|
||||
<div class="overlay-shadow"></div>
|
||||
|
||||
<div class="content-inner">
|
||||
<div class="content-container"></div>
|
||||
<div class="content-container">
|
||||
<!-- Here comes PDF Viewer-->
|
||||
</div>
|
||||
|
||||
<div class="right-container">
|
||||
<iqser-empty-state
|
||||
|
||||
@ -10,7 +10,6 @@ import {
|
||||
ErrorService,
|
||||
FilterService,
|
||||
LoadingService,
|
||||
log,
|
||||
NestedFilter,
|
||||
OnAttach,
|
||||
OnDetach,
|
||||
@ -206,7 +205,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
this.#rebuildFilters();
|
||||
}
|
||||
|
||||
ngOnDetach(): void {
|
||||
async ngOnDetach() {
|
||||
await this._documentViewer.lock();
|
||||
this._documentViewer.close();
|
||||
super.ngOnDetach();
|
||||
this._changeDetectorRef.markForCheck();
|
||||
@ -535,10 +535,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
});
|
||||
|
||||
this.addActiveScreenSubscription = this.#textSelected$.subscribe();
|
||||
this.addActiveScreenSubscription = this.state.dossierFileChange$.subscribe();
|
||||
|
||||
this.addActiveScreenSubscription = this.state.blob$
|
||||
.pipe(
|
||||
log('Reload blob'),
|
||||
switchMap(blob => from(this._documentViewer.lock()).pipe(map(() => blob))),
|
||||
tap(() => this._errorService.clear()),
|
||||
tap(blob => this.pdf.loadDocument(blob, this.state.file)),
|
||||
@ -628,6 +628,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
private _navigateToDossier() {
|
||||
return this._router.navigate([this._dossiersService.find(this.dossierId)?.routerLink]);
|
||||
this._logger.info('Navigating to ', this.state.dossier.dossierName);
|
||||
return this._router.navigate([this.state.dossier.routerLink]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +246,6 @@ export class PdfProxyService {
|
||||
onClick: () => this._addManualRedactionOfType(ManualRedactionEntryTypes.DICTIONARY),
|
||||
});
|
||||
|
||||
console.log('configure popup');
|
||||
this._pdf.configureTextPopups(popups);
|
||||
|
||||
return this._handleCustomActions();
|
||||
|
||||
@ -4,9 +4,8 @@ import { hexToRgb } from '../../../utils';
|
||||
import { AnnotationWrapper } from '../../../models/file/annotation.wrapper';
|
||||
import { UserPreferenceService } from '../../../services/user-preference.service';
|
||||
import { RedactionLogService } from '../../../services/files/redaction-log.service';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
|
||||
import { DOSSIER_ID, FILE_ID, IRectangle, ISectionGrid, ISectionRectangle } from '@red/domain';
|
||||
import { IRectangle, ISectionGrid, ISectionRectangle } from '@red/domain';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { DictionariesMapService } from '../../../services/entity-services/dictionaries-map.service';
|
||||
import { SuperTypes } from '../../../models/file/super-types';
|
||||
@ -33,9 +32,14 @@ export class AnnotationDrawService {
|
||||
private readonly _documentViewer: REDDocumentViewer,
|
||||
) {}
|
||||
|
||||
draw(annotations: List<AnnotationWrapper>, dossierTemplateId: string, hideSkipped: boolean) {
|
||||
const licenseKey = environment.licenseKey ? atob(environment.licenseKey) : null;
|
||||
return this._pdf.PDFNet.runWithCleanup(() => this._draw(annotations, dossierTemplateId, hideSkipped), licenseKey);
|
||||
async draw(annotations: List<AnnotationWrapper>, dossierTemplateId: string, hideSkipped: boolean) {
|
||||
await this._documentViewer.lock();
|
||||
try {
|
||||
await this._draw(annotations, dossierTemplateId, hideSkipped);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
await this._documentViewer.unlock();
|
||||
}
|
||||
|
||||
getAndConvertColor(superType: string, dossierTemplateId: string, dictionary?: string) {
|
||||
@ -90,8 +94,7 @@ export class AnnotationDrawService {
|
||||
await this._pdf.annotationManager.drawAnnotationsFromList(annotations);
|
||||
|
||||
if (this._userPreferenceService.areDevFeaturesEnabled) {
|
||||
const dossierId = this._activatedRoute.snapshot.paramMap.get(DOSSIER_ID);
|
||||
const fileId = this._activatedRoute.snapshot.paramMap.get(FILE_ID);
|
||||
const { dossierId, fileId } = this._pdf;
|
||||
const sectionsGrid$ = this._redactionLogService.getSectionGrid(dossierId, fileId);
|
||||
const sectionsGrid = await firstValueFrom(sectionsGrid$).catch(() => ({ rectanglesPerPage: {} }));
|
||||
await this._drawSections(sectionsGrid, dossierTemplateId);
|
||||
|
||||
@ -119,6 +119,17 @@ export class REDDocumentViewer {
|
||||
return true;
|
||||
}
|
||||
|
||||
async unlock() {
|
||||
const document = await this.PDFDoc;
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await document.unlock();
|
||||
this._logger.info('[PDF] Unlocked');
|
||||
return true;
|
||||
}
|
||||
|
||||
setRectangleToolStyles(color: Color) {
|
||||
this.#document.getTool('AnnotationCreateRectangle').setStyles({
|
||||
StrokeThickness: 2,
|
||||
|
||||
@ -14,7 +14,6 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FilesService } from '../../../services/files/files.service';
|
||||
import { PdfViewer } from './pdf-viewer.service';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { FilesMapService } from '../../../services/files/files-map.service';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
|
||||
@ -27,7 +26,6 @@ export class PageRotationService {
|
||||
constructor(
|
||||
private readonly _pdf: PdfViewer,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _activatedRoute: ActivatedRoute,
|
||||
private readonly _logger: NGXLogger,
|
||||
private readonly _injector: Injector,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
@ -49,8 +47,7 @@ export class PageRotationService {
|
||||
applyRotation() {
|
||||
this._loadingService.start();
|
||||
const pages = this.#rotations$.value;
|
||||
const dossierId = this._activatedRoute.snapshot.paramMap.get('dossierId');
|
||||
const fileId = this._activatedRoute.snapshot.paramMap.get('fileId');
|
||||
const { dossierId, fileId } = this._pdf;
|
||||
|
||||
if (!dossierId || !fileId) {
|
||||
this._loadingService.stop();
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { Inject, Injectable, Injector } from '@angular/core';
|
||||
import WebViewer, { Core, WebViewerInstance, WebViewerOptions } from '@pdftron/webviewer';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { environment } from '@environments/environment';
|
||||
import { BASE_HREF_FN, BaseHrefFn } from '../../../tokens';
|
||||
import { File, IHeaderElement } from '@red/domain';
|
||||
import { ErrorService, shareDistinctLast, shareLast } from '@iqser/common-ui';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { distinctUntilChanged, map, startWith, tap } from 'rxjs/operators';
|
||||
import { BehaviorSubject, combineLatest, fromEvent, Observable } from 'rxjs';
|
||||
import { ConfigService } from '../../../services/config.service';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { DISABLED_HOTKEYS, DOCUMENT_LOADING_ERROR, SEARCH_OPTIONS, USELESS_ELEMENTS } from '../utils/constants';
|
||||
import { Rgb } from '../utils/types';
|
||||
@ -36,6 +36,8 @@ export class PdfViewer {
|
||||
* @deprecated Use REDAnnotationManager service instead
|
||||
*/
|
||||
annotationManager: AnnotationManager;
|
||||
fileId: string;
|
||||
dossierId: string;
|
||||
|
||||
pageChanged$: Observable<number>;
|
||||
compareMode$: Observable<boolean>;
|
||||
@ -138,6 +140,7 @@ export class PdfViewer {
|
||||
|
||||
async init(htmlElement: HTMLElement) {
|
||||
this.#instance = await this.#getInstance(htmlElement);
|
||||
await this.PDFNet.initialize(environment.licenseKey ? window.atob(environment.licenseKey) : null);
|
||||
this._logger.info('[PDF] Initialized');
|
||||
|
||||
this.documentViewer = this.#instance.Core.documentViewer;
|
||||
@ -171,18 +174,17 @@ export class PdfViewer {
|
||||
}
|
||||
|
||||
async loadDocument(blob: Blob, file: File) {
|
||||
this._logger.info('[PDF] Loading document', blob, file);
|
||||
const onError = () => {
|
||||
this._injector.get(ErrorService).set(DOCUMENT_LOADING_ERROR);
|
||||
this._logger.error('[PDF] Error while loading document');
|
||||
// this.stateService.reloadBlob();
|
||||
};
|
||||
|
||||
const pdfNet = this.#instance.Core.PDFNet;
|
||||
await pdfNet.initialize(environment.licenseKey ? window.atob(environment.licenseKey) : null);
|
||||
const document = await pdfNet.PDFDoc.createFromBuffer(await blob.arrayBuffer());
|
||||
const document = await this.PDFNet.PDFDoc.createFromBuffer(await blob.arrayBuffer());
|
||||
await document.flattenAnnotations(false);
|
||||
this.#currentBlob = blob;
|
||||
this.fileId = file.fileId;
|
||||
this.dossierId = file.dossierId;
|
||||
|
||||
this.#instance.UI.loadDocument(document, { filename: file?.filename + '.pdf' ?? 'document.pdf', onError });
|
||||
}
|
||||
|
||||
@ -8,13 +8,14 @@ export class LoggerRulesService extends NGXLoggerRulesService {
|
||||
if (message && typeof message === 'string') {
|
||||
const matches = message.match('\\[(.*?)\\]');
|
||||
|
||||
const firstMatch = matches[1]?.toUpperCase();
|
||||
|
||||
if (matches && matches.length > 0 && config.features[firstMatch]) {
|
||||
if (matches && matches.length > 0) {
|
||||
const firstMatch = matches[1]?.toUpperCase();
|
||||
const featureConfig = config.features[firstMatch];
|
||||
|
||||
if (!featureConfig.enabled || (featureConfig.level && featureConfig?.level < config.level)) {
|
||||
return false;
|
||||
if (featureConfig) {
|
||||
if (!featureConfig.enabled || (featureConfig.level && featureConfig.level < config.level)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user