From 362eb91c8d27d6d4ea8422b80443b7e689ace352 Mon Sep 17 00:00:00 2001
From: Hamza HRAMCHI <hamza.hramchi@xelians.fr>
Date: Mon, 9 Jan 2023 15:52:44 +0100
Subject: [PATCH] FEAT #20284 TIME 0:30 add conig parameters + fix css + add
 var langs

---
 lang/fr.json                                  |  6 ++++-
 .../app/administration/otp/otp.component.html | 25 +++++++++++++++----
 .../app/administration/otp/otp.component.ts   | 10 +++++---
 .../otps/otp-create.component.scss            |  3 ++-
 .../otp-connectors/otp-fast.service.ts        | 21 +++++++++++-----
 .../otp-connectors/otp-yousign.service.ts     | 20 ++++++++++-----
 6 files changed, 63 insertions(+), 22 deletions(-)

diff --git a/lang/fr.json b/lang/fr.json
index 6dcf8e479b..313bf5dbd8 100755
--- a/lang/fr.json
+++ b/lang/fr.json
@@ -671,6 +671,10 @@
 		"inputCardReaderUpdateCerts": "Une entrée de carte détectée, actualisation des certificats...",
 		"outputCardReaderUpdateCerts": "Une sortie de carte détectée, actualisation des certificats...",
 		"yousignOtp": "Yousign",
-		"fastOtp": "Fast"
+		"fastOtp": "Fast",
+		"subscriberId": "Identifiant de l'abonné",
+		"certPath": "Lien vers le certificat",
+		"certPass": "Mot de passe du certificat",
+		"certType": "Type de certificat"
 	}
 }
diff --git a/src/frontend/app/administration/otp/otp.component.html b/src/frontend/app/administration/otp/otp.component.html
index 15d5d24252..00968b770a 100644
--- a/src/frontend/app/administration/otp/otp.component.html
+++ b/src/frontend/app/administration/otp/otp.component.html
@@ -30,15 +30,30 @@
                 </ion-item>
             </ion-radio-group>
         </ion-list>
-        <ng-container *ngIf="connector.type === 'yousign'">
+        <ion-item>
+            <ion-label color="secondary" position="floating">{{'lang.apiUri' | translate}} *</ion-label>
+            <ion-input name="apiUri" [maxlength]="128" [(ngModel)]="connector.apiUri" required>
+            </ion-input>
+        </ion-item>
+        <ion-item>
+            <ion-label color="secondary" position="floating">{{(connector.type === 'yousing' ? 'lang.apiKey' : 'lang.subscriberId') | translate}} *</ion-label>
+            <ion-input name="apiKey" [maxlength]="128" [(ngModel)]="connector.apiKey" required>
+            </ion-input>
+        </ion-item>
+        <ng-container *ngIf="connector.type === 'fast'">
+            <ion-item>
+                <ion-label color="secondary" position="floating">{{'lang.certPath' | translate}} *</ion-label>
+                <ion-input name="certPath" [maxlength]="128" [(ngModel)]="connector.certPath" required>
+                </ion-input>
+            </ion-item>
             <ion-item>
-                <ion-label color="secondary" position="floating">{{'lang.apiUri' | translate}} *</ion-label>
-                <ion-input name="apiUri" [maxlength]="128" [(ngModel)]="connector.apiUri" [required]="connector.type === 'yousign'">
+                <ion-label color="secondary" position="floating">{{'lang.certPass' | translate}} *</ion-label>
+                <ion-input name="certPass" [maxlength]="128" [(ngModel)]="connector.certPass" required>
                 </ion-input>
             </ion-item>
             <ion-item>
-                <ion-label color="secondary" position="floating">{{'lang.apiKey' | translate}} *</ion-label>
-                <ion-input name="apiKey" [maxlength]="128" [(ngModel)]="connector.apiKey" [required]="connector.type === 'yousign'">
+                <ion-label color="secondary" position="floating">{{'lang.certType' | translate}} *</ion-label>
+                <ion-input name="certType" [maxlength]="128" [(ngModel)]="connector.certType" required>
                 </ion-input>
             </ion-item>
         </ng-container>
diff --git a/src/frontend/app/administration/otp/otp.component.ts b/src/frontend/app/administration/otp/otp.component.ts
index bfac983cb1..e86c8203f3 100644
--- a/src/frontend/app/administration/otp/otp.component.ts
+++ b/src/frontend/app/administration/otp/otp.component.ts
@@ -20,6 +20,9 @@ export interface Connector {
     label: string;
     apiUri: string;
     apiKey: string;
+    certPath?: string;
+    certPass?: string;
+    certType?: string;
     securityModes: string[];
     message: any;
 }
@@ -225,9 +228,10 @@ export class OtpComponent implements OnInit, OnDestroy {
             error = true;
         }
         if (!error) {
-            if (this.connector.type !== 'yousign') {
-                delete this.connector.apiKey;
-                delete this.connector.apiUri;
+            if (this.connector.type === 'yousign') {
+                delete this.connector.certPass;
+                delete this.connector.certPath;
+                delete this.connector.certType;
             }
             if (this.creationMode) {
                 this.createconnector();
diff --git a/src/frontend/app/document/visa-workflow/otps/otp-create.component.scss b/src/frontend/app/document/visa-workflow/otps/otp-create.component.scss
index d09854d7b8..048c56d676 100644
--- a/src/frontend/app/document/visa-workflow/otps/otp-create.component.scss
+++ b/src/frontend/app/document/visa-workflow/otps/otp-create.component.scss
@@ -11,8 +11,9 @@
 .chooseConnector {
   display: grid;
   grid-template-columns: repeat(2, auto);
+  justify-items: center;
+  justify-content: center;
   grid-gap: 5px;
-  margin: 15px;
 
   div {
       flex: 1;
diff --git a/src/frontend/app/service/otp-connectors/otp-fast.service.ts b/src/frontend/app/service/otp-connectors/otp-fast.service.ts
index 081da63fea..c71b14736d 100644
--- a/src/frontend/app/service/otp-connectors/otp-fast.service.ts
+++ b/src/frontend/app/service/otp-connectors/otp-fast.service.ts
@@ -1,17 +1,13 @@
 import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
-import { catchError, tap } from 'rxjs/operators';
-import { Observable, of, Subject } from 'rxjs';
-import { NotificationService } from '../notification.service';
-import { TranslateService } from '@ngx-translate/core';
 
 @Injectable({
     providedIn: 'root'
 })
 
+
 export class OtpFastService {
 
-    otpFields: any = {
+    otpFields: OtpFields = {
         type: 'fast',
         firstname: null,
         lastname: null,
@@ -24,3 +20,16 @@ export class OtpFastService {
         modes: ['fast_otp']
     };
 }
+
+export interface OtpFields {
+    type: string;
+    firstname: string;
+    lastname: string;
+    email: string;
+    phone: string;
+    sourceId: number;
+    security: string;
+    securityModes: string[];
+    role: string;
+    modes: string[];
+}
diff --git a/src/frontend/app/service/otp-connectors/otp-yousign.service.ts b/src/frontend/app/service/otp-connectors/otp-yousign.service.ts
index 17152f7ee1..4c9113700b 100644
--- a/src/frontend/app/service/otp-connectors/otp-yousign.service.ts
+++ b/src/frontend/app/service/otp-connectors/otp-yousign.service.ts
@@ -1,9 +1,4 @@
 import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
-import { catchError, tap } from 'rxjs/operators';
-import { Observable, of, Subject } from 'rxjs';
-import { NotificationService } from '../notification.service';
-import { TranslateService } from '@ngx-translate/core';
 
 @Injectable({
     providedIn: 'root'
@@ -11,7 +6,7 @@ import { TranslateService } from '@ngx-translate/core';
 
 export class OtpYousignService {
 
-    otpFields: any = {
+    otpFields: OtpFields = {
         type: 'yousign',
         firstname: null,
         lastname: null,
@@ -24,3 +19,16 @@ export class OtpYousignService {
         securityModes: [],
     };
 }
+
+export interface OtpFields {
+    type: string;
+    firstname: string;
+    lastname: string;
+    email: string;
+    phone: string;
+    sourceId: number;
+    security: string;
+    securityModes: string[];
+    role: string;
+    modes: string[];
+}
-- 
GitLab