Commit 1a75ed7f authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #16956 TIME 0:40 check length of sources and security modes

parent 8434b614
......@@ -5,7 +5,7 @@
<mat-spinner style="margin:auto;"></mat-spinner>
</div>
<div *ngIf="!loading" class="userForm">
<mat-form-field appearance="fill">
<mat-form-field *ngIf="sources.length > 1" appearance="fill">
<mat-label>{{ 'lang.source' | translate }}</mat-label>
<mat-select #source [(ngModel)]="userOTP.sourceId" (selectionChange)="setCurrentSource($event.value)" required>
<mat-option *ngFor="let source of sources" [value]="source.id" >
......@@ -38,7 +38,7 @@
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-form-field *ngIf="currentSource.length > 1" appearance="fill">
<mat-label>{{ 'lang.securityMode' | translate }}</mat-label>
<mat-select #securityMode [(ngModel)]="userOTP.security"required>
<mat-option *ngFor="let mode of currentSource" [value]="mode" >
......
......@@ -51,6 +51,8 @@ export class CreateUserOtpComponent implements OnInit {
type: ''
};
loading: boolean = true;
constructor(
public translate: TranslateService,
public http: HttpClient,
......@@ -70,7 +72,11 @@ export class CreateUserOtpComponent implements OnInit {
tap((data: any) => {
if (data) {
this.sources = data.otp;
this.userOTP.sourceId = this.sources[0].id;
this.userOTP.type = this.sources[0].type;
this.setCurrentSource(this.sources[0].id);
}
this.loading = false;
resolve(true);
}),
catchError((err: any) => {
......@@ -99,5 +105,6 @@ export class CreateUserOtpComponent implements OnInit {
const selectedSource: any = this.sources.filter((item: any) => item.id === id)[0];
this.userOTP.type = selectedSource.type;
this.currentSource = selectedSource.securityModes;
this.userOTP.security = this.currentSource[0];
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment