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

pull/18/head
Manuel Aranda Rosales 2025-03-24 12:38:13 +01:00
commit 5d54cf78ec
4 changed files with 88 additions and 10 deletions

View File

@ -40,15 +40,34 @@
</div> </div>
</mat-tab> </mat-tab>
<mat-tab label="{{'repositories' | translate}}"> <mat-tab label="Repositorios">
<div *ngIf="!loading" class="content-container"> <mat-tab-group>
<ul> <mat-tab *ngFor="let repository of repositories" [label]="repository.name">
<li *ngFor="let repository of repositories"> <div *ngIf="repositoryStatuses[repository.id]">
{{ repository.name }} <app-status-tab
</li> [loading]="loading"
</ul> [diskUsage]="repositoryStatuses[repository.id].disk"
[servicesStatus]="repositoryStatuses[repository.id].services"
[processesStatus]="repositoryStatuses[repository.id].processes"
[ramUsage]="repositoryStatuses[repository.id].ram"
[cpuUsage]="repositoryStatuses[repository.id].cpu"
[diskUsageChartData]="[
{ name: 'Usado', value: repositoryStatuses[repository.id].disk.used },
{ name: 'Disponible', value: repositoryStatuses[repository.id].disk.available }
]"
[ramUsageChartData]="[
{ name: 'Usado', value: repositoryStatuses[repository.id].ram.used },
{ name: 'Disponible', value: repositoryStatuses[repository.id].ram.available }
]"
[view]="view"
[colorScheme]="colorScheme"
[isDoughnut]="isDoughnut"
[showLabels]="showLabels">
</app-status-tab>
</div> </div>
</mat-tab> </mat-tab>
</mat-tab-group>
</mat-tab>
</mat-tab-group> </mat-tab-group>
</mat-dialog-content> </mat-dialog-content>

View File

@ -22,6 +22,7 @@ export class GlobalStatusComponent implements OnInit {
view: [number, number] = [400, 220]; view: [number, number] = [400, 220];
repositoriesUrl: string; repositoriesUrl: string;
repositories: any[] = []; repositories: any[] = [];
repositoryStatuses: { [key: string]: any } = {};
ogBootApiUrl: string; ogBootApiUrl: string;
ogBootDiskUsage: any = {}; ogBootDiskUsage: any = {};
@ -99,6 +100,9 @@ export class GlobalStatusComponent implements OnInit {
this.http.get<any>(`${this.repositoriesUrl}?page=1&itemsPerPage=10`).subscribe( this.http.get<any>(`${this.repositoriesUrl}?page=1&itemsPerPage=10`).subscribe(
data => { data => {
this.repositories = data['hydra:member']; this.repositories = data['hydra:member'];
this.repositories.forEach(repository => {
this.loadRepositoryStatus(repository.id);
});
this.loading = false; this.loading = false;
}, },
error => { error => {
@ -108,6 +112,30 @@ export class GlobalStatusComponent implements OnInit {
); );
} }
loadRepositoryStatus(repositoryId: string): void {
this.http.get<any>(`${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 { loadOgBootStatus(): void {
this.isDhcp = false; this.isDhcp = false;
this.loadStatus(this.ogBootApiUrl, this.ogBootDiskUsage, this.ogBootServicesStatus, this.ogBootDiskUsageChartData, this.installedOgLives, this.isDhcp); 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 { onTabChange(event: MatTabChangeEvent): void {
if (event.tab.textLabel === 'OgBoot') { if (event.tab.textLabel === 'OgBoot') {
this.loadOgBootStatus(); this.loadOgBootStatus();
} } else if (event.tab.textLabel === 'Dhcp') {
else if (event.tab.textLabel === 'Dhcp') {
this.loadDhcpStatus(); this.loadDhcpStatus();
} else if (event.tab.textLabel === 'Repositorios') {
if (this.repositories.length === 0) {
this.loadRepositories();
}
} }
} }
} }

View File

@ -19,6 +19,30 @@
</div> </div>
</div> </div>
<!-- RAM Usage Section -->
<div class="ram-usage-container">
<h3 class="ram-title">Uso de RAM</h3>
<div class="ram-usage">
<ngx-charts-pie-chart [view]="view" [scheme]="colorScheme" [results]="ramUsageChartData" [doughnut]="isDoughnut"
[labels]="showLabels">
</ngx-charts-pie-chart>
<div class="ram-usage-info">
<p>Total: <strong>{{ ramUsage.total }}</strong></p>
<p>Usado: <strong>{{ ramUsage.used }}</strong></p>
<p>Disponible: <strong>{{ ramUsage.available }}</strong></p>
<p>Usado (%): <strong>{{ ramUsage.used_percentage }}</strong></p>
</div>
</div>
</div>
<!-- CPU Usage Section -->
<div class="cpu-usage-container">
<h3 class="cpu-title">Uso de CPU</h3>
<div class="cpu-usage">
<p>Usado: <strong>{{ cpuUsage.used_percentage }}</strong></p>
</div>
</div>
<!-- Services Status Section --> <!-- Services Status Section -->
<div class="services-status" joyrideStep="servicesStatusStep" text="{{ 'servicesStatusDescription' | translate }}"> <div class="services-status" joyrideStep="servicesStatusStep" text="{{ 'servicesStatusDescription' | translate }}">
<h3 class="service-title">{{ 'servicesTitle' | translate }}</h3> <h3 class="service-title">{{ 'servicesTitle' | translate }}</h3>

View File

@ -19,6 +19,10 @@ export class StatusTabComponent {
}; };
@Input() view: [number, number] = [400, 220]; @Input() view: [number, number] = [400, 220];
@Input() isDhcp: boolean = false; @Input() isDhcp: boolean = false;
@Input() processesStatus: any = {};
@Input() ramUsage: any = {};
@Input() cpuUsage: any = {};
@Input() ramUsageChartData: any[] = [];
getServices(): { name: string, status: string }[] { getServices(): { name: string, status: string }[] {
if (!this.servicesStatus) { if (!this.servicesStatus) {