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();
} catch (e) {
this._toaster.error(_('file-preview.tabs.exclude-pages.error'));
this._loadingService.stop();
}
this._loadingService.stop();
}
async includePagesRange(range: IPageRange): Promise<void> {
@ -87,5 +87,6 @@ export class PageExclusionComponent implements OnChanges {
.toPromise();
this._inputComponent.reset();
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 { DossiersService } from '@services/entity-services/dossiers.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 { WatermarkService } from '@shared/services/watermark.service';
import { ExcludedPagesService } from './services/excluded-pages.service';
@ -409,6 +409,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
await this._stampPDF();
await this._cleanupAndRedrawManualAnnotations$().toPromise();
this._instance.Core.documentViewer.addEventListener('pageNumberUpdated', () => {
this._setExcludedPageStyles();
});
// Go to initial page from query params
const pageNumber = this._lastPage || this._activatedRoute.snapshot.queryParams.page;
if (pageNumber) {
@ -459,6 +463,21 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
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> {
await this._loadFileData(file, true);
await this._cleanupAndRedrawManualAnnotations$().toPromise();
@ -523,14 +542,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
document,
this._instance.Core.PDFNet,
this._translateService.instant('file-preview.excluded-from-redaction'),
25,
17,
'courier',
'DIAGONAL',
33,
'#283241',
'TOP_LEFT',
50,
'#dd4d50',
excludedPages,
);
}
this._setExcludedPageStyles();
}
private _subscribeToFileUpdates(): void {

View File

@ -42,7 +42,7 @@ export async function stampPDFPage(
text: string,
fontSize: number,
fontType: string,
orientation: 'DIAGONAL' | 'HORIZONTAL' | 'VERTICAL',
orientation: 'DIAGONAL' | 'HORIZONTAL' | 'VERTICAL' | 'TOP_LEFT',
opacity: number,
color: string,
pages: number[],
@ -67,6 +67,11 @@ export async function stampPDFPage(
break;
case 'HORIZONTAL':
break;
case 'TOP_LEFT':
await stamper.setAlignment(-1, 1);
await stamper.setRotation(90);
await stamper.setPosition(20, 20);
break;
case 'DIAGONAL':
default:
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.",
"download-original-file": "Download Original File",
"exclude-pages": "Exclude pages from redaction",
"excluded-from-redaction": "excluded from automatic redaction",
"excluded-from-redaction": "excluded",
"fullscreen": "Full Screen (F)",
"last-reviewer": "Last Reviewed by:",
"no-data": {

View File

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