mise à jour de la page de paramétrage

This commit is contained in:
Vincent BENOIT
2022-10-10 17:35:07 +02:00
parent e1de9cfa5a
commit 93bfe8aadf
6 changed files with 84 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators, ValidatorFn, ValidationErrors, AbstractControl } from '@angular/forms';
import { Router } from '@angular/router';
import { BackendService } from '../../../../services/backend/backend.service';
import { Parameters } from '../../../../models/parameters.model';
import { ToastrService } from 'ngx-toastr';
@Component({
@@ -12,10 +13,9 @@ import { ToastrService } from 'ngx-toastr';
export class ParametresComponent implements OnInit {
paramsFG:FormGroup;
submitted:boolean=false;
PwPin:number = 4;
Pw:number = 9;
slideDisable:boolean=false;
pinChecked:boolean=false;
pinNumber:string="0000";
constructor(private fb:FormBuilder,
private bs:BackendService,
@@ -26,13 +26,35 @@ export class ParametresComponent implements OnInit {
this.paramsFG=this.fb.group({
num_accepted:["", [
Validators.required,
Validators.pattern('(?=[0-9]{9}).{' + this.Pw + '}'),
Validators.pattern('^[0-9]{9}$'),
]],
num_tone:["", [
Validators.required,
Validators.pattern('^[1-5]{1}$'),
]],
dtmf_code:["", [
Validators.required,
Validators.pattern('^[0-9A-D#*]{1}$'),
]],
dtmf_duration:["", [
Validators.required,
Validators.pattern('^[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5]$'),
]],
});
}
onUpdate(): void {
this.bs.retreiveParams().subscribe(
(data:Parameters) => {
this.paramsFG.get('num_accepted').setValue(data.num_autorized);
this.paramsFG.get('num_tone').setValue(data.tone_duration);
this.paramsFG.get('dtmf_code').setValue(data.dtmf_code);
this.paramsFG.get('dtmf_duration').setValue(data.dtmf_duration);
this.slideDisable = data.pin_actif;
this.pinChecked = data.pin_actif;
this.pinNumber = data.code_pin;
}, err => {
this.toast.error("Erreur de récupération des paramètres");
}
);
}
onSlideChanged(event: any): void {
@@ -42,11 +64,15 @@ export class ParametresComponent implements OnInit {
onCodeChanged(code: string): void {
// this called every time when user changed the code
}
onCodeCompleted(code: string): void {
// this called only if user entered full code
this.pinNumber = code;
}
onUpdate(): void {
}
}