From 5a3b0df27d009d2812adcb6e926487b9d94a77cc Mon Sep 17 00:00:00 2001 From: Vincent BENOIT Date: Mon, 28 Nov 2022 11:37:22 +0100 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20de=20la=20page=20d'infos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/workspace/infos/infos.component.css | 13 +++- .../home/workspace/infos/infos.component.html | 60 ++++++++++++------- .../home/workspace/infos/infos.component.ts | 39 ++++++++++++ src/app/services/backend/backend.service.ts | 22 +++++++ 4 files changed, 112 insertions(+), 22 deletions(-) diff --git a/src/app/components/home/workspace/infos/infos.component.css b/src/app/components/home/workspace/infos/infos.component.css index 9ebeecb..f24cb9e 100644 --- a/src/app/components/home/workspace/infos/infos.component.css +++ b/src/app/components/home/workspace/infos/infos.component.css @@ -18,7 +18,7 @@ margin-bottom: 0.5rem; width: 85%; } - + .info-title { width: 100%; } @@ -33,3 +33,14 @@ width: 85%; } +.control-card { + margin-top: 0.5rem; + margin-bottom: 0.5rem; + width: 85%; +} + +button { + /*display: block;*/ + width: 89%; + margin-top: 1.5rem; +} diff --git a/src/app/components/home/workspace/infos/infos.component.html b/src/app/components/home/workspace/infos/infos.component.html index ad22858..b66abb8 100644 --- a/src/app/components/home/workspace/infos/infos.component.html +++ b/src/app/components/home/workspace/infos/infos.component.html @@ -6,6 +6,15 @@
+ + +
+ Processus InterCOM: +
check_circle
+
cancel
+
+
+
@@ -41,7 +50,7 @@
Mémoire utilisée: {{infos.system.used_mem}} Mo - ({{infos.system.percent_used_mem}}%) + ({{infos.system.percent_used_mem}}%)
Disque total: @@ -54,7 +63,7 @@
Disque utilisé: {{infos.system.used_disk}} Mo - ({{infos.system.percent_used_disk}}%) + ({{infos.system.percent_used_disk}}%)
@@ -84,23 +93,32 @@
-

Contrôle

-
- Opérateur: - {{infos.operator}} -
-
- Provider: - {{infos.provider}} -
-
- Signal: - - ({{infos.signal_qos}}) -
-
- carte SIM: -
check_circle
-
cancel
-
+ + + + Contrôle + + + +
+ Opérateur: + {{infos.operator}} +
+
+ Provider: + {{infos.provider}} +
+
+ Signal: + {{infos.signal_dbm}}dbm + ({{infos.signal_qos}}) +
+
+ carte SIM: +
check_circle
+
cancel
+
+
+
+
diff --git a/src/app/components/home/workspace/infos/infos.component.ts b/src/app/components/home/workspace/infos/infos.component.ts index cdbd429..638d394 100644 --- a/src/app/components/home/workspace/infos/infos.component.ts +++ b/src/app/components/home/workspace/infos/infos.component.ts @@ -14,13 +14,26 @@ export class InfosComponent implements OnInit { cpu_color:string = "green"; mem_color:string = "green"; disk_color:string = "green"; + qos_color:string = "green"; isProcessing:boolean = true; + isAlive:boolean = false; constructor( private bs:BackendService, private router:Router, private toast:ToastrService ) { } ngOnInit(): void { + this.bs.processAlive().subscribe( + data => { + console.log("data:", data); + }, err => { + if(err.status == 401) { + this.router.navigateByUrl("/login"); + } else { + this.toast.error(err.error.description); + } + } + ) this.bs.retreiveInfos().subscribe( (data:Info) => { this.infos = data; @@ -29,16 +42,28 @@ export class InfosComponent implements OnInit { } else if(data.system.percent_used_mem > 80) { this.mem_color = "red"; } else {} + if(data.system.cpu_usage >= 70) { this.cpu_color = "orange"; } else if(data.system.cpu_usage > 80) { this.cpu_color = "red"; } else {} + if(data.system.percent_used_disk >= 50) { this.disk_color = "orange"; } else if(data.system.percent_used_disk > 80) { this.disk_color = "red"; } else {} + + if(data.signal_qos == "Marginal") { + this.qos_color = "red"; + } else if(data.signal_qos == "OK") { + this.qos_color = "orange"; + } else if(data.signal_qos == "Good") { + this.qos_color = "blue"; + } else if(data.signal_qos == "Excellent") { + this.qos_color = "green"; + } else {} this.isProcessing = false; }, err => { if(err.status == 401) { @@ -50,4 +75,18 @@ export class InfosComponent implements OnInit { ); } + onReboot():void { + this.bs.rebootSys().subscribe( + data => { + this.toast.info("Redémarrage du système en cours ..."); + this.router.navigateByUrl("/login"); + }, err => { + if(err.status == 401) { + this.router.navigateByUrl("/login"); + } else { + this.toast.error(err.error.description); + } + } + ) + } } diff --git a/src/app/services/backend/backend.service.ts b/src/app/services/backend/backend.service.ts index 6c346b2..4d23d67 100644 --- a/src/app/services/backend/backend.service.ts +++ b/src/app/services/backend/backend.service.ts @@ -150,4 +150,26 @@ export class BackendService { }; return this.http.get(host+"/api/configurateur/infos", options); } + + processAlive():Observable { + let host=environment.host; + const options = { + headers: new HttpHeaders({ + 'Content-Type' : 'application/json', + }), + withCredentials: true + }; + return this.http.get(host+"/api/configurateur/alive", options); + } + + rebootSys():Observable { + let host=environment.host; + const options = { + headers: new HttpHeaders({ + 'Content-Type' : 'application/json', + }), + withCredentials: true + }; + return this.http.post(host+"/api/configurateur/reboot", {}, options); + } }