Skip to content

Commit

Permalink
Ripristinata grafica configurazione applicazione.
Browse files Browse the repository at this point in the history
  • Loading branch information
pintorig committed May 28, 2021
1 parent a52f584 commit e9bb2ba
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,21 @@
<input matInput [placeholder]="voce.PASSWORD" formControlName="password_ctrl" autocomplete="off" required>
</mat-form-field>
</div>
<div *ngIf="sslAuth">
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup">
<mat-select #sslType placeholder="SSL Type" formControlName="ssl_ctrl" (selectionChange)="_onSslTypeChange(sslType)" [required]="auth && auth.value === SSL">
<mat-option [value]="CLIENT">Client</mat-option>
<mat-option [value]="SERVER">Server</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup">
<div *ngIf="_isSslAuth">
<div class="w-100" [formGroup]="fGroup">
<mat-slide-toggle #type formControlName="ssl_ctrl" color="accent" (change)="_onTypeChange(type)">{{ voce.AUTENTICAZIONE_CLIENT }}</mat-slide-toggle>
</div>
<mat-form-field class="w-100 mt-3" color="accent" [formGroup]="fGroup">
<input matInput [placeholder]="voce.TRUST_STORE_LOC" formControlName="tsLocation_ctrl" autocomplete="off" required>
</mat-form-field>
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup">
<input matInput [placeholder]="voce.TRUST_STORE_PWD" formControlName="tsPassword_ctrl" autocomplete="off" required>
</mat-form-field>
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup">
<input matInput [placeholder]="voce.KEY_STORE_LOC" formControlName="ksLocation_ctrl" autocomplete="off" [required]="sslTypeValue === CLIENT">
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup" *ngIf="_isSslClient">
<input matInput [placeholder]="voce.KEY_STORE_LOC" formControlName="ksLocation_ctrl" autocomplete="off" required>
</mat-form-field>
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup">
<input matInput [placeholder]="voce.KEY_STORE_PWD" formControlName="ksPassword_ctrl" autocomplete="off" [required]="sslTypeValue === CLIENT">
<mat-form-field class="w-100" color="accent" [formGroup]="fGroup" *ngIf="_isSslClient">
<input matInput [placeholder]="voce.KEY_STORE_PWD" formControlName="ksPassword_ctrl" autocomplete="off" required>
</mat-form-field>
</div>

Expand Down Expand Up @@ -132,4 +129,4 @@
</mat-card>
</div>
<div class="col-12 col-lg-2"></div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class ApplicazioneViewComponent implements IModalDialog, IFormComponent,
protected SSL = UtilService.TIPI_AUTENTICAZIONE.ssl;
protected CLIENT = UtilService.TIPI_SSL.client;
protected SERVER = UtilService.TIPI_SSL.server;
protected sslTypeValue: string = '';

protected versioni: any[] = UtilService.TIPI_VERSIONE_API;

Expand All @@ -40,7 +39,6 @@ export class ApplicazioneViewComponent implements IModalDialog, IFormComponent,

protected _attivaGestionePassword: boolean = false;


constructor(public gps: GovpayService, public us: UtilService) {
this._attivaGestionePassword = !!(UtilService.GESTIONE_PASSWORD && UtilService.GESTIONE_PASSWORD.ENABLED);
}
Expand Down Expand Up @@ -114,13 +112,16 @@ export class ApplicazioneViewComponent implements IModalDialog, IFormComponent,
if (item.auth.hasOwnProperty('tipo')) {
this._isSslAuth = true;
this.fGroup.controls['auth_ctrl'].setValue(this.SSL);
this.addSslTypeControls(item.auth.tipo);
this.addSslControls(item.auth.tipo);
(item.auth.tipo)?this.fGroup.controls['ssl_ctrl'].setValue(item.auth.tipo):null;
(item.auth.ksLocation)?this.fGroup.controls['ksLocation_ctrl'].setValue(item.auth.ksLocation):null;
(item.auth.ksPassword)?this.fGroup.controls['ksPassword_ctrl'].setValue(item.auth.ksPassword):null;
(item.auth.tsLocation)?this.fGroup.controls['tsLocation_ctrl'].setValue(item.auth.tsLocation):null;
(item.auth.tsPassword)?this.fGroup.controls['tsPassword_ctrl'].setValue(item.auth.tsPassword):null;
this.addSslControls();
this.fGroup.controls['ssl_ctrl'].setValue(item.auth.tipo === this.CLIENT);
this.fGroup.controls['tsLocation_ctrl'].setValue(item.auth.tsLocation);
this.fGroup.controls['tsPassword_ctrl'].setValue(item.auth.tsPassword);
if (item.auth.tipo === this.CLIENT) {
this.addSslClientControls();
this.fGroup.controls['ksLocation_ctrl'].setValue(item.auth.ksLocation);
this.fGroup.controls['ksPassword_ctrl'].setValue(item.auth.ksPassword);
this._isSslClient = true;
}
}
}
}
Expand Down Expand Up @@ -295,46 +296,40 @@ export class ApplicazioneViewComponent implements IModalDialog, IFormComponent,
this._isBasicAuth = true;
break;
case this.SSL:
this.addSslTypeControls(this.SERVER);
this.addSslControls(this.SERVER);
this.sslAuth = true;
this.addSslControls();
this._isSslAuth = true;
break;
}
}

protected _onSslTypeChange(target: any) {
this.sslTypeValue = target.value;
this.fGroup.controls['ksLocation_ctrl'].clearValidators();
this.fGroup.controls['ksPassword_ctrl'].clearValidators();
if (target.value === this.CLIENT) {
this.fGroup.controls['ksLocation_ctrl'].setValidators(Validators.required);
this.fGroup.controls['ksPassword_ctrl'].setValidators(Validators.required);
protected _onTypeChange(target) {
this._isSslClient = false;
this.removeSslClientControls();
if (target.checked === true) {
this._isSslClient = true;
this.addSslClientControls();
}
this.fGroup.controls['ksLocation_ctrl'].updateValueAndValidity();
this.fGroup.controls['ksPassword_ctrl'].updateValueAndValidity();
}

protected addBasicControls() {
this.fGroup.addControl('username_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('password_ctrl', new FormControl('', Validators.required));
this.fGroup.controls['username_ctrl'].updateValueAndValidity();
this.fGroup.controls['password_ctrl'].updateValueAndValidity();
}

protected addSslTypeControls(tipo: string) {
this.fGroup.addControl('ssl_ctrl', new FormControl(tipo, Validators.required));
this.fGroup.controls['ssl_ctrl'].updateValueAndValidity();
}

protected addSslControls(tipo: string) {
protected addSslControls() {
this.fGroup.addControl('ssl_ctrl', new FormControl(false, Validators.required));
this.fGroup.addControl('tsLocation_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('tsPassword_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('ksLocation_ctrl', new FormControl(''));
this.fGroup.addControl('ksPassword_ctrl', new FormControl(''));
this.fGroup.controls['tsLocation_ctrl'].updateValueAndValidity();
this.fGroup.controls['tsPassword_ctrl'].updateValueAndValidity();
this.fGroup.controls['ksLocation_ctrl'].updateValueAndValidity();
this.fGroup.controls['ksPassword_ctrl'].updateValueAndValidity();
}

protected addSslClientControls() {
this.fGroup.addControl('ksLocation_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('ksPassword_ctrl', new FormControl('', Validators.required));
}

protected removeSslClientControls() {
this.fGroup.removeControl('ksLocation_ctrl');
this.fGroup.removeControl('ksPassword_ctrl');
}

protected removeBasicControls() {
Expand All @@ -344,10 +339,10 @@ export class ApplicazioneViewComponent implements IModalDialog, IFormComponent,

protected removeSslControls() {
this.fGroup.removeControl('ssl_ctrl');
this.fGroup.removeControl('tsLocation_ctrl');
this.fGroup.removeControl('tsPassword_ctrl');
this.fGroup.removeControl('ksLocation_ctrl');
this.fGroup.removeControl('ksPassword_ctrl');
this.fGroup.removeControl('tsLocation_ctrl');
this.fGroup.removeControl('tsPassword_ctrl');
}

/**
Expand Down Expand Up @@ -414,4 +409,4 @@ export class ApplicazioneViewComponent implements IModalDialog, IFormComponent,

return _json;
}
}
}

0 comments on commit e9bb2ba

Please sign in to comment.