From 9182fa6cebc6f89991886c30f2264c5bc0088c89 Mon Sep 17 00:00:00 2001 From: Vincent BENOIT Date: Fri, 25 Nov 2022 20:43:59 +0100 Subject: [PATCH] passage de la configuration du fonctionnement du scheduler dans la page horaires et non plus dans la page parametres --- .../home/workspace/hours/hours.component.css | 11 +++- .../home/workspace/hours/hours.component.html | 7 +++ .../home/workspace/hours/hours.component.ts | 53 ++++++++++++++++++- .../parametres/parametres.component.html | 9 ---- .../parametres/parametres.component.ts | 13 +++-- 5 files changed, 74 insertions(+), 19 deletions(-) diff --git a/src/app/components/home/workspace/hours/hours.component.css b/src/app/components/home/workspace/hours/hours.component.css index f9e6e4e..d25fd8b 100644 --- a/src/app/components/home/workspace/hours/hours.component.css +++ b/src/app/components/home/workspace/hours/hours.component.css @@ -15,7 +15,7 @@ table { margin: 1rem; table-layout: fixed; align: center; - width: 80%; + width: 90%; border: 1px solid #cccccc; } @@ -31,5 +31,12 @@ tr { button { margin-top: 1rem; - width: 80%; + width: 90%; +} + +@media (max-width: 500px) { + tr { + text-align: center; + font-size:0.5em; + } } diff --git a/src/app/components/home/workspace/hours/hours.component.html b/src/app/components/home/workspace/hours/hours.component.html index 2b062d1..950fec4 100644 --- a/src/app/components/home/workspace/hours/hours.component.html +++ b/src/app/components/home/workspace/hours/hours.component.html @@ -6,6 +6,13 @@
+
+ + + {{operation}} + + +
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}} - - -
-
diff --git a/src/app/components/home/workspace/parametres/parametres.component.ts b/src/app/components/home/workspace/parametres/parametres.component.ts index b2df65b..c573542 100644 --- a/src/app/components/home/workspace/parametres/parametres.component.ts +++ b/src/app/components/home/workspace/parametres/parametres.component.ts @@ -19,7 +19,6 @@ export class ParametresComponent implements OnInit { pinNumber:string="0000"; isProcessing:boolean = true; defaultOp:string = 'Manuel ON'; - operations:string[] = ['Manuel ON', 'Manuel OFF', 'Horaires']; constructor(private fb:FormBuilder, private bs:BackendService, @@ -88,12 +87,12 @@ export class ParametresComponent implements OnInit { } let params:Parameters = {operation:'', - pin_actif:false, - code_pin:'', - num_autorized:'', - tone_duration:0, - dtmf_code:'', - dtmf_duration:0}; + pin_actif:false, + code_pin:'', + num_autorized:'', + tone_duration:0, + dtmf_code:'', + dtmf_duration:0}; params.operation = this.defaultOp; params.pin_actif = this.pinChecked; if (this.pinChecked == false) {