ajout de la mise à jour des paramètres

This commit is contained in:
Vincent BENOIT
2022-10-11 09:56:24 +02:00
parent 93bfe8aadf
commit fb402ad1ad
2 changed files with 39 additions and 1 deletions

View File

@@ -72,7 +72,33 @@ export class ParametresComponent implements OnInit {
}
onUpdate(): void {
if(this.paramsFG.invalid) {
console.log("Form invalid !!");
return;
}
let params:Parameters = {pin_actif:false,
code_pin:'',
num_autorized:'',
tone_duration:0,
dtmf_code:'',
dtmf_duration:0};
params.pin_actif = this.pinChecked;
if (this.pinChecked == false) {
params.code_pin = '0000';
} else {
params.code_pin = this.pinNumber;
}
params.num_autorized = this.paramsFG.get('num_accepted').value;
params.tone_duration = this.paramsFG.get('num_tone').value;
params.dtmf_code = this.paramsFG.get('dtmf_code').value;
params.dtmf_duration = this.paramsFG.get('dtmf_duration').value;
this.bs.updateParams(params).subscribe(
data => {
this.toast.success("Mise à jour des paramètres réussie");
}, err => {
this.toast.error("Erreur de mise à jour des paramètres");
}
);
}
}

View File

@@ -79,4 +79,16 @@ export class BackendService {
};
return this.http.get<Parameters>(host+"/api/configurateur/params", options);
}
updateParams(val:Parameters):Observable<any> {
let host=environment.host;
const options = {
headers: new HttpHeaders({
'Content-Type' : 'application/json',
}),
withCredentials: true
};
return this.http.post<any>(host+"/api/configurateur/update_params", val, options);
}
}