diff --git a/src/frontend/app/administration/parameter/other/checkSaeInterconnection/check-sae-interconnection.component.ts b/src/frontend/app/administration/parameter/other/checkSaeInterconnection/check-sae-interconnection.component.ts index 7f258694485e0ad119070f5f83d096f38cebcdf7..02a15b1223bbcccca949fdf7ad0f0a94012e920b 100644 --- a/src/frontend/app/administration/parameter/other/checkSaeInterconnection/check-sae-interconnection.component.ts +++ b/src/frontend/app/administration/parameter/other/checkSaeInterconnection/check-sae-interconnection.component.ts @@ -42,7 +42,7 @@ export class CheckSaeInterconnectionComponent implements OnInit { tap(() => { this.loading = false; this.hasError = false; - this.result = '<b>' + this.translate.instant('lang.interconnectionSuccess') + '</b> '; + this.result = this.translate.instant('lang.interconnectionSuccess'); }), catchError((err: any) => { this.hasError = true; diff --git a/src/frontend/app/administration/parameter/other/other-parameters.component.html b/src/frontend/app/administration/parameter/other/other-parameters.component.html index 5d4e10df64a929924166ecb89c7961f2baaa028b..ca32b22c1fbaa9f6cd5a5cf0ca9be34b868f0643 100644 --- a/src/frontend/app/administration/parameter/other/other-parameters.component.html +++ b/src/frontend/app/administration/parameter/other/other-parameters.component.html @@ -140,13 +140,22 @@ </mat-expansion-panel-header> <mat-tab-group> <mat-tab [label]="saeEnabled"> + <app-maarch-message [mode]="'info'" [content]="'lang.configSaeInfo' | translate" style="font-size: 14px; height: 50%; margin-bottom: 10px;"></app-maarch-message> + <mat-slide-toggle style="margin: 15px;" [checked]="saeEnabled === 'maarchRM'" color="primary" (change)="switchSae()"> + {{'lang.switchSae' | translate}} + </mat-slide-toggle> + <mat-form-field *ngIf="saeEnabled !== 'maarchRM'" appearance="outline"> + <mat-label>{{'lang.sae' | translate}}</mat-label> + <input required matInput type="text" [title]="'lang.sae' | translate" + [value]="saeConfig['maarchRM']['sae']" [formControl]="saeConfig['maarchRM']['sae']"> + </mat-form-field> <ng-container *ngFor="let sae of saeConfig[saeEnabled] | keyvalue: originalOrder"> <div *ngIf="saeEnabled === 'maarchRM'"> <div *ngIf="!sae.key.includes('status')" class="form-group"> <div class="col-md-6"> <mat-form-field appearance="outline"> <mat-label>{{'lang.' + sae.key |translate}}</mat-label> - <input matInput type="text" [title]="'lang.' + sae.key |translate" + <input required matInput type="text" [readonly]="sae.key === 'sae'" [title]="'lang.' + sae.key |translate" [value]="saeConfig[saeEnabled][sae.key]" [formControl]="saeConfig[saeEnabled][sae.key]"> </mat-form-field> </div> @@ -155,7 +164,7 @@ <div class="col-md-12"> <mat-form-field appearance="outline"> <mat-label>{{'lang.' + sae.key |translate}}</mat-label> - <mat-select [formControl]="saeConfig[saeEnabled][sae.key]"> + <mat-select required [formControl]="saeConfig[saeEnabled][sae.key]"> <mat-option *ngFor="let status of statuses" [value]="status.statusId" [id]="status.id"> {{ status.label }} </mat-option> @@ -269,13 +278,20 @@ </mat-expansion-panel> </div> </ng-container> + <div *ngIf="saeEnabled === 'maarchRM'" class="form-group"> + <div class="col-md-12"> + <mat-hint align="start" style="font-size: 12px; color: rgb(138, 137, 137)" [innerHTML]="'lang.mustHaveforTest' | translate"></mat-hint> + </div> + </div> <div class="form-group"> <div class="col-sm-12" style="text-align:center;"> - <button mat-raised-button color="primary" [disabled]="loading || !isValid()" (click)="saveSaeConfig()"> - {{(saeEnabled === 'maarchRM' ? 'lang.validateConfig' : 'lang.validate') | translate}} + <button *ngIf="saeEnabled" mat-raised-button color="primary" [disabled]="loading || !allValid()" (click)="saveSaeConfig()"> + {{'lang.validate' | translate}} + </button> + <button *ngIf="saeEnabled === 'maarchRM'" mat-raised-button color="primary" [disabled]="loading || !isValid()" (click)="saveSaeConfig('test')"> + {{'lang.test' | translate}} </button> - <mat-slide-toggle style="padding-left: 10px; padding-top: 10px;" [checked]="saeEnabled === 'maarchRM'" color="primary" (change)="switchSae()"> - {{'lang.switchSae' | translate}}</mat-slide-toggle> + </div> </div> </mat-tab> diff --git a/src/frontend/app/administration/parameter/other/other-parameters.component.ts b/src/frontend/app/administration/parameter/other/other-parameters.component.ts index fa4c2b0befbea1679a12b1089430c581ac8d67c4..1eca422089418f02a527060713b99b80c5c41ff6 100644 --- a/src/frontend/app/administration/parameter/other/other-parameters.component.ts +++ b/src/frontend/app/administration/parameter/other/other-parameters.component.ts @@ -84,7 +84,7 @@ export class OtherParametersComponent implements OnInit { maarchRM: { sae: new FormControl('MaarchRM'), urlSAEService: new FormControl('https://demo-ap.maarchrm.com'), - token: new FormControl('phdF9WkJuTKkDuPXoqDZuCFEQT7En7YqsVROsdD1HoNZV7jD5+XyCtKbhx0Chb4s3skokalo0wEn48DE3M4kGrAceH0/XFbyLZVRoVOO+Y/wxyRdE1QJleI8yijEfGut'), + token: new FormControl(''), senderOrgRegNumber: new FormControl('org_987654321_DGS_SA'), accessRuleCode: new FormControl('AR039'), certificateSSL: new FormControl(''), @@ -622,6 +622,7 @@ export class OtherParametersComponent implements OnInit { tap((data: any) => { if (data !== undefined) { this.saeEnabled = data.sae.toLowerCase() === 'maarchrm' ? 'maarchRM' : 'externalSAE'; + this.saeConfig['maarchRM']['sae'].setValue(this.saeEnabled === 'externalSAE' ? 'externalSAE' : 'maarchRM'); if (this.saeEnabled === 'maarchRM') { this.saeConfig[this.saeEnabled] = { sae: new FormControl(data.sae), @@ -651,7 +652,7 @@ export class OtherParametersComponent implements OnInit { }); } - saveSaeConfig() { + saveSaeConfig(action: string = 'validate') { this.loading = true; this.hasError = false; this.http.put('../rest/seda/configuration', this.formatSaeConfig()).pipe( @@ -669,7 +670,7 @@ export class OtherParametersComponent implements OnInit { }) ).subscribe(); - if (!this.hasError && this.saeEnabled === 'maarchRM') { + if (!this.hasError && this.saeEnabled === 'maarchRM' && action === 'test') { this.dialog.open(CheckSaeInterconnectionComponent, { panelClass: 'maarch-modal', disableClose: true, @@ -706,7 +707,6 @@ export class OtherParametersComponent implements OnInit { }); } }); - maarchRM['sae'] = this.saeEnabled !== 'maarchRM' ? 'external' : this.saeConfig['maarchRM']['sae'].value; return objToSend = { ... maarchRM, externalSAE: externalSAE @@ -741,6 +741,7 @@ export class OtherParametersComponent implements OnInit { switchSae() { this.saeEnabled = this.saeEnabled === 'maarchRM' ? 'externalSAE' : 'maarchRM'; + this.saeConfig['maarchRM']['sae'].setValue(this.saeEnabled === 'externalSAE' ? 'externalSAE' : 'maarchRM'); } addValue(externalData: string) { @@ -783,10 +784,18 @@ export class OtherParametersComponent implements OnInit { } isValid() { + return !this.functions.empty(this.saeConfig['maarchRM']['sae'].value) && !this.functions.empty(this.saeConfig['maarchRM']['urlSAEService'].value) && !this.functions.empty(this.saeConfig['maarchRM']['token'].value); + } + + allValid() { if (this.saeEnabled === 'maarchRM') { - return !this.functions.empty(this.saeConfig['maarchRM']['sae'].value) && !this.functions.empty(this.saeConfig['maarchRM']['urlSAEService'].value) && !this.functions.empty(this.saeConfig['maarchRM']['token'].value); - } else if (this.saeEnabled === 'externalSAE') { - return this.retentionRules.every((item: any) => !this.functions.empty(item.label) && !this.functions.empty(item.id)) && this.archiveEntities.every((item: any) => !this.functions.empty(item.label) && !this.functions.empty(item.id)) && this.archivalAgreements.every((item: any) => !this.functions.empty(item.label) && !this.functions.empty(item.id)); + return Object.keys(this.saeConfig['maarchRM']).every((item: any) => !this.functions.empty(this.saeConfig['maarchRM'][item].value)); + } else { + return this.retentionRules.every((item: any) => !this.functions.empty(item.label) && !this.functions.empty(item.id)) && + this.archiveEntities.every((item: any) => !this.functions.empty(item.label) && !this.functions.empty(item.id)) && + this.archivalAgreements.every((item: any) => !this.functions.empty(item.label) && !this.functions.empty(item.id)) && + !this.functions.empty(this.saeConfig['maarchRM']['sae'].value); + } } } diff --git a/src/lang/lang-en.json b/src/lang/lang-en.json index eae28939102cf85f5126c0a3c28f82e118239c87..4f21033dcc200655408ea20d2a001ab8e5cbbe34 100644 --- a/src/lang/lang-en.json +++ b/src/lang/lang-en.json @@ -2541,5 +2541,7 @@ "saeInterconnectionTest": "Interconnection with your EAS", "interconnectionFailed": "<b>Interconnection with Maarch RM failed.</b> Error when calling Maarch RM server", "interconnectionSuccess": "Successful interconnection with Maarch RM", - "switchSae": "Switch to Maarch RM" + "switchSae": "Configure Maarch RM", + "configSaeInfo": "For more information on setting up an electronic filing system.Consult the documentation : <a href=\"http://docs.maarch.org/MaarchCourrier/guat/guat_exploitation/Seda_send.html\" target=\"_blank\" class=\"link\"> Configure an SAE < / a>", + "mustHaveforTest": "In order to test the interconnection with Maarch RM, it is necessary to fill in the fields: <b> API address </b> and <b> API key </b>." } diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index 8b17df8530764989abd3084ea77fe09e37de11ad..18f7c3ffea11ee70ed4dae1f18d945d1a4a63aac 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -2539,5 +2539,7 @@ "saeInterconnectionTest": "Interconnexion avec votre SAE", "interconnectionFailed": "<b>L'interconnexion avec Maarch RM a échouée.</b> Erreur lors de l'appel au serveur Maarch RM", "interconnectionSuccess": "Interconnexion réussie avec Maarch RM", - "switchSae": "Passer à Maarch RM" + "switchSae": "Configurer Maarch RM", + "configSaeInfo": "Pour plus d'informations sur la configuration d'un système d'archivage électronique. Consulter la documentation : <a href=\"http://docs.maarch.org/MaarchCourrier/guat/guat_exploitation/Seda_send.html\" target=\"_blank\" class=\"link\">Configurer un SAE</a>", + "mustHaveforTest": "Afin de tester l'interconnexion avec Maarch RM, il est nécessaire de remplir les champs: <b>Adresse de l'API</b> et <b>Jeton d'accès</b>." }