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

pull/18/head
Manuel Aranda Rosales 2025-03-20 11:12:00 +01:00
commit b4bf4909fa
5 changed files with 76 additions and 24 deletions

View File

@ -13,7 +13,8 @@
[view]="view"
[colorScheme]="colorScheme"
[isDoughnut]="isDoughnut"
[showLabels]="showLabels">
[showLabels]="showLabels"
[isDhcp]="isDhcp">
</app-status-tab>
</mat-tab>
@ -22,12 +23,13 @@
[loading]="loading"
[diskUsage]="dhcpDiskUsage"
[servicesStatus]="dhcpServicesStatus"
[installedOgLives]="installedOgLives"
[subnets]="subnets"
[diskUsageChartData]="dhcpDiskUsageChartData"
[view]="view"
[colorScheme]="colorScheme"
[isDoughnut]="isDoughnut"
[showLabels]="showLabels">
[showLabels]="showLabels"
[isDhcp]="isDhcp">
</app-status-tab>
</mat-tab>

View File

@ -13,6 +13,7 @@ export class GlobalStatusComponent implements OnInit {
baseUrl: string;
loading: boolean = false;
installedOgLives: any[] = [];
subnets: any[] = [];
showLabels: boolean = true;
isDoughnut: boolean = true;
colorScheme: any = {
@ -29,6 +30,7 @@ export class GlobalStatusComponent implements OnInit {
dhcpDiskUsage: any = {};
dhcpServicesStatus: any = {};
dhcpDiskUsageChartData: any[] = [];
isDhcp: boolean = false;
constructor(
private configService: ConfigService,
@ -44,7 +46,7 @@ export class GlobalStatusComponent implements OnInit {
this.loadOgBootStatus();
}
loadStatus(apiUrl: string, diskUsage: any, servicesStatus: any, diskUsageChartData: any[], installedOgLives: any[]): void {
loadStatus(apiUrl: string, diskUsage: any, servicesStatus: any, diskUsageChartData: any[], installedOgLives: any[], isDhcp: boolean): void {
this.loading = true;
const timeoutId = setTimeout(() => {
this.loading = false;
@ -58,9 +60,17 @@ export class GlobalStatusComponent implements OnInit {
diskUsage.percentage = data.message.disk_usage.percentage;
Object.assign(servicesStatus, data.message.services_status);
installedOgLives.length = 0;
if (data.message.installed_oglives) {
installedOgLives.push(...data.message.installed_oglives);
if (isDhcp) {
this.subnets.length = 0;
if (data.message.subnets) {
this.subnets.push(...data.message.subnets);
}
} else {
installedOgLives.length = 0;
if (data.message.installed_oglives) {
installedOgLives.push(...data.message.installed_oglives);
}
}
diskUsageChartData.length = 0;
@ -82,11 +92,13 @@ export class GlobalStatusComponent implements OnInit {
}
loadOgBootStatus(): void {
this.loadStatus(this.ogBootApiUrl, this.ogBootDiskUsage, this.ogBootServicesStatus, this.ogBootDiskUsageChartData, this.installedOgLives);
this.isDhcp = false;
this.loadStatus(this.ogBootApiUrl, this.ogBootDiskUsage, this.ogBootServicesStatus, this.ogBootDiskUsageChartData, this.installedOgLives, this.isDhcp);
}
loadDhcpStatus(): void {
this.loadStatus(this.dhcpApiUrl, this.dhcpDiskUsage, this.dhcpServicesStatus, this.dhcpDiskUsageChartData, this.installedOgLives);
this.isDhcp = true;
this.loadStatus(this.dhcpApiUrl, this.dhcpDiskUsage, this.dhcpServicesStatus, this.dhcpDiskUsageChartData, this.installedOgLives, this.isDhcp);
}
onTabChange(event: MatTabChangeEvent): void {

View File

@ -31,24 +31,32 @@
</ul>
</div>
<!-- Installed OgLives Section -->
<!-- Installed OgLives / Subnets Section -->
<div class="installed-oglives" joyrideStep="oglivesStep" text="{{ 'oglivesDescription' | translate }}">
<h3>{{ 'installedOglivesTitle' | translate }}</h3>
<h3>{{ isDhcp ? ('subnets' | translate) : ('InstalledOglivesTitle' | translate)}}</h3>
<table>
<thead>
<tr>
<th>{{ 'idLabel' | translate }}</th>
<th>{{ 'kernelLabel' | translate }}</th>
<th>{{ 'architectureLabel' | translate }}</th>
<th>{{ 'revisionLabel' | translate }}</th>
<th *ngIf="!isDhcp">{{ 'kernelLabel' | translate }}</th>
<th *ngIf="!isDhcp">{{ 'architectureLabel' | translate }}</th>
<th *ngIf="!isDhcp">{{ 'revisionLabel' | translate }}</th>
<th *ngIf="isDhcp">{{ 'bootFileNameLabel' | translate }}</th>
<th *ngIf="isDhcp">{{ 'nextServerLabel' | translate }}</th>
<th *ngIf="isDhcp">{{ 'ipLabel' | translate }}</th>
<th *ngIf="isDhcp">{{ 'clientsLabel' | translate }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let oglive of installedOgLives">
<td>{{ oglive.id }}</td>
<td>{{ oglive.kernel }}</td>
<td>{{ oglive.architecture }}</td>
<td>{{ oglive.revision }}</td>
<tr *ngFor="let item of isDhcp ? subnets : installedOgLives">
<td>{{ item.id }}</td>
<td *ngIf="!isDhcp">{{ item.kernel }}</td>
<td *ngIf="!isDhcp">{{ item.architecture }}</td>
<td *ngIf="!isDhcp">{{ item.revision }}</td>
<td *ngIf="isDhcp">{{ item['boot-file-name'] }}</td>
<td *ngIf="isDhcp">{{ item['next-server'] }}</td>
<td *ngIf="isDhcp">{{ item.subnet }}</td>
<td *ngIf="isDhcp">{{ item.reservations.length }}</td>
</tr>
</tbody>
</table>

View File

@ -10,6 +10,7 @@ export class StatusTabComponent {
@Input() diskUsage: any = {};
@Input() servicesStatus: any = {};
@Input() installedOgLives: any[] = [];
@Input() subnets: any[] = [];
@Input() diskUsageChartData: any[] = [];
@Input() showLabels: boolean = true;
@Input() isDoughnut: boolean = true;
@ -17,6 +18,7 @@ export class StatusTabComponent {
domain: ['#df200d', '#26a700']
};
@Input() view: [number, number] = [400, 220];
@Input() isDhcp: boolean = false;
getServices(): { name: string, status: string }[] {
if (!this.servicesStatus) {
@ -26,7 +28,6 @@ export class StatusTabComponent {
name: key,
status: this.servicesStatus[key]
}))
console.log(services)
return services;
}

View File

@ -1,16 +1,45 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { ConvertImageToVirtualComponent } from './convert-image-to-virtual.component';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ToastrModule } from 'ngx-toastr';
import { ConfigService } from '@services/config.service';
describe('ConvertImageToVirtualComponent', () => {
let component: ConvertImageToVirtualComponent;
let fixture: ComponentFixture<ConvertImageToVirtualComponent>;
beforeEach(async () => {
const mockConfigService = {
apiUrl: 'http://mock-api-url'
};
await TestBed.configureTestingModule({
declarations: [ConvertImageToVirtualComponent]
declarations: [ConvertImageToVirtualComponent],
imports: [
MatDialogModule,
ToastrModule.forRoot()
],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
{
provide: MatDialogRef,
useValue: {}
},
{
provide: MAT_DIALOG_DATA,
useValue: {}
},
{
provide: ConfigService,
useValue: mockConfigService
}
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
.compileComponents();
fixture = TestBed.createComponent(ConvertImageToVirtualComponent);
component = fixture.componentInstance;
@ -20,4 +49,4 @@ describe('ConvertImageToVirtualComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
});
});