RED-2833: Excluded page watermark update

This commit is contained in:
Adina Țeudan 2021-11-26 19:48:12 +02:00
parent 59014c4dd0
commit 33d07f304b
5 changed files with 38 additions and 8 deletions

View File

@ -70,8 +70,8 @@ export class PageExclusionComponent implements OnChanges {
this.excludedPagesService.toggle(); this.excludedPagesService.toggle();
} catch (e) { } catch (e) {
this._toaster.error(_('file-preview.tabs.exclude-pages.error')); this._toaster.error(_('file-preview.tabs.exclude-pages.error'));
this._loadingService.stop();
} }
this._loadingService.stop();
} }
async includePagesRange(range: IPageRange): Promise<void> { async includePagesRange(range: IPageRange): Promise<void> {
@ -87,5 +87,6 @@ export class PageExclusionComponent implements OnChanges {
.toPromise(); .toPromise();
this._inputComponent.reset(); this._inputComponent.reset();
this.excludedPagesService.toggle(); this.excludedPagesService.toggle();
this._loadingService.stop();
} }
} }

View File

@ -48,7 +48,7 @@ import { FileActionsComponent } from '../../shared/components/file-actions/file-
import { FilesService } from '@services/entity-services/files.service'; import { FilesService } from '@services/entity-services/files.service';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import { FileManagementService } from '@services/entity-services/file-management.service'; import { FileManagementService } from '@services/entity-services/file-management.service';
import { filter, map, switchMap, switchMapTo, tap } from 'rxjs/operators'; import { filter, map, switchMap, tap } from 'rxjs/operators';
import { FilesMapService } from '@services/entity-services/files-map.service'; import { FilesMapService } from '@services/entity-services/files-map.service';
import { WatermarkService } from '@shared/services/watermark.service'; import { WatermarkService } from '@shared/services/watermark.service';
import { ExcludedPagesService } from './services/excluded-pages.service'; import { ExcludedPagesService } from './services/excluded-pages.service';
@ -409,6 +409,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
await this._stampPDF(); await this._stampPDF();
await this._cleanupAndRedrawManualAnnotations$().toPromise(); await this._cleanupAndRedrawManualAnnotations$().toPromise();
this._instance.Core.documentViewer.addEventListener('pageNumberUpdated', () => {
this._setExcludedPageStyles();
});
// Go to initial page from query params // Go to initial page from query params
const pageNumber = this._lastPage || this._activatedRoute.snapshot.queryParams.page; const pageNumber = this._lastPage || this._activatedRoute.snapshot.queryParams.page;
if (pageNumber) { if (pageNumber) {
@ -459,6 +463,21 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
return false; return false;
} }
private _setExcludedPageStyles() {
const file = this._filesMapService.get(this.dossierId, this.fileId);
setTimeout(() => {
const iframeDoc = this._instance.UI.iframeWindow.document;
const pageContainer = iframeDoc.getElementById(`pageWidgetContainer${this.activeViewerPage}`);
if (pageContainer) {
if (file.excludedPages.includes(this.activeViewerPage)) {
pageContainer.classList.add('excluded-page');
} else {
pageContainer.classList.remove('excluded-page');
}
}
}, 100);
}
private async _reloadFile(file: File): Promise<void> { private async _reloadFile(file: File): Promise<void> {
await this._loadFileData(file, true); await this._loadFileData(file, true);
await this._cleanupAndRedrawManualAnnotations$().toPromise(); await this._cleanupAndRedrawManualAnnotations$().toPromise();
@ -523,14 +542,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
document, document,
this._instance.Core.PDFNet, this._instance.Core.PDFNet,
this._translateService.instant('file-preview.excluded-from-redaction'), this._translateService.instant('file-preview.excluded-from-redaction'),
25, 17,
'courier', 'courier',
'DIAGONAL', 'TOP_LEFT',
33, 50,
'#283241', '#dd4d50',
excludedPages, excludedPages,
); );
} }
this._setExcludedPageStyles();
} }
private _subscribeToFileUpdates(): void { private _subscribeToFileUpdates(): void {

View File

@ -42,7 +42,7 @@ export async function stampPDFPage(
text: string, text: string,
fontSize: number, fontSize: number,
fontType: string, fontType: string,
orientation: 'DIAGONAL' | 'HORIZONTAL' | 'VERTICAL', orientation: 'DIAGONAL' | 'HORIZONTAL' | 'VERTICAL' | 'TOP_LEFT',
opacity: number, opacity: number,
color: string, color: string,
pages: number[], pages: number[],
@ -67,6 +67,11 @@ export async function stampPDFPage(
break; break;
case 'HORIZONTAL': case 'HORIZONTAL':
break; break;
case 'TOP_LEFT':
await stamper.setAlignment(-1, 1);
await stamper.setRotation(90);
await stamper.setPosition(20, 20);
break;
case 'DIAGONAL': case 'DIAGONAL':
default: default:
await stamper.setAlignment(0, 0); await stamper.setAlignment(0, 0);

View File

@ -1032,7 +1032,7 @@
"document-info": "Your Document Info lives here. This includes metadata required on each document.", "document-info": "Your Document Info lives here. This includes metadata required on each document.",
"download-original-file": "Download Original File", "download-original-file": "Download Original File",
"exclude-pages": "Exclude pages from redaction", "exclude-pages": "Exclude pages from redaction",
"excluded-from-redaction": "excluded from automatic redaction", "excluded-from-redaction": "excluded",
"fullscreen": "Full Screen (F)", "fullscreen": "Full Screen (F)",
"last-reviewer": "Last Reviewed by:", "last-reviewer": "Last Reviewed by:",
"no-data": { "no-data": {

View File

@ -33,3 +33,7 @@
.Popup .Button img { .Popup .Button img {
width: 18px; width: 18px;
} }
.excluded-page {
border: 2px solid #dd4d5080;
}