From 3599a40edeb8cad09b60c92508724fd51e841ec9 Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Mon, 24 Mar 2025 12:37:44 +0100 Subject: [PATCH] Enhance Global Status component to display detailed repository status including RAM and CPU usage --- .../global-status.component.html | 35 ++++++++++++++----- .../global-status/global-status.component.ts | 35 +++++++++++++++++-- .../status-tab/status-tab.component.html | 24 +++++++++++++ .../status-tab/status-tab.component.ts | 4 +++ 4 files changed, 88 insertions(+), 10 deletions(-) diff --git a/ogWebconsole/src/app/components/global-status/global-status.component.html b/ogWebconsole/src/app/components/global-status/global-status.component.html index d185adb..7ffc407 100644 --- a/ogWebconsole/src/app/components/global-status/global-status.component.html +++ b/ogWebconsole/src/app/components/global-status/global-status.component.html @@ -40,14 +40,33 @@ - -
-
    -
  • - {{ repository.name }} -
  • -
-
+ + + +
+ + +
+
+
diff --git a/ogWebconsole/src/app/components/global-status/global-status.component.ts b/ogWebconsole/src/app/components/global-status/global-status.component.ts index 7b8b6eb..78d6545 100644 --- a/ogWebconsole/src/app/components/global-status/global-status.component.ts +++ b/ogWebconsole/src/app/components/global-status/global-status.component.ts @@ -22,6 +22,7 @@ export class GlobalStatusComponent implements OnInit { view: [number, number] = [400, 220]; repositoriesUrl: string; repositories: any[] = []; + repositoryStatuses: { [key: string]: any } = {}; ogBootApiUrl: string; ogBootDiskUsage: any = {}; @@ -99,6 +100,9 @@ export class GlobalStatusComponent implements OnInit { this.http.get(`${this.repositoriesUrl}?page=1&itemsPerPage=10`).subscribe( data => { this.repositories = data['hydra:member']; + this.repositories.forEach(repository => { + this.loadRepositoryStatus(repository.id); + }); this.loading = false; }, error => { @@ -108,6 +112,30 @@ export class GlobalStatusComponent implements OnInit { ); } + loadRepositoryStatus(repositoryId: string): void { + this.http.get(`${this.baseUrl}/image-repositories/server/${repositoryId}/status`).subscribe( + data => { + const output = data.output; + this.repositoryStatuses[repositoryId] = { + ...output, + disk: { + ...output.disk, + used: parseFloat(output.disk.used), + available: parseFloat(output.disk.available) + }, + ram: { + ...output.ram, + used: parseFloat(output.ram.used), + available: parseFloat(output.ram.available) + } + }; + }, + error => { + console.error(`Error fetching status for repository ${repositoryId}`, error); + } + ); + } + loadOgBootStatus(): void { this.isDhcp = false; this.loadStatus(this.ogBootApiUrl, this.ogBootDiskUsage, this.ogBootServicesStatus, this.ogBootDiskUsageChartData, this.installedOgLives, this.isDhcp); @@ -121,9 +149,12 @@ export class GlobalStatusComponent implements OnInit { onTabChange(event: MatTabChangeEvent): void { if (event.tab.textLabel === 'OgBoot') { this.loadOgBootStatus(); - } - else if (event.tab.textLabel === 'Dhcp') { + } else if (event.tab.textLabel === 'Dhcp') { this.loadDhcpStatus(); + } else if (event.tab.textLabel === 'Repositorios') { + if (this.repositories.length === 0) { + this.loadRepositories(); + } } } } \ No newline at end of file diff --git a/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.html b/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.html index c0cb099..34bece3 100644 --- a/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.html +++ b/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.html @@ -19,6 +19,30 @@ + +
+

Uso de RAM

+
+ + +
+

Total: {{ ramUsage.total }}

+

Usado: {{ ramUsage.used }}

+

Disponible: {{ ramUsage.available }}

+

Usado (%): {{ ramUsage.used_percentage }}

+
+
+
+ + +
+

Uso de CPU

+
+

Usado: {{ cpuUsage.used_percentage }}

+
+
+

{{ 'servicesTitle' | translate }}

diff --git a/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.ts b/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.ts index e92d6ab..d1d5406 100644 --- a/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.ts +++ b/ogWebconsole/src/app/components/global-status/status-tab/status-tab.component.ts @@ -19,6 +19,10 @@ export class StatusTabComponent { }; @Input() view: [number, number] = [400, 220]; @Input() isDhcp: boolean = false; + @Input() processesStatus: any = {}; + @Input() ramUsage: any = {}; + @Input() cpuUsage: any = {}; + @Input() ramUsageChartData: any[] = []; getServices(): { name: string, status: string }[] { if (!this.servicesStatus) {