ajout d'un timer lors de l'action de mise à jour pour les pages account, paramètres et hours
This commit is contained in:
@@ -18,6 +18,10 @@ export class ParametresComponent implements OnInit {
|
||||
pinChecked:boolean=false;
|
||||
pinNumber:string="0000";
|
||||
isProcessing:boolean = true;
|
||||
isDisabled:boolean = true;
|
||||
timeLeft:number = 0;
|
||||
buttonText:string = "Mise à jour";
|
||||
interval:any;
|
||||
|
||||
constructor(private fb:FormBuilder,
|
||||
private bs:BackendService,
|
||||
@@ -54,6 +58,7 @@ export class ParametresComponent implements OnInit {
|
||||
this.pinChecked = data.pin_actif;
|
||||
this.pinNumber = data.code_pin;
|
||||
this.isProcessing = false;
|
||||
this.isDisabled = false;
|
||||
}, err => {
|
||||
if(err.status == 401) {
|
||||
this.router.navigateByUrl("/login");
|
||||
@@ -78,6 +83,22 @@ export class ParametresComponent implements OnInit {
|
||||
this.pinNumber = code;
|
||||
}
|
||||
|
||||
setTimeoutDisabledButton(timeout:number): void {
|
||||
this.timeLeft = timeout;
|
||||
this.isDisabled = true;
|
||||
this.buttonText = "Mise à jour" + " ... (" + this.timeLeft + ")";
|
||||
this.interval = setInterval(() => {
|
||||
if(this.timeLeft > 0) {
|
||||
this.timeLeft--;
|
||||
this.buttonText = "Mise à jour" + " ... (" + this.timeLeft + ")";
|
||||
} else {
|
||||
this.isDisabled = false;
|
||||
this.buttonText = "Mise à jour";
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
|
||||
onUpdate(): void {
|
||||
if(this.paramsFG.invalid) {
|
||||
console.log("Form invalid !!");
|
||||
@@ -101,6 +122,7 @@ export class ParametresComponent implements OnInit {
|
||||
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.setTimeoutDisabledButton(5);
|
||||
this.bs.updateParams(params).subscribe(
|
||||
data => {
|
||||
this.toast.success("Mise à jour des paramètres réussie");
|
||||
|
||||
Reference in New Issue
Block a user