passage de la configuration du fonctionnement du scheduler dans la page horaires et non plus dans la page parametres

This commit is contained in:
2022-11-25 20:43:59 +01:00
parent f4f903421e
commit 9182fa6ceb
5 changed files with 74 additions and 19 deletions

View File

@@ -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;
}
}

View File

@@ -6,6 +6,13 @@
<div *ngIf="!isProcessing" class="container"
fxLayout="column"
fxLayoutAlign="space-around center">
<div style="margin-top:1rem; width: 90%;">
<mat-radio-group [(ngModel)]="defaultOp" fxLayout="row" fxLayoutAlign="space-around center">
<mat-radio-button style="margin: 10px; font-size: normal;" *ngFor="let operation of operations" [value]="operation">
{{operation}}
</mat-radio-button>
</mat-radio-group>
</div>
<table border="0" cellspacing="1" cellpadding="1">
<thead>
<tr>

View File

@@ -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");

View File

@@ -6,15 +6,6 @@
<div *ngIf="!isProcessing" class="container"
fxLayout="column"
fxLayoutAlign="space-around center">
<section style="margin-top:1rem; width: 70%;">
<label style="margin-left: 10px; font-size: smaller;">Fonctionnement:</label>
<mat-radio-group [(ngModel)]="defaultOp">
<mat-radio-button style="margin: 10px; font-size: smaller;" *ngFor="let operation of operations" [value]="operation">
{{operation}}
</mat-radio-button>
</mat-radio-group>
</section>
<!-- Params Form -->
<form [formGroup]="paramsFG"
fxLayout="column">

View File

@@ -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) {