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