diff --git a/src/app/components/home/workspace/hours/hours.component.ts b/src/app/components/home/workspace/hours/hours.component.ts
index dbdd2a9..c5becba 100644
--- a/src/app/components/home/workspace/hours/hours.component.ts
+++ b/src/app/components/home/workspace/hours/hours.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { BackendService } from '../../../../services/backend/backend.service';
import { Scheduler, Horaire } from '../../../../models/scheduler.model';
+import { Parameters } from '../../../../models/parameters.model';
import { ToastrService } from 'ngx-toastr';
import { Observable, throwError } from 'rxjs';
import { catchError, map, startWith } from 'rxjs/operators';
@@ -17,6 +18,14 @@ export class HoursComponent implements OnInit {
schedCols:number = 0;
schedRows:number = 0;
colorFlag:string = 'red';
+ defaultOp:string = 'Manuel ON';
+ operations:string[] = ['Manuel ON', 'Manuel OFF', 'Horaires'];
+ num_auto:string = "";
+ tone_duration:number = 0;
+ dtmf_code:string = "";
+ dtmf_duration:number = 0;
+ pinChecked:boolean = false;
+ pinNumber:string = "";
constructor( private bs:BackendService,
private router:Router,
@@ -28,6 +37,24 @@ export class HoursComponent implements OnInit {
this.schedule = datas;
this.schedCols = Object.keys(datas).length;
this.schedRows = Object.keys(datas[0].horaires).length;
+ }, err => {
+ if(err.status == 401) {
+ this.router.navigateByUrl("/login");
+ } else {
+ this.toast.error(err.error.description);
+ }
+ this.isProcessing = false;
+ }
+ );
+ this.bs.retreiveParams().subscribe(
+ (data:Parameters) => {
+ this.num_auto = data.num_autorized;
+ this.tone_duration = data.tone_duration;
+ this.dtmf_code = data.dtmf_code;
+ this.dtmf_duration = data.dtmf_duration;
+ this.defaultOp = data.operation;
+ this.pinChecked = data.pin_actif;
+ this.pinNumber = data.code_pin;
this.isProcessing = false;
}, err => {
if(err.status == 401) {
@@ -41,9 +68,33 @@ export class HoursComponent implements OnInit {
}
onUpdate(): void {
+ let params:Parameters = {operation:'',
+ pin_actif:false,
+ code_pin:'',
+ num_autorized:'',
+ tone_duration:0,
+ dtmf_code:'',
+ dtmf_duration:0};
+ params.operation = this.defaultOp;
+ params.pin_actif = this.pinChecked;
+ params.code_pin = this.pinNumber;
+ params.num_autorized = this.num_auto;
+ params.tone_duration = this.tone_duration;
+ params.dtmf_code = this.dtmf_code;
+ params.dtmf_duration = this.dtmf_duration;
this.bs.updateSchedulers(this.schedule).subscribe(
data => {
- this.toast.success("Mise à jour des horaires réussie");
+ this.bs.updateParams(params).subscribe(
+ data => {
+ this.toast.success("Mise à jour des horaires réussie");
+ }, err => {
+ if(err.status == 401) {
+ this.router.navigateByUrl("/login");
+ } else {
+ this.toast.error(err.error.description);
+ }
+ }
+ );
}, err => {
if(err.status == 401) {
this.router.navigateByUrl("/login");
diff --git a/src/app/components/home/workspace/parametres/parametres.component.html b/src/app/components/home/workspace/parametres/parametres.component.html
index b8f6342..6fbf890 100644
--- a/src/app/components/home/workspace/parametres/parametres.component.html
+++ b/src/app/components/home/workspace/parametres/parametres.component.html
@@ -6,15 +6,6 @@
-
-
-
-
- {{operation}}
-
-
-
-