refs #1617. Fix: handle undefined networkSettings in ClientViewComponent
testing/ogGui-multibranch/pipeline/head This commit looks good Details

deb-pkg
Lucas Lara García 2025-02-26 12:20:21 +01:00
parent 900cb423b3
commit 7e06e60598
2 changed files with 49 additions and 43 deletions

View File

@ -21,8 +21,7 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
@Input() pcInTable: number = 5; @Input() pcInTable: number = 5;
groupedClients: GroupedClients[] = []; groupedClients: GroupedClients[] = [];
constructor(public dialog: MatDialog, private http: HttpClient, private toastService: ToastrService) {} constructor(public dialog: MatDialog, private http: HttpClient, private toastService: ToastrService) { }
ngOnInit(): void { ngOnInit(): void {
this.groupClientsByOrganizationalUnit(); this.groupClientsByOrganizationalUnit();
@ -61,7 +60,6 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
}); });
} }
chunkArray(arr: any[], chunkSize: number): any[][] { chunkArray(arr: any[], chunkSize: number): any[][] {
const chunks = []; const chunks = [];
for (let i = 0; i < arr.length; i += chunkSize) { for (let i = 0; i < arr.length; i += chunkSize) {
@ -71,7 +69,8 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
} }
handleClientClick(client: any): void { handleClientClick(client: any): void {
const dialogRef = this.dialog.open(ClientViewComponent, { data: { client }, width: '800px', height:'700px' }); console.log('Client clicked:', client);
this.dialog.open(ClientViewComponent, { data: { client }, width: '800px', height: '700px' });
} }
onDragMoved(event: CdkDragMove<any>, client: any): void { onDragMoved(event: CdkDragMove<any>, client: any): void {

View File

@ -1,5 +1,5 @@
import {Component, Inject} from '@angular/core'; import { Component, Inject } from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
@Component({ @Component({
selector: 'app-client-view', selector: 'app-client-view',
@ -11,52 +11,59 @@ export class ClientViewComponent {
displayedColumns: string[] = ['property', 'value']; displayedColumns: string[] = ['property', 'value'];
generalData = [ generalData = [
{property: 'Nombre', value: this.data.client.name}, { property: 'Nombre', value: this.data.client.name },
{property: 'Uuid', value: this.data.client.uuid}, { property: 'Uuid', value: this.data.client.uuid },
{property: 'IP', value: this.data.client.ip}, { property: 'IP', value: this.data.client.ip },
{property: 'MAC', value: this.data.client.mac}, { property: 'MAC', value: this.data.client.mac },
{property: 'Nº de serie', value: this.data.client.serialNumber}, { property: 'Nº de serie', value: this.data.client.serialNumber },
{property: 'Netiface', value: this.data.client.netiface}, { property: 'Netiface', value: this.data.client.netiface },
{property: 'Perfil hardware', value: this.data.client.hardwareProfile ? this.data.client.hardwareProfile.description : ''}, { property: 'Perfil hardware', value: this.data.client.hardwareProfile ? this.data.client.hardwareProfile.description : '' },
{property: 'Menú', value: this.data.client.menu ? this.data.client.menu.description : ''}, { property: 'Menú', value: this.data.client.menu ? this.data.client.menu.description : '' },
{property: 'Fecha de creación', value: this.data.client.createdAt}, { property: 'Fecha de creación', value: this.data.client.createdAt },
{property: 'Creado por', value: this.data.client.createdBy} { property: 'Creado por', value: this.data.client.createdBy }
]; ];
networkData = [ networkData = [
{property: 'Menú', value: this.data.client.menu ? this.data.client.menu.description : ''}, { property: 'Menú', value: this.data.client.menu ? this.data.client.menu.description : '' },
{property: 'Perfil hardware', value: this.data.client.hardwareProfile ? this.data.client.hardwareProfile.description : ''}, { property: 'Perfil hardware', value: this.data.client.hardwareProfile ? this.data.client.hardwareProfile.description : '' },
{property: 'Subred', value: this.data.client.subnet}, { property: 'Subred', value: this.data.client.subnet },
{property: 'OGlive', value: ''}, { property: 'OGlive', value: '' },
{property: 'Autoexec', value: ''}, { property: 'Autoexec', value: '' },
{property: 'Repositorio', value: ''}, { property: 'Repositorio', value: '' },
{property: 'Validacion', value: ''}, { property: 'Validacion', value: '' },
{property: 'Página login', value: ''}, { property: 'Página login', value: '' },
{property: 'Fecha de creación', value: this.data.client.createdAt}, { property: 'Fecha de creación', value: this.data.client.createdAt },
{property: 'Creado por', value: this.data.client.createdBy} { property: 'NTP', value: this.data.client.organizationalUnit?.networkSettings?.ntp || '' },
{ property: 'Modo p2p', value: this.data.client.organizationalUnit?.networkSettings?.p2pMode || '' },
{ property: 'Tiempo p2p', value: this.data.client.organizationalUnit?.networkSettings?.p2pTime || '' },
{ property: 'IP multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastIp || '' },
{ property: 'Modo multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastMode || '' },
{ property: 'Puerto multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastPort || '' },
{ property: 'Velocidad multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastSpeed || '' },
{ property: 'Perfil hardware', value: this.data.client.organizationalUnit?.networkSettings?.hardwareProfile?.description || '' },
{ property: 'Menú', value: this.data.client.organizationalUnit?.networkSettings?.menu?.description || '' }
]; ];
classroomData = [ classroomData = [
{property: 'Url servidor proxy', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.proxy : ''}, { property: 'Url servidor proxy', value: this.data.client.organizationalUnit?.networkSettings?.proxy || '' },
{property: 'IP DNS', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.dns : ''}, { property: 'IP DNS', value: this.data.client.organizationalUnit?.networkSettings?.dns || '' },
{property: 'Máscara de red', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.netmask : ''}, { property: 'Máscara de red', value: this.data.client.organizationalUnit?.networkSettings?.netmask || '' },
{property: 'Router', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.router : ''}, { property: 'Router', value: this.data.client.organizationalUnit?.networkSettings?.router || '' },
{property: 'NTP', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.ntp : ''}, { property: 'NTP', value: this.data.client.organizationalUnit?.networkSettings?.ntp || '' },
{property: 'Modo p2p', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.p2pMode : ''}, { property: 'Modo p2p', value: this.data.client.organizationalUnit?.networkSettings?.p2pMode || '' },
{property: 'Tiempo p2p', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.p2pTime : ''}, { property: 'Tiempo p2p', value: this.data.client.organizationalUnit?.networkSettings?.p2pTime || '' },
{property: 'IP multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastIp : ''}, { property: 'IP multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastIp || '' },
{property: 'Modo multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastMode : ''}, { property: 'Modo multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastMode || '' },
{property: 'Puerto multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastPort : ''}, { property: 'Puerto multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastPort || '' },
{property: 'Velocidad multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastSpeed : ''}, { property: 'Velocidad multicast', value: this.data.client.organizationalUnit?.networkSettings?.mcastSpeed || '' },
{property: 'Perfil hardware', value: this.data.client.organizationalUnit.networkSettings && this.data.client.organizationalUnit.networkSettings.hardwareProfile ? this.data.client.organizationalUnit.networkSettings.hardwareProfile.description : ''}, { property: 'Perfil hardware', value: this.data.client.organizationalUnit?.networkSettings?.hardwareProfile?.description || '' },
{property: 'Menú', value: this.data.client.organizationalUnit.networkSettings && this.data.client.organizationalUnit.networkSettings.menu ? this.data.client.organizationalUnit.networkSettings.menu.description : ''} { property: 'Menú', value: this.data.client.organizationalUnit?.networkSettings?.menu?.description || '' }
]; ];
constructor( constructor(
private dialogRef: MatDialogRef<ClientViewComponent>, private dialogRef: MatDialogRef<ClientViewComponent>,
@Inject(MAT_DIALOG_DATA) public data: any @Inject(MAT_DIALOG_DATA) public data: any
) { ) {}
}
onNoClick(): void { onNoClick(): void {
this.dialogRef.close(); this.dialogRef.close();