diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index 313842c455f5caeb2106008ff6f1017340c7a0ba..310df0ab167d4e9d7551dda91e79218305bc75e7 100755 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -20,13 +20,16 @@ import { SignaturesComponent } from './signatures/signatures.component'; import { SignaturePadPageComponent } from './pad/pad.component'; import { SignaturePadModule } from 'angular2-signaturepad'; import { DrawerComponent } from './drawer/drawer.component'; -import { DocumentComponent, - WarnModalComponent, - ConfirmModalComponent, - SuccessInfoValidBottomSheetComponent, - RejectInfoBottomSheetComponent } from './document/document.component'; +import { DocumentComponent } from './document/document.component'; +import { DocumentSignListComponent } from './documentSignList/document-sign-list.component'; +import { DocumentNoteListComponent } from './documentNoteList/document-note-list.component'; +import { DocumentNotePadComponent } from './documentNotePad/document-note-pad.component'; import { SidebarComponent } from './sidebar/sidebar.component'; import { ProfileComponent } from './profile/profile.component'; +import { ConfirmModalComponent } from './modal/confirm-modal.component'; +import { WarnModalComponent } from './modal/warn-modal.component'; +import { SuccessInfoValidBottomSheetComponent } from './modal/success-info-valid.component'; +import { RejectInfoBottomSheetComponent } from './modal/reject-info.component'; // SERVICES import { NotificationService, CustomSnackbarComponent } from './service/notification.service'; @@ -42,6 +45,9 @@ import { SignaturesContentService } from './service/signatures.service'; SignaturePadPageComponent, DrawerComponent, DocumentComponent, + DocumentSignListComponent, + DocumentNoteListComponent, + DocumentNotePadComponent, SidebarComponent, WarnModalComponent, ConfirmModalComponent, diff --git a/src/frontend/app/document/document.component.html b/src/frontend/app/document/document.component.html index a44025c8dd0076d5d7324c0709e94c8764ecc701..4241615b79c4c1c87afd6a2d66315efe82c5df88 100755 --- a/src/frontend/app/document/document.component.html +++ b/src/frontend/app/document/document.component.html @@ -43,32 +43,6 @@ </section> </article> </header> - <div *ngIf="signaturesService.lockNote"> - <span style="z-index:1;position: fixed;bottom: 10px;top: 10px;font-size: 25px;height:50px;"> - <button class="btn blue" (tap)="cancelAnnotation(i);"><i - class="fas fa-arrow-left fa-2x"></i>Quitter l'annotation</button> - </span> - <span *ngIf="!lockSignaturePad" style="z-index:1;position: fixed;top: 10px;left: 50%;transform: translateX(-50%);font-size: 25px;"> - <button class="btn red" (tap)="test();"><i - class="fas fa-lock fa-2x"></i>Vérouiller la zone de travaille</button> - </span> - <span *ngIf="lockSignaturePad" style="z-index:1;position: fixed;top: 10px;left: 50%;transform: translateX(-50%);font-size: 25px;"> - <button class="btn green" (tap)="test();"><i - class="fas fa-lock fa-2x"></i>Dévérouiller la zone de travaille</button> - </span> - <span *ngIf="scale==1" style="z-index:1;position: fixed;top: 10px;right: 0;font-size: 25px;"> - <button class="btn blue" (tap)="zoomPlus();"><i - class="fas fa-plus fa-2x"></i>Zoomer</button> - </span> - <span *ngIf="scale==2" style="z-index:1;position: fixed;top: 10px;right: 0px;font-size: 25px;"> - <button class="btn blue" (tap)="zoomMinus();"><i - class="fas fa-plus fa-2x"></i>Dézoomer</button> - </span> - <span style="z-index:1;position: fixed;bottom: 10px;left: 50%;transform: translateX(-50%);font-size: 25px;"> - <button class="btn green" (click)="$event.stopPropagation();validateAnnotation();"><i - class="fas fa-check-circle fa-2x"></i>Valider l'annotation</button> - </span> - </div> <article class="article" #article *ngIf="!freezeSidenavClose"> <button class="btn-previous" (click)="prevPage()" *ngIf="pageNum > 1 && !this.signaturesService.annotationMode"><i class="fas fa-chevron-left fa-3x"></i></button> @@ -79,66 +53,18 @@ <button class="btn-next" (click)="nextDoc()" *ngIf="pageNum == totalPages && docList.length > currentDoc+1 && !this.signaturesService.annotationMode"><i class="fas fa-chevron-right fa-3x"></i><i class="fas fa-chevron-right fa-3x"></i></button> <div [ngClass]="{'overlay': (annotation$ | async)}"></div> - <div [style.width.px]="768*scale" class="canvas-wrapper" #canvasWrapper> + <div [style.width.px]="768*signaturesService.scale" class="canvas-wrapper" #canvasWrapper> <pdf-viewer [ngClass]="{ 'pdf-page-canvas':!renderingDoc, 'pdf-page-canvas-loading-doc':renderingDoc - }" [src]="pdfDataArr" [render-text]="false" [zoom]="scale" [show-all]="false" [(page)]="pageNum" [original-size]="false" style="display: block;" (after-load-complete)="pdfRendered($event)" (page-rendered)="pageRendered($event)" (click)="addAnnotation($event)"></pdf-viewer> + }" [src]="pdfDataArr" [render-text]="false" [zoom]="signaturesService.scale" [show-all]="false" [(page)]="pageNum" [original-size]="false" style="display: block;" (after-load-complete)="pdfRendered($event)" (page-rendered)="pageRendered($event)" (click)="addAnnotation($event)"></pdf-viewer> <ng-container *ngIf="currentDoc == 0"> - <ng-container *ngFor="let note of this.signaturesService.notesContent[this.signaturesService.currentPage];let i = index;"> - <div style="top:0;left:0;position: absolute;" [ngClass]="{ - 'pdf-page-canvas':!renderingDoc, - 'pdf-page-canvas-loading-doc':renderingDoc - }"> - <img [style.width.px]="note.width*scale" [src]="sanitization.bypassSecurityTrustUrl(note.fullPath)" (click)="addAnnotation($event)"> - </div> - </ng-container> - <ng-container *ngFor="let signature of this.signaturesService.signaturesContent[this.signaturesService.currentPage];let i = index;"> - - <div [position]="{'x': signature.positionX*scale, 'y': signature.positionY*scale}" id="signaturesContent" - style="top:0;left:0;position: absolute;border: dashed 1px grey;background: rgba(255, 255, 255, 0.6) none repeat scroll 0% 0%;" ngDraggable preventDefaultEvent="true" [bounds]="canvas" - inBounds="true" (endOffset)="moveSign($event,i)" [ngClass]="{ - 'pdf-page-canvas':!renderingDoc, - 'pdf-page-canvas-loading-doc':renderingDoc - }"> - <button (tap)="openMenu(menuTrigger)" mat-icon-button #menuTrigger="matMenuTrigger" [matMenuTriggerFor]="menu" style="right: 0;position: absolute;color:#F99830;"> - <mat-icon fontSet="fas" fontIcon="fa-ellipsis-v"></mat-icon> - </button> - <mat-menu #menu="matMenu"> - <button mat-menu-item (click)="$event.stopPropagation();deleteSignature(i);"> - <mat-icon fontSet="fas" fontIcon="fa-times"></mat-icon> - <span>Supprimer la signature</span> - </button> - <button [disabled]="signature.inAllPage" mat-menu-item (click)="$event.stopPropagation();cloneSign(i);"> - <mat-icon fontSet="fas" fontIcon="fa-clone"></mat-icon> - <span>Cloner la signature</span> - </button> - </mat-menu> - <img [src]="sanitization.bypassSecurityTrustUrl('data:image/png;base64,' + signature.encodedSignature)" - [style.width.px]="this.signaturesService.signWidth"> - </div> - </ng-container> + + <app-document-note-list (triggerEvent)="addAnnotation($event)"></app-document-note-list> + <app-document-sign-list [canvas]="canvasWrapper"></app-document-sign-list> + + <app-document-note-pad [pageNum]="pageNum" #appDocumentNotePad></app-document-note-pad> - <div *ngIf="signaturesService.lockNote" [style.width.px]="this.signaturesService.workingAreaWidth" [style.height.px]="this.signaturesService.workingAreaHeight" style="top:0;position: absolute;border: dashed 1px grey;overflow: hidden;" [ngClass]="{ - 'pdf-page-canvas':!renderingDoc, - 'pdf-page-canvas-loading-doc':renderingDoc - }"> - <div class="tool-content tool-content-left"> - <input type="range" name="dot" min="1" max="10" step="1" value="1" (input)="onDotChange($event.target.value)" - class="range"> - <i class="fas fa-pen-nib"></i> - </div> - <div class="tool-content tool-content-right"> - <ng-container *ngFor="let color of penColors" let idx="index"> - <input type="radio" name="colors" [checked]="idx === 0" [value]="color.id" (change)="onColorChange(color)" - class="radio" [ngStyle]="{'border-color': color.id, 'background-color': color.id}"> - </ng-container> - <hr> - <i class="fa fa-undo fa-2x undo" (click)="undo()"></i> - </div> - <signature-pad id="notePad" [options]="annotationPadOptions"></signature-pad> - <div *ngIf="lockSignaturePad" style="background: #ffffffb3;position: absolute;top: 0;left: 0;width: 100%;height: 100%;"></div> - </div> </ng-container> </div> <div class="page-under"> diff --git a/src/frontend/app/document/document.component.scss b/src/frontend/app/document/document.component.scss index 16f604aaf22c7bbcfea776df304b1a9a80d4480e..eb0ca95145fa0db336fcc4a90bb17cc2c886e6b6 100644 --- a/src/frontend/app/document/document.component.scss +++ b/src/frontend/app/document/document.component.scss @@ -190,23 +190,6 @@ button.disabled { background: rgba(0, 0, 0, 0.5); } -.radio { - appearance: none; - position: relative; - margin: 5px; - width: 30px; - height: 30px; - border-radius: 30px; - border-width: none; - border-style: solid; - outline: none; - cursor: pointer; - transition: all 0.2s; - &:checked, &:hover { - transform: scale(1.5); - } -} - .pdf-page-canvas { opacity: 1; transition: 0.5s opacity ease-in; @@ -222,28 +205,3 @@ button.disabled { overflow: hidden; text-overflow: ellipsis; } - -.tool-content { - display: flex; - position: fixed; - background: #8080804d; - border-radius: 20px; - top: 170px; - transform: translateY(-50%) rotate(-90deg); - padding: 10px; - &-left { - left: -40px; - } - &-right { - right: -40px; - } -} - -.undo { - cursor: pointer; - transform: rotate(90deg); - transition: all 0.2s; - &:active { - transform: rotate(90deg) scale(1.5); - } -} diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index c934268039cecd41ef662749e14b8b38651a7aea..c0d2ed90e294f7da165e4af95399b148fbf5c7ad 100755 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -1,19 +1,7 @@ import { Component, OnInit, ViewChild, ElementRef, Input, Inject } from '@angular/core'; import { SignaturesContentService } from '../service/signatures.service'; import { DomSanitizer } from '@angular/platform-browser'; -import * as $ from 'jquery'; -import { SignaturePad } from 'angular2-signaturepad/signature-pad'; -import { - MatDialogRef, - MatDialog, - MAT_DIALOG_DATA, - MatBottomSheet, - MatBottomSheetRef, - MatBottomSheetConfig, - MatSidenav, - MatMenuTrigger, - MatMenu -} from '@angular/material'; +import { MatDialog, MatBottomSheet, MatBottomSheetConfig, MatSidenav } from '@angular/material'; import { SignaturesComponent } from '../signatures/signatures.component'; import { ActivatedRoute, Router } from '@angular/router'; import { HttpClient } from '@angular/common/http'; @@ -21,6 +9,11 @@ import { NotificationService } from '../service/notification.service'; import { trigger, transition, style, animate } from '@angular/animations'; import { PDFDocumentProxy } from 'ng2-pdf-viewer'; import { CookieService } from 'ngx-cookie-service'; +import { DocumentNotePadComponent } from '../documentNotePad/document-note-pad.component'; +import { WarnModalComponent } from '../modal/warn-modal.component'; +import { RejectInfoBottomSheetComponent } from '../modal/reject-info.component'; +import { ConfirmModalComponent } from '../modal/confirm-modal.component'; +import { SuccessInfoValidBottomSheetComponent } from '../modal/success-info-valid.component'; @Component({ @@ -77,28 +70,16 @@ export class DocumentComponent implements OnInit { loadingPage = true; pageNum = 1; signaturesContent: any = []; - scale = 1; totalPages: number; draggable: boolean; loadingDoc = true; - renderingDoc = true; signaturePadPosX = 0; signaturePadPosY = 50; currentDoc = 0; docList: any = []; actionsList: any = []; - lockSignaturePad = false; pdfDataArr: any; - annotationPadOptions = { - throttle: 0, - minWidth: 1, - maxWidth: 2.5, - backgroundColor: 'rgba(255, 255, 255, 0)', - canvasWidth: 768, - canvasHeight: 270 - }; freezeSidenavClose = false; - penColors = [{ id: 'black' }, { id: '#1a75ff' }, { id: '#FF0000' }]; @Input() mainDocument: any = {}; @@ -106,8 +87,8 @@ export class DocumentComponent implements OnInit { @ViewChild('snavRight') snavRight: MatSidenav; @ViewChild('canvas') canvas: ElementRef; @ViewChild('canvasWrapper') canvasWrapper: ElementRef; - @ViewChild('menuTrigger') menuSign: MatMenuTrigger; - @ViewChild(SignaturePad) signaturePad: SignaturePad; + + @ViewChild('appDocumentNotePad') appDocumentNotePad: DocumentNotePadComponent; constructor(private router: Router, private route: ActivatedRoute, public http: HttpClient, @@ -127,7 +108,7 @@ export class DocumentComponent implements OnInit { }, 500); this.route.params.subscribe(params => { if (typeof params['id'] !== 'undefined') { - this.renderingDoc = true; + this.signaturesService.renderingDoc = true; this.loadingDoc = true; this.http.get('../rest/documents/' + params['id']) .subscribe((data: any) => { @@ -151,7 +132,7 @@ export class DocumentComponent implements OnInit { this.pdfRender(this.docList[this.currentDoc]); setTimeout(() => { this.loadingPage = false; - this.renderingDoc = false; + this.signaturesService.renderingDoc = false; }, 500); this.loadNextDoc(); }, (err: any) => { @@ -198,21 +179,11 @@ export class DocumentComponent implements OnInit { this.canvasWrapper.nativeElement.style.width = this.signaturesService.workingAreaWidth + 'px'; this.canvasWrapper.nativeElement.style.height = this.signaturesService.workingAreaHeight + 'px'; - this.annotationPadOptions.canvasWidth = this.signaturesService.workingAreaWidth; - this.annotationPadOptions.canvasHeight = this.signaturesService.workingAreaHeight; - - const ratio = Math.max(window.devicePixelRatio || 1, 1); - this.annotationPadOptions.canvasHeight = this.annotationPadOptions.canvasHeight * ratio; - this.annotationPadOptions.canvasWidth = this.annotationPadOptions.canvasWidth * ratio; - - if (this.signaturePad !== undefined) { - this.signaturePad.set('canvasWidth', this.annotationPadOptions.canvasWidth); - this.signaturePad.set('canvasHeight', this.annotationPadOptions.canvasHeight); - } + this.appDocumentNotePad.resizePad(); this.signaturesService.signWidth = this.signaturesService.workingAreaWidth / 4.5; - this.renderingDoc = false; + this.signaturesService.renderingDoc = false; } prevPage() { @@ -241,7 +212,7 @@ export class DocumentComponent implements OnInit { } nextDoc() { - this.renderingDoc = true; + this.signaturesService.renderingDoc = true; this.signaturesService.isTaggable = false; this.pageNum = 1; this.currentDoc++; @@ -250,7 +221,7 @@ export class DocumentComponent implements OnInit { } prevDoc() { - this.renderingDoc = true; + this.signaturesService.renderingDoc = true; this.pageNum = 1; this.currentDoc--; if (this.currentDoc === 0) { @@ -263,125 +234,10 @@ export class DocumentComponent implements OnInit { addAnnotation() { if (!this.signaturesService.lockNote && this.currentDoc === 0) { this.signaturesService.annotationMode = true; - this.signaturePadPosX = 0; - this.signaturePadPosY = 0; this.signaturesService.lockNote = true; } } - moveSign(event: any, i: number) { - this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].positionX = event.x; - this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].positionY = event.y; - } - - cloneSign(i: number) { - - const r = confirm('Voulez-vous apposer la signature sur les autres pages ?'); - - if (r) { - this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].inAllPage = true; - this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].token = Math.random().toString(36).substr(2, 9); - - for (let index = 1; index <= this.signaturesService.totalPage; index++) { - if (!this.signaturesService.signaturesContent[index]) { - this.signaturesService.signaturesContent[index] = []; - } - if (index !== this.signaturesService.currentPage) { - this.signaturesService.signaturesContent[index].push(JSON.parse(JSON.stringify(this.signaturesService.signaturesContent[this.signaturesService.currentPage][i]))); - } - } - } - this.menuSign.closeMenu(); - } - - moveNote(event: any, i: number) { - this.signaturesService.notesContent[this.signaturesService.currentPage][i].positionX = event.x; - this.signaturesService.notesContent[this.signaturesService.currentPage][i].positionY = event.y; - } - - movePad(event: any) { - this.signaturePadPosX = event.x; - this.signaturePadPosY = event.y; - $('.page-viewer, .canvas-wrapper, .mat-sidenav-content').css({ 'overflow': 'auto' }); - } - - deleteSignature(i: number) { - - if (this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].inAllPage === true) { - const token = this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].token; - const r = confirm('Voulez-vous supprimer la signature sur les autres pages ?'); - - if (r) { - - for (let index = 1; index <= this.signaturesService.totalPage; index++) { - if (!this.signaturesService.signaturesContent[index]) { - this.signaturesService.signaturesContent[index] = []; - } - for (let index2 = 0; index2 <= this.signaturesService.signaturesContent[index].length; index2++) { - if (this.signaturesService.signaturesContent[index][index2]) { - if (token === this.signaturesService.signaturesContent[index][index2].token) { - this.signaturesService.signaturesContent[index].splice(index2, 1); - } - } - } - } - } else { - this.signaturesService.signaturesContent[this.signaturesService.currentPage].splice(i, 1); - } - } else { - this.signaturesService.signaturesContent[this.signaturesService.currentPage].splice(i, 1); - } - } - - deleteNote(index: number) { - this.signaturesService.notesContent[this.signaturesService.currentPage].splice(index, 1); - } - - validateAnnotation() { - if (!this.signaturesService.notesContent[this.signaturesService.currentPage]) { - this.signaturesService.notesContent[this.signaturesService.currentPage] = []; - } - this.signaturesService.notesContent[this.signaturesService.currentPage].push( - { - 'fullPath': this.signaturePad.toDataURL('image/svg+xml'), - 'positionX': (this.signaturePadPosX * 100) / this.annotationPadOptions.canvasWidth, - 'positionY': (this.signaturePadPosY * 100) / this.annotationPadOptions.canvasHeight, - 'height': this.annotationPadOptions.canvasHeight, - 'width': 768, - } - ); - this.signaturePad.clear(); - if (this.scale > 1) { - this.renderingDoc = true; - } - this.scale = 1; - this.signaturesService.annotationMode = false; - this.signaturesService.lockNote = false; - this.notificationService.success('Annotation ajoutée'); - } - - cancelAnnotation() { - setTimeout(() => { - this.signaturesService.annotationMode = false; - this.signaturePad.clear(); - this.scale = 1; - this.signaturesService.lockNote = false; - }, 200); - } - - freezDoc() { - $('.page-viewer, .canvas-wrapper, .mat-sidenav-content').css({ 'overflow': 'hidden' }); - } - - onColorChange(entry: any) { - this.signaturePad.set('penColor', entry.id); - } - - onDotChange(entry: any) { - this.signaturePad.set('minWidth', parseFloat(entry)); - this.signaturePad.set('maxWidth', parseFloat(entry) + 2); - } - openDialog(): void { const dialogRef = this.dialog.open(WarnModalComponent, { width: '350px', @@ -450,12 +306,6 @@ export class DocumentComponent implements OnInit { }); } - undoTag() { - if (this.signaturesService.notesContent[this.pageNum]) { - this.signaturesService.notesContent[this.pageNum].pop(); - } - } - loadNextDoc () { if (this.docList[this.currentDoc + 1] && this.docList[this.currentDoc + 1].id && this.docList[this.currentDoc + 1].encodedDocument === '') { this.http.get('../rest/attachments/' + this.docList[this.currentDoc + 1].id) @@ -471,200 +321,4 @@ export class DocumentComponent implements OnInit { this.signaturesService.currentAction = action.id; this[action.event](); } - - test() { - if (this.lockSignaturePad) { - this.lockSignaturePad = false; - this.signaturePad.on(); - } else { - this.lockSignaturePad = true; - this.signaturePad.off(); - } - } - - zoomPlus() { - this.renderingDoc = true; - this.lockSignaturePad = true; - this.scale = 2; - } - - zoomMinus() { - this.renderingDoc = true; - this.signaturePad.clear(); - this.lockSignaturePad = true; - this.scale = 1; - } - - undo() { - const data = this.signaturePad.toData(); - if (data) { - data.pop(); // remove the last dot or line - this.signaturePad.fromData(data); - } - } - - // USE TO PREVENT ISSUE IN MOBILE - openMenu(menu: MatMenuTrigger) { - menu.openMenu(); - } -} - -@Component({ - templateUrl: '../modal/warn-modal.component.html', - styleUrls: ['../modal/warn-modal.component.scss'] -}) -export class WarnModalComponent { - disableState = false; - - constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<WarnModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { } - - confirmDoc () { - const signatures: any[] = []; - if (this.signaturesService.currentAction > 0) { - for (let index = 1; index <= this.signaturesService.totalPage; index++) { - if (this.signaturesService.signaturesContent[index]) { - this.signaturesService.signaturesContent[index].forEach((signature: any) => { - signatures.push( - { - 'encodedImage' : signature.encodedSignature, - 'width' : (this.signaturesService.signWidth * 100) / signature.pdfAreaX, - 'positionX' : (signature.positionX * 100) / signature.pdfAreaX, - 'positionY' : (signature.positionY * 100) / signature.pdfAreaY, - 'type' : 'PNG', - 'page' : index - } - ); - }); - } - if (this.signaturesService.notesContent[index]) { - this.signaturesService.notesContent[index].forEach((note: any) => { - signatures.push( - { - 'encodedImage' : note.fullPath, - 'width' : note.width, - 'positionX' : note.positionX, - 'positionY' : note.positionY, - 'type' : 'SVG', - 'page' : index - } - ); - }); - } - } - this.disableState = true; - this.http.put('../rest/documents/' + this.signaturesService.mainDocumentId + '/actions/' + this.signaturesService.currentAction, {'signatures': signatures}) - .subscribe(() => { - this.signaturesService.documentsList.splice(this.signaturesService.indexDocumentsList, 1); - if (this.signaturesService.documentsListCount > 0) { - this.signaturesService.documentsListCount--; - } - this.disableState = false; - this.dialogRef.close('sucess'); - }, (err: any) => { - this.notificationService.handleErrors(err); - this.disableState = false; - }); - } else { - this.dialogRef.close('sucess'); - } - } -} - -@Component({ - templateUrl: '../modal/confirm-modal.component.html', - styleUrls: ['../modal/confirm-modal.component.scss'] -}) -export class ConfirmModalComponent { - disableState = false; - - constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<ConfirmModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { } - - confirmDoc () { - const signatures: any[] = []; - if (this.signaturesService.currentAction > 0) { - for (let index = 1; index <= this.signaturesService.totalPage; index++) { - if (this.signaturesService.signaturesContent[index]) { - this.signaturesService.signaturesContent[index].forEach((signature: any) => { - signatures.push( - { - 'encodedImage' : signature.encodedSignature, - 'width' : (this.signaturesService.signWidth * 100) / signature.pdfAreaX, - 'positionX' : (signature.positionX * 100) / signature.pdfAreaX, - 'positionY' : (signature.positionY * 100) / signature.pdfAreaY, - 'type' : 'PNG', - 'page' : index, - } - ); - }); - } - if (this.signaturesService.notesContent[index]) { - this.signaturesService.notesContent[index].forEach((note: any) => { - signatures.push( - { - 'encodedImage' : note.fullPath, - 'width' : note.width, - 'positionX' : note.positionX, - 'positionY' : note.positionY, - 'type' : 'SVG', - 'page' : index, - } - ); - }); - } - } - this.disableState = true; - this.http.put('../rest/documents/' + this.signaturesService.mainDocumentId + '/actions/' + this.signaturesService.currentAction, {'signatures': signatures}) - .subscribe(() => { - this.disableState = false; - this.dialogRef.close('sucess'); - this.signaturesService.documentsList.splice(this.signaturesService.indexDocumentsList, 1); - if (this.signaturesService.documentsListCount > 0) { - this.signaturesService.documentsListCount--; - } - }, (err: any) => { - this.notificationService.handleErrors(err); - this.disableState = false; - }); - } else { - this.dialogRef.close('sucess'); - } - } -} - -@Component({ - templateUrl: '../modal/success-info-valid.html', - styleUrls: ['../modal/success-info-valid.scss'] -}) -export class SuccessInfoValidBottomSheetComponent implements OnInit { - date: Date = new Date(); - constructor(private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<SuccessInfoValidBottomSheetComponent>) { } - ngOnInit(): void { - setTimeout(() => { - if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList]) { - this.router.navigate(['/documents/' + this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].id]); - } else { - this.router.navigate(['/documents']); - } - this.bottomSheetRef.dismiss(); - }, 2000); - } -} - -@Component({ - templateUrl: '../modal/reject-info.html', - styleUrls: ['../modal/reject-info.scss'] -}) -export class RejectInfoBottomSheetComponent implements OnInit { - date: Date = new Date(); - constructor(private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<RejectInfoBottomSheetComponent>) { } - ngOnInit(): void { - setTimeout(() => { - if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList]) { - this.router.navigate(['/documents/' + this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].id]); - } else { - this.router.navigate(['/documents']); - } - this.bottomSheetRef.dismiss(); - }, 2000); - } } diff --git a/src/frontend/app/documentNoteList/document-note-list.component.html b/src/frontend/app/documentNoteList/document-note-list.component.html new file mode 100644 index 0000000000000000000000000000000000000000..08572a345818d20fc88aebebb6b01fc445515e78 --- /dev/null +++ b/src/frontend/app/documentNoteList/document-note-list.component.html @@ -0,0 +1,8 @@ +<ng-container *ngFor="let note of this.signaturesService.notesContent[this.signaturesService.currentPage];let i = index;"> + <div style="top:0;left:0;position: absolute;" [ngClass]="{ + 'pdf-page-canvas':!renderingDoc, + 'pdf-page-canvas-loading-doc':renderingDoc + }"> + <img [style.width.px]="note.width*signaturesService.scale" [src]="sanitization.bypassSecurityTrustUrl(note.fullPath)" (click)="triggerAddnnotation($event)"> + </div> + </ng-container> \ No newline at end of file diff --git a/src/frontend/app/documentNoteList/document-note-list.component.ts b/src/frontend/app/documentNoteList/document-note-list.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..51587c45e77ceaa9f9b52fad44512f61363ab855 --- /dev/null +++ b/src/frontend/app/documentNoteList/document-note-list.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit, Input, ElementRef, EventEmitter, Output } from '@angular/core'; +import { SignaturesContentService } from '../service/signatures.service'; +import { DomSanitizer } from '@angular/platform-browser'; + + +@Component({ + selector: 'app-document-note-list', + templateUrl: 'document-note-list.component.html', +}) +export class DocumentNoteListComponent implements OnInit { + + + @Input() canvas: ElementRef; + @Input() scale: number; + @Output() triggerEvent = new EventEmitter<string>(); + + constructor(private sanitization: DomSanitizer, public signaturesService: SignaturesContentService) { } + + ngOnInit(): void { } + + triggerAddnnotation (event: any) { + this.triggerEvent.emit(event); + } +} diff --git a/src/frontend/app/documentNotePad/document-note-pad.component.html b/src/frontend/app/documentNotePad/document-note-pad.component.html new file mode 100644 index 0000000000000000000000000000000000000000..1e635e14f3e2afd997864609b913d6bd623803c7 --- /dev/null +++ b/src/frontend/app/documentNotePad/document-note-pad.component.html @@ -0,0 +1,41 @@ +<div *ngIf="signaturesService.lockNote"> + <span style="z-index:1;position: fixed;bottom: 10px;top: 10px;font-size: 25px;height:50px;"> + <button class="btn blue" (tap)="cancelAnnotation(i);"><i class="fas fa-arrow-left fa-2x"></i>Quitter l'annotation</button> + </span> + <span *ngIf="!lockSignaturePad" style="z-index:1;position: fixed;top: 10px;left: 50%;transform: translateX(-50%);font-size: 25px;"> + <button class="btn red" (tap)="togglePad();"><i class="fas fa-lock fa-2x"></i>Vérouiller la zone de travaille</button> + </span> + <span *ngIf="lockSignaturePad" style="z-index:1;position: fixed;top: 10px;left: 50%;transform: translateX(-50%);font-size: 25px;"> + <button class="btn green" (tap)="togglePad();"><i class="fas fa-lock fa-2x"></i>Dévérouiller la zone de travaille</button> + </span> + <span *ngIf="signaturesService.scale==1" style="z-index:1;position: fixed;top: 10px;right: 0;font-size: 25px;"> + <button class="btn blue" (tap)="zoomPlus();"><i class="fas fa-plus fa-2x"></i>Zoomer</button> + </span> + <span *ngIf="signaturesService.scale==2" style="z-index:1;position: fixed;top: 10px;right: 0px;font-size: 25px;"> + <button class="btn blue" (tap)="zoomMinus();"><i class="fas fa-plus fa-2x"></i>Dézoomer</button> + </span> + <span style="z-index:1;position: fixed;bottom: 10px;left: 50%;transform: translateX(-50%);font-size: 25px;"> + <button class="btn green" (click)="$event.stopPropagation();validateAnnotation();"><i class="fas fa-check-circle fa-2x"></i>Valider + l'annotation</button> + </span> +</div> +<div *ngIf="signaturesService.lockNote" [style.width.px]="this.signaturesService.workingAreaWidth" [style.height.px]="this.signaturesService.workingAreaHeight" + style="top:0;position: absolute;border: dashed 1px grey;overflow: hidden;" [ngClass]="{ + 'pdf-page-canvas':!renderingDoc, + 'pdf-page-canvas-loading-doc':renderingDoc +}"> + <div class="tool-content tool-content-left"> + <input type="range" name="dot" min="1" max="10" step="1" value="1" (input)="onDotChange($event.target.value)" class="range"> + <i class="fas fa-pen-nib"></i> + </div> + <div class="tool-content tool-content-right"> + <ng-container *ngFor="let color of penColors" let idx="index"> + <input type="radio" name="colors" [checked]="idx === 0" [value]="color.id" (change)="onColorChange(color)" class="radio" + [ngStyle]="{'border-color': color.id, 'background-color': color.id}"> + </ng-container> + <hr> + <i class="fa fa-undo fa-2x undo" (click)="undo()"></i> + </div> + <signature-pad id="notePad" [options]="annotationPadOptions"></signature-pad> + <div *ngIf="lockSignaturePad" style="background: #ffffffb3;position: absolute;top: 0;left: 0;width: 100%;height: 100%;"></div> +</div> \ No newline at end of file diff --git a/src/frontend/app/documentNotePad/document-note-pad.component.scss b/src/frontend/app/documentNotePad/document-note-pad.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..d9a2899f25f4d6dd1163937e60f7610e63d874c8 --- /dev/null +++ b/src/frontend/app/documentNotePad/document-note-pad.component.scss @@ -0,0 +1,41 @@ +.tool-content { + display: flex; + position: fixed; + background: #8080804d; + border-radius: 20px; + top: 170px; + transform: translateY(-50%) rotate(-90deg); + padding: 10px; + &-left { + left: -40px; + } + &-right { + right: -40px; + } +} + +.undo { + cursor: pointer; + transform: rotate(90deg); + transition: all 0.2s; + &:active { + transform: rotate(90deg) scale(1.5); + } +} + +.radio { + appearance: none; + position: relative; + margin: 5px; + width: 30px; + height: 30px; + border-radius: 30px; + border-width: none; + border-style: solid; + outline: none; + cursor: pointer; + transition: all 0.2s; + &:checked, &:hover { + transform: scale(1.5); + } +} diff --git a/src/frontend/app/documentNotePad/document-note-pad.component.ts b/src/frontend/app/documentNotePad/document-note-pad.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..179845c80cd8ba684b90e21b3fc6710cb2e36b19 --- /dev/null +++ b/src/frontend/app/documentNotePad/document-note-pad.component.ts @@ -0,0 +1,126 @@ +import { Component, OnInit, ViewChild, Input, ElementRef } from '@angular/core'; +import { SignaturesContentService } from '../service/signatures.service'; +import { NotificationService } from '../service/notification.service'; +import { DomSanitizer } from '@angular/platform-browser'; +import { SignaturePad } from 'angular2-signaturepad/signature-pad'; + + +@Component({ + selector: 'app-document-note-pad', + templateUrl: 'document-note-pad.component.html', + styleUrls: ['document-note-pad.component.scss'], +}) +export class DocumentNotePadComponent implements OnInit { + + lockSignaturePad = false; + penColors = [{ id: 'black' }, { id: '#1a75ff' }, { id: '#FF0000' }]; + annotationPadOptions = { + throttle: 0, + minWidth: 1, + maxWidth: 2.5, + backgroundColor: 'rgba(255, 255, 255, 0)', + canvasWidth: 768, + canvasHeight: 270 + }; + + @ViewChild(SignaturePad) signaturePad: SignaturePad; + @Input() pageNum: number; + + + constructor(private sanitization: DomSanitizer, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { } + + ngOnInit(): void { } + + onDotChange(entry: any) { + this.signaturePad.set('minWidth', parseFloat(entry)); + this.signaturePad.set('maxWidth', parseFloat(entry) + 2); + } + + onColorChange(entry: any) { + this.signaturePad.set('penColor', entry.id); + } + + undoTag() { + if (this.signaturesService.notesContent[this.pageNum]) { + this.signaturesService.notesContent[this.pageNum].pop(); + } + } + + resizePad() { + this.annotationPadOptions.canvasWidth = this.signaturesService.workingAreaWidth; + this.annotationPadOptions.canvasHeight = this.signaturesService.workingAreaHeight; + + const ratio = Math.max(window.devicePixelRatio || 1, 1); + this.annotationPadOptions.canvasHeight = this.annotationPadOptions.canvasHeight * ratio; + this.annotationPadOptions.canvasWidth = this.annotationPadOptions.canvasWidth * ratio; + + if (this.signaturePad !== undefined) { + this.signaturePad.set('canvasWidth', this.annotationPadOptions.canvasWidth); + this.signaturePad.set('canvasHeight', this.annotationPadOptions.canvasHeight); + } + } + + cancelAnnotation() { + setTimeout(() => { + this.signaturesService.annotationMode = false; + this.signaturePad.clear(); + this.signaturesService.scale = 1; + this.signaturesService.lockNote = false; + }, 200); + } + + togglePad() { + if (this.lockSignaturePad) { + this.lockSignaturePad = false; + this.signaturePad.on(); + } else { + this.lockSignaturePad = true; + this.signaturePad.off(); + } + } + + zoomPlus() { + this.signaturesService.renderingDoc = true; + this.lockSignaturePad = true; + this.signaturesService.scale = 2; + } + + zoomMinus() { + this.signaturesService.renderingDoc = true; + this.signaturePad.clear(); + this.lockSignaturePad = true; + this.signaturesService.scale = 1; + } + + validateAnnotation() { + if (!this.signaturesService.notesContent[this.signaturesService.currentPage]) { + this.signaturesService.notesContent[this.signaturesService.currentPage] = []; + } + this.signaturesService.notesContent[this.signaturesService.currentPage].push( + { + 'fullPath': this.signaturePad.toDataURL('image/svg+xml'), + 'positionX': 0, + 'positionY': 0, + 'height': this.annotationPadOptions.canvasHeight, + 'width': 768, + } + ); + this.signaturePad.clear(); + if (this.signaturesService.scale > 1) { + this.signaturesService.renderingDoc = true; + } + this.signaturesService.scale = 1; + this.signaturesService.annotationMode = false; + this.signaturesService.lockNote = false; + this.notificationService.success('Annotation ajoutée'); + } + + undo() { + const data = this.signaturePad.toData(); + if (data) { + data.pop(); // remove the last dot or line + this.signaturePad.fromData(data); + } + } + +} diff --git a/src/frontend/app/documentSignList/document-sign-list.component.html b/src/frontend/app/documentSignList/document-sign-list.component.html new file mode 100644 index 0000000000000000000000000000000000000000..55f67d76475868504cc8e2a6f3b06ac485694aab --- /dev/null +++ b/src/frontend/app/documentSignList/document-sign-list.component.html @@ -0,0 +1,24 @@ +<ng-container *ngFor="let signature of this.signaturesService.signaturesContent[this.signaturesService.currentPage];let i = index;"> + <div [position]="{'x': signature.positionX*signaturesService.scale, 'y': signature.positionY*signaturesService.scale}" id="signaturesContent" style="top:0;left:0;position: absolute;border: dashed 1px grey;background: rgba(255, 255, 255, 0.6) none repeat scroll 0% 0%;" + ngDraggable preventDefaultEvent="true" [bounds]="canvas" inBounds="true" (endOffset)="moveSign($event,i)" [ngClass]="{ + 'pdf-page-canvas':!renderingDoc, + 'pdf-page-canvas-loading-doc':renderingDoc + }"> + <button (tap)="openMenu(menuTrigger)" mat-icon-button #menuTrigger="matMenuTrigger" [matMenuTriggerFor]="menu" + style="right: 0;position: absolute;color:#F99830;"> + <mat-icon fontSet="fas" fontIcon="fa-ellipsis-v"></mat-icon> + </button> + <mat-menu #menu="matMenu"> + <button mat-menu-item (click)="$event.stopPropagation();deleteSignature(i);"> + <mat-icon fontSet="fas" fontIcon="fa-times"></mat-icon> + <span>Supprimer la signature</span> + </button> + <button [disabled]="signature.inAllPage" mat-menu-item (click)="$event.stopPropagation();cloneSign(i);"> + <mat-icon fontSet="fas" fontIcon="fa-clone"></mat-icon> + <span>Cloner la signature</span> + </button> + </mat-menu> + <img [src]="sanitization.bypassSecurityTrustUrl('data:image/png;base64,' + signature.encodedSignature)" + [style.width.px]="this.signaturesService.signWidth"> + </div> +</ng-container> \ No newline at end of file diff --git a/src/frontend/app/documentSignList/document-sign-list.component.ts b/src/frontend/app/documentSignList/document-sign-list.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..c109a27fa094373458ec742ea820788e1fe74a2f --- /dev/null +++ b/src/frontend/app/documentSignList/document-sign-list.component.ts @@ -0,0 +1,82 @@ +import { Component, OnInit, ViewChild, Input, ElementRef } from '@angular/core'; +import { SignaturesContentService } from '../service/signatures.service'; +import { + MatMenuTrigger, +} from '@angular/material'; +import { NotificationService } from '../service/notification.service'; +import { DomSanitizer } from '@angular/platform-browser'; + + +@Component({ + selector: 'app-document-sign-list', + templateUrl: 'document-sign-list.component.html', +}) +export class DocumentSignListComponent implements OnInit { + + + @Input('canvas') canvas: ElementRef; + + @ViewChild('menuTrigger') menuSign: MatMenuTrigger; + + constructor(private sanitization: DomSanitizer, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { } + + ngOnInit(): void { } + + moveSign(event: any, i: number) { + this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].positionX = event.x; + this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].positionY = event.y; + } + + cloneSign(i: number) { + + const r = confirm('Voulez-vous apposer la signature sur les autres pages ?'); + + if (r) { + this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].inAllPage = true; + this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].token = Math.random().toString(36).substr(2, 9); + + for (let index = 1; index <= this.signaturesService.totalPage; index++) { + if (!this.signaturesService.signaturesContent[index]) { + this.signaturesService.signaturesContent[index] = []; + } + if (index !== this.signaturesService.currentPage) { + this.signaturesService.signaturesContent[index].push(JSON.parse(JSON.stringify(this.signaturesService.signaturesContent[this.signaturesService.currentPage][i]))); + } + } + } + this.menuSign.closeMenu(); + } + + deleteSignature(i: number) { + + if (this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].inAllPage === true) { + const token = this.signaturesService.signaturesContent[this.signaturesService.currentPage][i].token; + const r = confirm('Voulez-vous supprimer la signature sur les autres pages ?'); + + if (r) { + + for (let index = 1; index <= this.signaturesService.totalPage; index++) { + if (!this.signaturesService.signaturesContent[index]) { + this.signaturesService.signaturesContent[index] = []; + } + for (let index2 = 0; index2 <= this.signaturesService.signaturesContent[index].length; index2++) { + if (this.signaturesService.signaturesContent[index][index2]) { + if (token === this.signaturesService.signaturesContent[index][index2].token) { + this.signaturesService.signaturesContent[index].splice(index2, 1); + } + } + } + } + } else { + this.signaturesService.signaturesContent[this.signaturesService.currentPage].splice(i, 1); + } + } else { + this.signaturesService.signaturesContent[this.signaturesService.currentPage].splice(i, 1); + } + } + + // USE TO PREVENT ISSUE IN MOBILE + openMenu(menu: MatMenuTrigger) { + menu.openMenu(); + } +} diff --git a/src/frontend/app/modal/confirm-modal.component.ts b/src/frontend/app/modal/confirm-modal.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..1eea17c5afd5d61b755f25b9999a8c6d680330ae --- /dev/null +++ b/src/frontend/app/modal/confirm-modal.component.ts @@ -0,0 +1,66 @@ +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { SignaturesContentService } from '../service/signatures.service'; +import { NotificationService } from '../service/notification.service'; +import { HttpClient } from '@angular/common/http'; + +@Component({ + templateUrl: 'confirm-modal.component.html', + styleUrls: ['confirm-modal.component.scss'] +}) +export class ConfirmModalComponent { + disableState = false; + + constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<ConfirmModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { } + + confirmDoc () { + const signatures: any[] = []; + if (this.signaturesService.currentAction > 0) { + for (let index = 1; index <= this.signaturesService.totalPage; index++) { + if (this.signaturesService.signaturesContent[index]) { + this.signaturesService.signaturesContent[index].forEach((signature: any) => { + signatures.push( + { + 'encodedImage' : signature.encodedSignature, + 'width' : (this.signaturesService.signWidth * 100) / signature.pdfAreaX, + 'positionX' : (signature.positionX * 100) / signature.pdfAreaX, + 'positionY' : (signature.positionY * 100) / signature.pdfAreaY, + 'type' : 'PNG', + 'page' : index, + } + ); + }); + } + if (this.signaturesService.notesContent[index]) { + this.signaturesService.notesContent[index].forEach((note: any) => { + signatures.push( + { + 'encodedImage' : note.fullPath, + 'width' : note.width, + 'positionX' : note.positionX, + 'positionY' : note.positionY, + 'type' : 'SVG', + 'page' : index, + } + ); + }); + } + } + this.disableState = true; + this.http.put('../rest/documents/' + this.signaturesService.mainDocumentId + '/actions/' + this.signaturesService.currentAction, {'signatures': signatures}) + .subscribe(() => { + this.disableState = false; + this.dialogRef.close('sucess'); + this.signaturesService.documentsList.splice(this.signaturesService.indexDocumentsList, 1); + if (this.signaturesService.documentsListCount > 0) { + this.signaturesService.documentsListCount--; + } + }, (err: any) => { + this.notificationService.handleErrors(err); + this.disableState = false; + }); + } else { + this.dialogRef.close('sucess'); + } + } +} diff --git a/src/frontend/app/modal/reject-info.component.ts b/src/frontend/app/modal/reject-info.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c90cdc42d40dd71023176a984ee748e3fda24b9 --- /dev/null +++ b/src/frontend/app/modal/reject-info.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { SignaturesContentService } from '../service/signatures.service'; +import { MatBottomSheetRef } from '@angular/material'; + +@Component({ + templateUrl: '../modal/reject-info.html', + styleUrls: ['../modal/reject-info.scss'] +}) +export class RejectInfoBottomSheetComponent implements OnInit { + date: Date = new Date(); + constructor(private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<RejectInfoBottomSheetComponent>) { } + ngOnInit(): void { + setTimeout(() => { + if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList]) { + this.router.navigate(['/documents/' + this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].id]); + } else { + this.router.navigate(['/documents']); + } + this.bottomSheetRef.dismiss(); + }, 2000); + } +} diff --git a/src/frontend/app/modal/success-info-valid.component.ts b/src/frontend/app/modal/success-info-valid.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..a28f530434d60598a4417572d6cf828497dfaef1 --- /dev/null +++ b/src/frontend/app/modal/success-info-valid.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { SignaturesContentService } from '../service/signatures.service'; +import { MatBottomSheetRef } from '@angular/material'; + +@Component({ + templateUrl: 'success-info-valid.html', + styleUrls: ['success-info-valid.scss'] +}) +export class SuccessInfoValidBottomSheetComponent implements OnInit { + date: Date = new Date(); + constructor(private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<SuccessInfoValidBottomSheetComponent>) { } + ngOnInit(): void { + setTimeout(() => { + if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList]) { + this.router.navigate(['/documents/' + this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].id]); + } else { + this.router.navigate(['/documents']); + } + this.bottomSheetRef.dismiss(); + }, 2000); + } +} diff --git a/src/frontend/app/modal/warn-modal.component.ts b/src/frontend/app/modal/warn-modal.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcd95fe21be6b60b6519c3f53ce68a90d737e832 --- /dev/null +++ b/src/frontend/app/modal/warn-modal.component.ts @@ -0,0 +1,67 @@ + +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { SignaturesContentService } from '../service/signatures.service'; +import { NotificationService } from '../service/notification.service'; +import { HttpClient } from '@angular/common/http'; + +@Component({ + templateUrl: 'warn-modal.component.html', + styleUrls: ['warn-modal.component.scss'] +}) +export class WarnModalComponent { + disableState = false; + + constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<WarnModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { } + + confirmDoc () { + const signatures: any[] = []; + if (this.signaturesService.currentAction > 0) { + for (let index = 1; index <= this.signaturesService.totalPage; index++) { + if (this.signaturesService.signaturesContent[index]) { + this.signaturesService.signaturesContent[index].forEach((signature: any) => { + signatures.push( + { + 'encodedImage' : signature.encodedSignature, + 'width' : (this.signaturesService.signWidth * 100) / signature.pdfAreaX, + 'positionX' : (signature.positionX * 100) / signature.pdfAreaX, + 'positionY' : (signature.positionY * 100) / signature.pdfAreaY, + 'type' : 'PNG', + 'page' : index + } + ); + }); + } + if (this.signaturesService.notesContent[index]) { + this.signaturesService.notesContent[index].forEach((note: any) => { + signatures.push( + { + 'encodedImage' : note.fullPath, + 'width' : note.width, + 'positionX' : note.positionX, + 'positionY' : note.positionY, + 'type' : 'SVG', + 'page' : index + } + ); + }); + } + } + this.disableState = true; + this.http.put('../rest/documents/' + this.signaturesService.mainDocumentId + '/actions/' + this.signaturesService.currentAction, {'signatures': signatures}) + .subscribe(() => { + this.signaturesService.documentsList.splice(this.signaturesService.indexDocumentsList, 1); + if (this.signaturesService.documentsListCount > 0) { + this.signaturesService.documentsListCount--; + } + this.disableState = false; + this.dialogRef.close('sucess'); + }, (err: any) => { + this.notificationService.handleErrors(err); + this.disableState = false; + }); + } else { + this.dialogRef.close('sucess'); + } + } +} diff --git a/src/frontend/app/service/signatures.service.ts b/src/frontend/app/service/signatures.service.ts index bd9740e3eb7f648e985007619460f4788dcbbdce..4a0746001444807068a36f0f9d90321b49d0bd75 100755 --- a/src/frontend/app/service/signatures.service.ts +++ b/src/frontend/app/service/signatures.service.ts @@ -25,4 +25,6 @@ export class SignaturesContentService { newSign: any = {}; workingAreaWidth = 0; workingAreaHeight = 0; + renderingDoc = true; + scale = 1; }