diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index 8d61fb8acdf4edbe6fc0de11a904a765ad7f0ace..c20b7f5ca745a3ad50e75cb59a0936ee904f8b87 100755 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -82,6 +82,7 @@ import { SecuritiesAdministrationComponent } from './administration/security/sec import { NotificationService } from './service/notification.service'; import { SignaturesContentService } from './service/signatures.service'; import { FiltersService } from './service/filters.service'; +import { SignatureMethodModalComponent } from './service/signature-method/signature-method-modal.component'; // OTHERS import { ConfirmComponent } from './plugins/confirm.component'; @@ -139,7 +140,8 @@ import { SortPipe } from './plugins/sorting.pipe'; SearchComponent, SignaturePositionComponent, DevToolComponent, - DevLangComponent + DevLangComponent, + SignatureMethodModalComponent ], imports: [ FormsModule, diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index 4e04b1953a0b3e37b049f0bf822b85f0cca8fd6c..4c144cab012403bc2288a909025b466f66be6c9e 100755 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -20,6 +20,7 @@ import { ActionSheetController, AlertController, LoadingController, MenuControll import { NgxExtendedPdfViewerService } from 'ngx-extended-pdf-viewer'; import { catchError, tap } from 'rxjs/operators'; import { of } from 'rxjs'; +import { SignatureMethodService } from '../service/signature-method/signature-method.service'; @Component({ selector: 'app-document', @@ -115,6 +116,7 @@ export class DocumentComponent implements OnInit { public modalController: ModalController, private pdfViewerService: NgxExtendedPdfViewerService, public alertController: AlertController, + public signatureMethodService: SignatureMethodService, public navCtrl: NavController ) { this.draggable = false; @@ -291,7 +293,7 @@ export class DocumentComponent implements OnInit { scrollToElem() { const pageY = this.signaturesService.signaturesContent[this.pageNum][this.signaturesService.signaturesContent[this.pageNum].length - 1].positionY; const offsetTop = -($('#myBounds')[0].getBoundingClientRect().top - 70); - const realPosY = ( pageY - 75) + offsetTop; + const realPosY = (pageY - 75) + offsetTop; const scrollY = (realPosY - $(window).height()); @@ -643,7 +645,7 @@ export class DocumentComponent implements OnInit { spinner: 'dots' }).then(async (load: HTMLIonLoadingElement) => { load.present(); - const res = await this.sendDocument({'note': data.paragraph}); + const res = await this.sendDocument({ 'note': data.paragraph }); if (res) { const config: MatBottomSheetConfig = { disableClose: true, @@ -677,23 +679,29 @@ export class DocumentComponent implements OnInit { buttons: [ { text: this.translate.instant('lang.validate'), - handler: (data: any) => { - this.loadingController.create({ - message: this.translate.instant('lang.processing') + ' ...', - spinner: 'dots' - }).then(async (load: HTMLIonLoadingElement) => { - load.present(); - const res = await this.sendDocument({'note': data.paragraph}); - if (res) { - const config: MatBottomSheetConfig = { - disableClose: true, - direction: 'ltr' - }; - this.bottomSheet.open(SuccessInfoValidBottomSheetComponent, config); - this.localStorage.remove(this.mainDocument.id.toString()); - } - load.dismiss(); - }); + handler: async (data: any) => { + const currentUserWorkflow = this.mainDocument.workflow.filter((line: { current: boolean; }) => line.current === true)[0]; + const res = await this.signatureMethodService.checkAuthentication(currentUserWorkflow); + console.log('result auth', res); + if (res) { + this.loadingController.create({ + message: this.translate.instant('lang.processing') + ' ...', + spinner: 'dots' + }).then(async (load: HTMLIonLoadingElement) => { + load.present(); + const res = await this.sendDocument({ 'note': data.paragraph }); + if (res) { + const config: MatBottomSheetConfig = { + disableClose: true, + direction: 'ltr' + }; + this.bottomSheet.open(SuccessInfoValidBottomSheetComponent, config); + this.localStorage.remove(this.mainDocument.id.toString()); + } + load.dismiss(); + }); + } + } } ] diff --git a/src/frontend/app/service/signature-method/signature-method-modal.component.html b/src/frontend/app/service/signature-method/signature-method-modal.component.html new file mode 100644 index 0000000000000000000000000000000000000000..b97c32d8b2cbeab494c99d18c1062947c109547b --- /dev/null +++ b/src/frontend/app/service/signature-method/signature-method-modal.component.html @@ -0,0 +1,10 @@ +<ion-content> + <div class="content"> + <i *ngIf="status==='SUCCESS'" class="fas fa-check success"></i> + <i *ngIf="status==='WAITING'" class="fas fa-plug bounce"></i> + <i *ngIf="status==='ERROR'" class="fas fa-times danger"></i> + <ion-label *ngIf="status==='WAITING'" style="padding: 10px;">En attente d'identification ...</ion-label> + <ion-label *ngIf="status==='SUCCESS'" style="padding: 10px;">Identification réussie !</ion-label> + <ion-label *ngIf="status==='ERROR'" style="padding: 10px;">Identification échouée !</ion-label> + </div> +</ion-content> \ No newline at end of file diff --git a/src/frontend/app/service/signature-method/signature-method-modal.component.scss b/src/frontend/app/service/signature-method/signature-method-modal.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..0aa6ddc8f07d7807af78469eb98c2ba013866774 --- /dev/null +++ b/src/frontend/app/service/signature-method/signature-method-modal.component.scss @@ -0,0 +1,98 @@ +.content { + display: flex; + align-items: center; + justify-content: center; + padding: 30px !important; + height: 100%; + flex-direction: column; + + i { + font-size: 130px; + color: var(--ion-color-primary); + } +} + +.success { + color: var(--ion-color-success) !important; +} + +.danger { + color: var(--ion-color-danger) !important; +} + +@-webkit-keyframes bounce { + + from, + 20%, + 53%, + 80%, + to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); + animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + 40%, + 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + -webkit-transform: translate3d(0, -30px, 0); + transform: translate3d(0, -30px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + -webkit-transform: translate3d(0, -15px, 0); + transform: translate3d(0, -15px, 0); + } + + 90% { + -webkit-transform: translate3d(0, -4px, 0); + transform: translate3d(0, -4px, 0); + } +} + +@keyframes bounce { + + from, + 20%, + 53%, + 80%, + to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); + animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + 40%, + 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + -webkit-transform: translate3d(0, -30px, 0); + transform: translate3d(0, -30px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06); + -webkit-transform: translate3d(0, -15px, 0); + transform: translate3d(0, -15px, 0); + } + + 90% { + -webkit-transform: translate3d(0, -4px, 0); + transform: translate3d(0, -4px, 0); + } +} + +.bounce { + animation-duration: 2s; + -webkit-animation-name: bounce; + animation-name: bounce; + -webkit-transform-origin: center bottom; + transform-origin: center bottom; + animation-iteration-count: infinite; +} \ No newline at end of file diff --git a/src/frontend/app/service/signature-method/signature-method-modal.component.ts b/src/frontend/app/service/signature-method/signature-method-modal.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..fbf4de9a695ca3cc853785fc72056f9df8d31fb8 --- /dev/null +++ b/src/frontend/app/service/signature-method/signature-method-modal.component.ts @@ -0,0 +1,50 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { ModalController } from '@ionic/angular'; + +@Component({ + selector: 'signature-method-modal', + templateUrl: 'signature-method-modal.component.html', + styleUrls: ['./signature-method-modal.component.scss'] +}) +export class SignatureMethodModalComponent implements OnInit { + + status = 'WAITING'; + attempt = 1; + nbTry = 10; + interval: any; + + constructor( + public modalController: ModalController + ) { } + + ngOnInit(): void { + this.interval = setInterval(async () => { + console.log('attempt', this.attempt); + const res = await this.checkCertificate(); + if (res) { + this.status = 'SUCCESS'; + clearInterval(this.interval); + setTimeout(() => { + this.modalController.dismiss(true); + }, 1000); + } else if (this.attempt === this.nbTry) { + this.status = 'ERROR'; + clearInterval(this.interval); + setTimeout(() => { + this.modalController.dismiss(false); + }, 1000); + } + this.attempt++; + }, 1000); + } + + checkCertificate() { + return new Promise((resolve) => { + setTimeout(() => { + console.log('end request'); + resolve(false); + }, 800); + }); + } + +} diff --git a/src/frontend/app/service/signature-method/signature-method.service.ts b/src/frontend/app/service/signature-method/signature-method.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb6bdab7ef6b4a161a27c66f313202b1779fc87c --- /dev/null +++ b/src/frontend/app/service/signature-method/signature-method.service.ts @@ -0,0 +1,37 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { ModalController } from '@ionic/angular'; +import { SignatureMethodModalComponent } from './signature-method-modal.component'; + +@Injectable({ + providedIn: 'root' +}) +export class SignatureMethodService { + + constructor( + public http: HttpClient, + public modalController: ModalController + ) { } + + async checkAuthentication(userWorkflow: any) { + console.log(userWorkflow); + if (userWorkflow.signatureMode === 'rgs_2stars') { + const res = await this.openRgsAuth(); + return res; + } else { + return true; + } + } + + async openRgsAuth() { + return new Promise(async (resolve) => { + const modal = await this.modalController.create({ + component: SignatureMethodModalComponent, + componentProps: {} + }); + await modal.present(); + const { data } = await modal.onWillDismiss(); + resolve(data); + }); + } +} diff --git a/src/frontend/core/global.scss b/src/frontend/core/global.scss index 43f70364746333b5ff14935040d2b584398b52b6..665fef8ac22ec3179419fe90a521ce17feebe026 100644 --- a/src/frontend/core/global.scss +++ b/src/frontend/core/global.scss @@ -167,7 +167,7 @@ ion-icon { } } -.custom-alert-fullscreen .modal-wrapper{ +.custom-alert-fullscreen .modal-wrapper { width: 100%; height: 100%; } @@ -176,15 +176,15 @@ ion-icon { padding: 10px; display: flex; justify-content: center; - + ion-button { - margin: auto; - margin-left: 10px; - margin-right: 10px; - width: 150px; + margin: auto; + margin-left: 10px; + margin-right: 10px; + width: 150px; } ion-label { font-size: 13px; } - } \ No newline at end of file +} \ No newline at end of file