mise à jour de la page de logs et correction de bugs sur les autres pages

This commit is contained in:
Vincent BENOIT
2022-10-24 11:58:56 +02:00
parent 01118e5d4e
commit d72b8d9294
11 changed files with 162 additions and 21 deletions

View File

@@ -6,8 +6,8 @@
form {
/*margin-left: 100px;*/
width: 50%;
min-width: 50%;
width: 70%;
min-width: 70%;
}
mat-label {

View File

@@ -49,9 +49,14 @@ export class AccountComponent implements OnInit {
this.bs.updatePasswd(data).subscribe(
data => {
this.toast.success("Mise à jour réussie");
}, error => {
this.toast.error("Erreur de mise à jour du mot de passe");
});
}, err => {
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error(err.error.description);
}
}
);
}
}

View File

@@ -33,7 +33,7 @@ export class HoursComponent implements OnInit {
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error("Erreur de récupération des horaires");
this.toast.error(err.error.description);
}
this.isProcessing = false;
}
@@ -48,7 +48,7 @@ export class HoursComponent implements OnInit {
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error("Erreur de mise à jour des horaires");
this.toast.error(err.error.description);
}
}
);

View File

@@ -0,0 +1,16 @@
.container {
/* display: flex; */
/*background-color: #b8b8b8;*/
margin-bottom: 100px;
overflow-x: hidden;
overflow-y: auto;
}
.process {
width: 100%;
height: 75%;
}
.mat-spinner {
margin-top: 3rem;
}

View File

@@ -1 +1,9 @@
<p>infos works!</p>
<div *ngIf="isProcessing" class="process"
fxLayout="column"
fxLayoutAlign="space-around center">
<mat-spinner></mat-spinner>
</div>
<div *ngIf="!isProcessing" class="container"
fxLayout="column"
fxLayoutAlign="space-around center">
</div>

View File

@@ -1,4 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { BackendService } from '../../../../services/backend/backend.service';
import { Log } from '../../../../models/log.model';
import { ToastrService } from 'ngx-toastr';
@Component({
selector: 'app-infos',
@@ -6,8 +10,11 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./infos.component.css']
})
export class InfosComponent implements OnInit {
isProcessing:boolean = true;
constructor() { }
constructor( private bs:BackendService,
private router:Router,
private toast:ToastrService ) { }
ngOnInit(): void {
}

View File

@@ -8,7 +8,11 @@
.process {
width: 100%;
height: 75%;
height: 100%;
}
.mat-spinner {
margin-top: 3rem;
}
.mat-card.scrollable-content {
@@ -45,3 +49,35 @@ div.ERROR {
margin-bottom: 0.2rem;
background-color: red;
}
.logHeaderDebug {
border-radius:5px;
padding: 0.45rem;
background-color: lightblue;
margin-bottom: 0.8rem;
font-size:smaller;
}
.logHeaderInfo {
border-radius:5px;
padding: 0.45rem;
background-color: lightgreen;
margin-bottom: 0.8rem;
font-size:smaller;
}
.logHeaderWarn {
border-radius:5px;
padding: 0.45rem;
background-color: orange;
margin-bottom: 0.8rem;
font-size:smaller;
}
.logHeaderErr {
border-radius:5px;
padding: 0.45rem;
background-color: red;
margin-bottom: 0.8rem;
font-size:smaller;
}

View File

@@ -1,4 +1,4 @@
<mat-tab-group animationDuration="0ms" (selectedTabChange)="onTabChanged($event)">
<mat-tab-group animationDuration="0ms" selectedIndex=0 (selectedTabChange)="onTabChanged($event)">
<mat-tab label="Configurateur.log">
<div *ngIf="isProcessing" class="process"
fxLayout="column"
@@ -9,7 +9,13 @@
fxLayout="column"
fxLayoutAlign="space-around center">
<mat-card class="scrollable-content">
<mat-card-content #myList>
<mat-card-title fxLayout="row" fxLayoutAlign="space-around center">
<div class="logHeaderDebug mat-elevation-z2"><b>DEBUG</b></div>
<div class="logHeaderInfo mat-elevation-z2"><b>INFO</b></div>
<div class="logHeaderWarn mat-elevation-z2"><b>WARNING</b></div>
<div class="logHeaderErr mat-elevation-z2"><b>ERROR</b></div>
</mat-card-title>
<mat-card-content>
<ng-container *ngIf="confLogs">
<div *ngFor="let log of confLogs; let last = last" class={{log.gravity}}>
{{log.datetime}} - {{log.msg}}<br>
@@ -21,6 +27,30 @@
</div>
</mat-tab>
<mat-tab label="KineIntercom.log">
plop2
<div *ngIf="isProcessing" class="process"
fxLayout="column"
fxLayoutAlign="space-around center">
<mat-spinner></mat-spinner>
</div>
<div *ngIf="!isProcessing" class="container"
fxLayout="column"
fxLayoutAlign="space-around center">
<mat-card class="scrollable-content">
<mat-card-title fxLayout="row" fxLayoutAlign="space-around center">
<div class="logHeaderDebug mat-elevation-z2"><b>DEBUG</b></div>
<div class="logHeaderInfo mat-elevation-z2"><b>INFO</b></div>
<div class="logHeaderWarn mat-elevation-z2"><b>WARNING</b></div>
<div class="logHeaderErr mat-elevation-z2"><b>ERROR</b></div>
</mat-card-title>
<mat-card-content>
<ng-container *ngIf="appLogs">
<div *ngFor="let log of appLogs; let last = last" class={{log.gravity}}>
{{log.datetime}} - {{log.msg}}<br>
{{last ? scrollToBottom(): ''}}
</div>
</ng-container>
</mat-card-content>
</mat-card>
</div>
</mat-tab>
</mat-tab-group>

View File

@@ -13,7 +13,6 @@ export class LogsComponent implements OnInit {
isProcessing:boolean = true;
confLogs:Log[];
appLogs:Log[];
//@ViewChild('myList') myList: ElementRef;
gravity:string[] = ['DEBUG', 'INFO', 'WARNING', 'ERROR'];
constructor( private bs:BackendService,
@@ -21,18 +20,29 @@ export class LogsComponent implements OnInit {
private toast:ToastrService ) { }
ngOnInit(): void {
this.isProcessing = false;
this.bs.retreiveConfLogs().subscribe(
(datas:Log[]) => {
this.confLogs = datas;
this.isProcessing = false;
}, err => {
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error(err.error.description);
}
}
);
}
scrollToBottom(): void {
//this.myList.nativeElement.scrollTop = this.myList.nativeElement.scrollHeight;
console.log("plop");
}
onTabChanged(event:any): void {
switch(event.tab.textLabel) {
case 'Configurateur.log':
console.log("configurateur");
this.isProcessing = true;
this.bs.retreiveConfLogs().subscribe(
(datas:Log[]) => {
this.confLogs = datas;
@@ -41,14 +51,26 @@ export class LogsComponent implements OnInit {
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error("Erreur de mise à jour des horaires");
this.toast.error(err.error.description);
}
}
);
break;
case 'KineIntercom.log':
console.log("kineintercom");
this.isProcessing = true;
this.bs.retreiveAppLogs().subscribe(
(datas:Log[]) => {
this.appLogs = datas;
this.isProcessing = false;
}, err => {
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error(err.error.description);
}
}
);
break;
default:
break;

View File

@@ -54,8 +54,11 @@ export class ParametresComponent implements OnInit {
this.pinNumber = data.code_pin;
this.isProcessing = false;
}, err => {
this.toast.error("Erreur de récupération des paramètres");
this.isProcessing = false;
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error(err.error.description);
}
}
);
}
@@ -100,7 +103,11 @@ export class ParametresComponent implements OnInit {
data => {
this.toast.success("Mise à jour des paramètres réussie");
}, err => {
this.toast.error("Erreur de mise à jour des paramètres");
if(err.status == 401) {
this.router.navigateByUrl("/login");
} else {
this.toast.error(err.error.description);
}
}
);
}

View File

@@ -126,6 +126,16 @@ export class BackendService {
withCredentials: true
};
return this.http.get<Log[]>(host+"/api/configurateur/conf_logs", options);
}
retreiveAppLogs():Observable<Log[]> {
let host=environment.host;
const options = {
headers: new HttpHeaders({
'Content-Type' : 'application/json',
}),
withCredentials: true
};
return this.http.get<Log[]>(host+"/api/configurateur/app_logs", options);
}
}