From a0b3f0a4f746b46219e299d65e1e8debab49e89f Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Mon, 24 Mar 2025 13:05:21 +0100 Subject: [PATCH] Add repository status display with RAM, CPU usage, and process details in Global Status component --- .../global-status/global-status.component.html | 10 +++++++--- .../global-status/global-status.component.ts | 12 +++++++----- .../status-tab/status-tab.component.html | 16 ++++++++++++++-- .../status-tab/status-tab.component.ts | 11 +++++++++++ 4 files changed, 39 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 7ffc407..bbc80c6 100644 --- a/ogWebconsole/src/app/components/global-status/global-status.component.html +++ b/ogWebconsole/src/app/components/global-status/global-status.component.html @@ -18,7 +18,8 @@ [colorScheme]="colorScheme" [isDoughnut]="isDoughnut" [showLabels]="showLabels" - [isDhcp]="isDhcp"> + [isDhcp]="isDhcp" + [isRepository]="false"> @@ -35,7 +36,8 @@ [colorScheme]="colorScheme" [isDoughnut]="isDoughnut" [showLabels]="showLabels" - [isDhcp]="isDhcp"> + [isDhcp]="isDhcp" + [isRepository]="false"> @@ -62,7 +64,9 @@ [view]="view" [colorScheme]="colorScheme" [isDoughnut]="isDoughnut" - [showLabels]="showLabels"> + [showLabels]="showLabels" + [isDhcp]="false" + [isRepository]="true"> 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 78d6545..27b20a0 100644 --- a/ogWebconsole/src/app/components/global-status/global-status.component.ts +++ b/ogWebconsole/src/app/components/global-status/global-status.component.ts @@ -34,6 +34,7 @@ export class GlobalStatusComponent implements OnInit { dhcpServicesStatus: any = {}; dhcpDiskUsageChartData: any[] = []; isDhcp: boolean = false; + isRepository: boolean = false; constructor( private configService: ConfigService, @@ -101,7 +102,7 @@ export class GlobalStatusComponent implements OnInit { data => { this.repositories = data['hydra:member']; this.repositories.forEach(repository => { - this.loadRepositoryStatus(repository.id); + this.loadRepositoryStatus(repository.uuid); }); this.loading = false; }, @@ -112,11 +113,12 @@ export class GlobalStatusComponent implements OnInit { ); } - loadRepositoryStatus(repositoryId: string): void { - this.http.get(`${this.baseUrl}/image-repositories/server/${repositoryId}/status`).subscribe( + loadRepositoryStatus(repositoryUuid: string): void { + this.isRepository = true; + this.http.get(`${this.baseUrl}/image-repositories/server/${repositoryUuid}/status`).subscribe( data => { const output = data.output; - this.repositoryStatuses[repositoryId] = { + this.repositoryStatuses[repositoryUuid] = { ...output, disk: { ...output.disk, @@ -131,7 +133,7 @@ export class GlobalStatusComponent implements OnInit { }; }, error => { - console.error(`Error fetching status for repository ${repositoryId}`, error); + console.error(`Error fetching status for repository ${repositoryUuid}`, error); } ); } 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 34bece3..fcd894f 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 @@ -20,7 +20,7 @@ -
+

Uso de RAM

-
+

Uso de CPU

Usado: {{ cpuUsage.used_percentage }}

@@ -55,6 +55,18 @@
+ +
+

Procesos

+
    +
  • + + {{ process.name }}: {{ process.status }} +
  • +
+
+

{{ isDhcp ? ('subnets' | translate) : ('InstalledOglivesTitle' | 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 d1d5406..cafcb27 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 @@ -23,6 +23,7 @@ export class StatusTabComponent { @Input() ramUsage: any = {}; @Input() cpuUsage: any = {}; @Input() ramUsageChartData: any[] = []; + @Input() isRepository: boolean = false; getServices(): { name: string, status: string }[] { if (!this.servicesStatus) { @@ -35,6 +36,16 @@ export class StatusTabComponent { return services; } + getProcesses(): { name: string, status: string }[] { + if (!this.processesStatus) { + return []; + } + return Object.keys(this.processesStatus).map(key => ({ + name: key, + status: this.processesStatus[key] + })); + } + formatBytes(bytes: number): string { if (bytes >= 1e9) { return (bytes / 1e9).toFixed(2) + ' GB';