Merge branch 'develop' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oggui into develop

pull/18/head
Manuel Aranda Rosales 2025-03-24 13:07:47 +01:00
commit b5510ffa13
4 changed files with 39 additions and 10 deletions

View File

@ -18,7 +18,8 @@
[colorScheme]="colorScheme" [colorScheme]="colorScheme"
[isDoughnut]="isDoughnut" [isDoughnut]="isDoughnut"
[showLabels]="showLabels" [showLabels]="showLabels"
[isDhcp]="isDhcp"> [isDhcp]="isDhcp"
[isRepository]="false">
</app-status-tab> </app-status-tab>
</div> </div>
</mat-tab> </mat-tab>
@ -35,7 +36,8 @@
[colorScheme]="colorScheme" [colorScheme]="colorScheme"
[isDoughnut]="isDoughnut" [isDoughnut]="isDoughnut"
[showLabels]="showLabels" [showLabels]="showLabels"
[isDhcp]="isDhcp"> [isDhcp]="isDhcp"
[isRepository]="false">
</app-status-tab> </app-status-tab>
</div> </div>
</mat-tab> </mat-tab>
@ -62,7 +64,9 @@
[view]="view" [view]="view"
[colorScheme]="colorScheme" [colorScheme]="colorScheme"
[isDoughnut]="isDoughnut" [isDoughnut]="isDoughnut"
[showLabels]="showLabels"> [showLabels]="showLabels"
[isDhcp]="false"
[isRepository]="true">
</app-status-tab> </app-status-tab>
</div> </div>
</mat-tab> </mat-tab>

View File

@ -34,6 +34,7 @@ export class GlobalStatusComponent implements OnInit {
dhcpServicesStatus: any = {}; dhcpServicesStatus: any = {};
dhcpDiskUsageChartData: any[] = []; dhcpDiskUsageChartData: any[] = [];
isDhcp: boolean = false; isDhcp: boolean = false;
isRepository: boolean = false;
constructor( constructor(
private configService: ConfigService, private configService: ConfigService,
@ -101,7 +102,7 @@ export class GlobalStatusComponent implements OnInit {
data => { data => {
this.repositories = data['hydra:member']; this.repositories = data['hydra:member'];
this.repositories.forEach(repository => { this.repositories.forEach(repository => {
this.loadRepositoryStatus(repository.id); this.loadRepositoryStatus(repository.uuid);
}); });
this.loading = false; this.loading = false;
}, },
@ -112,11 +113,12 @@ export class GlobalStatusComponent implements OnInit {
); );
} }
loadRepositoryStatus(repositoryId: string): void { loadRepositoryStatus(repositoryUuid: string): void {
this.http.get<any>(`${this.baseUrl}/image-repositories/server/${repositoryId}/status`).subscribe( this.isRepository = true;
this.http.get<any>(`${this.baseUrl}/image-repositories/server/${repositoryUuid}/status`).subscribe(
data => { data => {
const output = data.output; const output = data.output;
this.repositoryStatuses[repositoryId] = { this.repositoryStatuses[repositoryUuid] = {
...output, ...output,
disk: { disk: {
...output.disk, ...output.disk,
@ -131,7 +133,7 @@ export class GlobalStatusComponent implements OnInit {
}; };
}, },
error => { error => {
console.error(`Error fetching status for repository ${repositoryId}`, error); console.error(`Error fetching status for repository ${repositoryUuid}`, error);
} }
); );
} }

View File

@ -20,7 +20,7 @@
</div> </div>
<!-- RAM Usage Section --> <!-- RAM Usage Section -->
<div class="ram-usage-container"> <div class="ram-usage-container" *ngIf="isRepository">
<h3 class="ram-title">Uso de RAM</h3> <h3 class="ram-title">Uso de RAM</h3>
<div class="ram-usage"> <div class="ram-usage">
<ngx-charts-pie-chart [view]="view" [scheme]="colorScheme" [results]="ramUsageChartData" [doughnut]="isDoughnut" <ngx-charts-pie-chart [view]="view" [scheme]="colorScheme" [results]="ramUsageChartData" [doughnut]="isDoughnut"
@ -36,7 +36,7 @@
</div> </div>
<!-- CPU Usage Section --> <!-- CPU Usage Section -->
<div class="cpu-usage-container"> <div class="cpu-usage-container" *ngIf="isRepository">
<h3 class="cpu-title">Uso de CPU</h3> <h3 class="cpu-title">Uso de CPU</h3>
<div class="cpu-usage"> <div class="cpu-usage">
<p>Usado: <strong>{{ cpuUsage.used_percentage }}</strong></p> <p>Usado: <strong>{{ cpuUsage.used_percentage }}</strong></p>
@ -55,6 +55,18 @@
</ul> </ul>
</div> </div>
<!-- Processes Status Section -->
<div class="processes-status" *ngIf="isRepository">
<h3 class="process-title">Procesos</h3>
<ul class="process-list">
<li *ngFor="let process of getProcesses()">
<span class="status-led"
[ngClass]="{ 'active': process.status === 'running', 'inactive': process.status !== 'running' }"></span>
{{ process.name }}: {{ process.status }}
</li>
</ul>
</div>
<!-- Installed OgLives / Subnets Section --> <!-- Installed OgLives / Subnets Section -->
<div> <div>
<h3>{{ isDhcp ? ('subnets' | translate) : ('InstalledOglivesTitle' | translate)}}</h3> <h3>{{ isDhcp ? ('subnets' | translate) : ('InstalledOglivesTitle' | translate)}}</h3>

View File

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