From 9ac2c6f2c82adf137170ed376ee64d57d35da5e3 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Fri, 23 Nov 2018 12:14:32 +0100
Subject: [PATCH] FIX rm id 1 in route

---
 package.json                                  | 25 +++++++++----------
 .../app/document/document.component.ts        |  7 ++++--
 src/frontend/app/pad/pad.component.ts         |  6 +++--
 .../app/signatures/signatures.component.ts    |  6 +++--
 4 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/package.json b/package.json
index deb7d0710c..4812e7f72d 100644
--- a/package.json
+++ b/package.json
@@ -19,21 +19,20 @@
   "author": "Maarch",
   "license": "GPL-3.0",
   "dependencies": {
-    "@angular/animations": "^7.0.4",
+    "@angular/animations": "^7.1.0",
     "@angular/cdk": "^7.0.4",
-    "@angular/common": "^7.0.4",
-    "@angular/compiler": "^7.0.4",
-    "@angular/core": "^7.0.4",
-    "@angular/forms": "^7.0.4",
-    "@angular/http": "^7.0.4",
+    "@angular/common": "^7.1.0",
+    "@angular/compiler": "^7.1.0",
+    "@angular/core": "^7.1.0",
+    "@angular/forms": "^7.1.0",
+    "@angular/http": "^7.1.0",
     "@angular/material": "^7.0.4",
-    "@angular/platform-browser": "^7.0.4",
-    "@angular/platform-browser-dynamic": "^7.0.4",
-    "@angular/router": "^7.0.4",
+    "@angular/platform-browser": "^7.1.0",
+    "@angular/platform-browser-dynamic": "^7.1.0",
+    "@angular/router": "^7.1.0",
     "@fortawesome/fontawesome-free": "^5.4.1",
     "@ngrx/store": "^6.1.0",
     "@ngrx/store-devtools": "^6.1.0",
-    "@types/node": "^10.11.7",
     "angular2-draggable": "^2.1.8",
     "angular2-signaturepad": "^2.8.0",
     "core-js": "^2.5.4",
@@ -52,13 +51,13 @@
   "devDependencies": {
     "@angular-devkit/build-angular": "~0.8.5",
     "@angular/cli": "~6.2.5",
-    "@angular/compiler-cli": "^7.0.4",
-    "@angular/language-service": "^7.0.4",
+    "@angular/compiler-cli": "^7.1.0",
+    "@angular/language-service": "^7.1.0",
     "@types/hammerjs": "^2.0.36",
     "@types/jasmine": "^2.8.12",
     "@types/jasminewd2": "^2.0.5",
     "@types/jquery": "^3.3.22",
-    "@types/node": "~10.11.7",
+    "@types/node": "^10.12.10",
     "codelyzer": "~4.2.1",
     "jasmine-core": "~2.99.1",
     "jasmine-spec-reporter": "~4.2.1",
diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts
index 52afbd3679..3bd27abf00 100755
--- a/src/frontend/app/document/document.component.ts
+++ b/src/frontend/app/document/document.component.ts
@@ -17,6 +17,7 @@ import { ActivatedRoute, Router } from '@angular/router';
 import { HttpClient } from '@angular/common/http';
 import { NotificationService } from '../service/notification.service';
 import { trigger, transition, style, animate } from '@angular/animations';
+import { CookieService } from 'ngx-cookie-service';
 import { PDFDocumentProxy } from 'ng2-pdf-viewer';
 
 @Component({
@@ -114,11 +115,13 @@ export class DocumentComponent implements OnInit {
     constructor(private router: Router, private route: ActivatedRoute, public http: HttpClient,
         public signaturesService: SignaturesContentService,
         public notificationService: NotificationService,
-        private sanitization: DomSanitizer, public dialog: MatDialog, private bottomSheet: MatBottomSheet) {
+        private sanitization: DomSanitizer, public dialog: MatDialog, private bottomSheet: MatBottomSheet, 
+        private cookieService: CookieService) {
         this.draggable = false;
     }
 
     ngOnInit(): void {
+        const cookieInfo = JSON.parse(atob(this.cookieService.get('maarchParapheurAuth')));
         setTimeout(() => {
             this.enterApp = false;
         }, 500);
@@ -133,7 +136,7 @@ export class DocumentComponent implements OnInit {
                         this.signaturesService.mainDocumentId = this.mainDocument.id;
                         this.actionsList = data.document.actionsAllowed;
                         if (this.signaturesService.signaturesList.length === 0) {
-                            this.http.get('../rest/users/' + '1' + '/signatures')
+                            this.http.get('../rest/users/' + cookieInfo.id + '/signatures')
                             .subscribe((dataSign: any) => {
                                 this.signaturesService.signaturesList = dataSign.signatures;
                                 this.signaturesService.loadingSign = false;
diff --git a/src/frontend/app/pad/pad.component.ts b/src/frontend/app/pad/pad.component.ts
index 43cd7656a8..b80ce940b3 100755
--- a/src/frontend/app/pad/pad.component.ts
+++ b/src/frontend/app/pad/pad.component.ts
@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
 import { SignaturesContentService } from '../service/signatures.service';
 import { HttpClient } from '@angular/common/http';
 import { NotificationService } from '../service/notification.service';
+import { CookieService } from 'ngx-cookie-service';
 
 interface AfterViewInit {
   ngAfterViewInit(): void;
@@ -36,7 +37,7 @@ export class SignaturePadPageComponent implements AfterViewInit {
     canvasHeight: 315
   };
 
-  constructor(public http: HttpClient, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { }
+  constructor(public http: HttpClient, public signaturesService: SignaturesContentService, public notificationService: NotificationService, private cookieService: CookieService) { }
 
   ngAfterViewInit() {
     // this.signaturePad.clear();
@@ -84,7 +85,8 @@ export class SignaturePadPageComponent implements AfterViewInit {
       'encodedSignature': newEncodedSign,
       'format': 'png'
     };
-    this.http.post('../rest/users/' + '1' + '/signatures', newSign)
+    const cookieInfo = JSON.parse(atob(this.cookieService.get('maarchParapheurAuth')));
+    this.http.post('../rest/users/' + cookieInfo.id + '/signatures', newSign)
       .subscribe((data: any) => {
         newSign.id = data.signatureId;
         this.signaturesService.newSign = newSign;
diff --git a/src/frontend/app/signatures/signatures.component.ts b/src/frontend/app/signatures/signatures.component.ts
index c1201296f8..13ec9a3612 100755
--- a/src/frontend/app/signatures/signatures.component.ts
+++ b/src/frontend/app/signatures/signatures.component.ts
@@ -7,6 +7,7 @@ import * as $ from 'jquery';
 import { HttpClient } from '@angular/common/http';
 import { trigger, transition, style, animate, stagger, query } from '@angular/animations';
 import { NotificationService } from '../service/notification.service';
+import { CookieService } from 'ngx-cookie-service';
 
 @Component({
   selector: 'app-signatures',
@@ -31,7 +32,7 @@ export class SignaturesComponent implements OnInit {
   count     : number    = 0;
 
   constructor(public http: HttpClient, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheet,
-     private sanitization: DomSanitizer, public notificationService: NotificationService) {
+     private sanitization: DomSanitizer, public notificationService: NotificationService, private cookieService: CookieService) {
   }
 
   ngOnInit() {
@@ -87,7 +88,8 @@ export class SignaturesComponent implements OnInit {
       let r = confirm('Voulez-vous supprimer cette signature ?');
 
       if (r) {
-          this.http.delete('../rest/users/ ' + '1' + '/signatures/' + signature.id)
+          const cookieInfo = JSON.parse(atob(this.cookieService.get('maarchParapheurAuth')));
+          this.http.delete('../rest/users/ ' + cookieInfo.id + '/signatures/' + signature.id)
               .subscribe(() => {
                   this.signaturesService.signaturesList.splice(i, 1);
                   this.notificationService.success('Signature supprimée');
-- 
GitLab