From 7e06e605981c4e9e9fba810f9137f3d4e9608a6c Mon Sep 17 00:00:00 2001 From: llara Date: Wed, 26 Feb 2025 12:20:21 +0100 Subject: [PATCH] refs #1617. Fix: handle undefined networkSettings in ClientViewComponent --- .../classroom-view.component.ts | 9 +- .../client-view/client-view.component.ts | 83 ++++++++++--------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/ogWebconsole/src/app/components/groups/shared/classroom-view/classroom-view.component.ts b/ogWebconsole/src/app/components/groups/shared/classroom-view/classroom-view.component.ts index fed55b0..33c65f9 100644 --- a/ogWebconsole/src/app/components/groups/shared/classroom-view/classroom-view.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/classroom-view/classroom-view.component.ts @@ -21,8 +21,7 @@ export class ClassroomViewComponent implements OnInit, OnChanges { @Input() pcInTable: number = 5; groupedClients: GroupedClients[] = []; - constructor(public dialog: MatDialog, private http: HttpClient, private toastService: ToastrService) {} - + constructor(public dialog: MatDialog, private http: HttpClient, private toastService: ToastrService) { } ngOnInit(): void { this.groupClientsByOrganizationalUnit(); @@ -61,7 +60,6 @@ export class ClassroomViewComponent implements OnInit, OnChanges { }); } - chunkArray(arr: any[], chunkSize: number): any[][] { const chunks = []; for (let i = 0; i < arr.length; i += chunkSize) { @@ -71,7 +69,8 @@ export class ClassroomViewComponent implements OnInit, OnChanges { } 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, client: any): void { @@ -106,4 +105,4 @@ export class ClassroomViewComponent implements OnInit, OnChanges { } else this.toastService.success('Cliente actualizado!', 'Éxito'); } -} +} \ No newline at end of file diff --git a/ogWebconsole/src/app/components/groups/shared/client-view/client-view.component.ts b/ogWebconsole/src/app/components/groups/shared/client-view/client-view.component.ts index 4193b44..1b7944a 100644 --- a/ogWebconsole/src/app/components/groups/shared/client-view/client-view.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/client-view/client-view.component.ts @@ -1,5 +1,5 @@ -import {Component, Inject} from '@angular/core'; -import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; @Component({ selector: 'app-client-view', @@ -11,54 +11,61 @@ export class ClientViewComponent { displayedColumns: string[] = ['property', 'value']; generalData = [ - {property: 'Nombre', value: this.data.client.name}, - {property: 'Uuid', value: this.data.client.uuid}, - {property: 'IP', value: this.data.client.ip}, - {property: 'MAC', value: this.data.client.mac}, - {property: 'Nº de serie', value: this.data.client.serialNumber}, - {property: 'Netiface', value: this.data.client.netiface}, - {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: 'Fecha de creación', value: this.data.client.createdAt}, - {property: 'Creado por', value: this.data.client.createdBy} + { property: 'Nombre', value: this.data.client.name }, + { property: 'Uuid', value: this.data.client.uuid }, + { property: 'IP', value: this.data.client.ip }, + { property: 'MAC', value: this.data.client.mac }, + { property: 'Nº de serie', value: this.data.client.serialNumber }, + { property: 'Netiface', value: this.data.client.netiface }, + { 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: 'Fecha de creación', value: this.data.client.createdAt }, + { property: 'Creado por', value: this.data.client.createdBy } ]; networkData = [ - {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: 'Subred', value: this.data.client.subnet}, - {property: 'OGlive', value: ''}, - {property: 'Autoexec', value: ''}, - {property: 'Repositorio', value: ''}, - {property: 'Validacion', value: ''}, - {property: 'Página login', value: ''}, - {property: 'Fecha de creación', value: this.data.client.createdAt}, - {property: 'Creado por', value: this.data.client.createdBy} + { 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: 'Subred', value: this.data.client.subnet }, + { property: 'OGlive', value: '' }, + { property: 'Autoexec', value: '' }, + { property: 'Repositorio', value: '' }, + { property: 'Validacion', value: '' }, + { property: 'Página login', value: '' }, + { property: 'Fecha de creación', value: this.data.client.createdAt }, + { 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 = [ - {property: 'Url servidor proxy', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.proxy : ''}, - {property: 'IP DNS', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.dns : ''}, - {property: 'Máscara de red', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.netmask : ''}, - {property: 'Router', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.router : ''}, - {property: 'NTP', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.ntp : ''}, - {property: 'Modo p2p', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.p2pMode : ''}, - {property: 'Tiempo p2p', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.p2pTime : ''}, - {property: 'IP multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastIp : ''}, - {property: 'Modo multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastMode : ''}, - {property: 'Puerto multicast', value: this.data.client.organizationalUnit.networkSettings ? this.data.client.organizationalUnit.networkSettings.mcastPort : ''}, - {property: 'Velocidad multicast', value: this.data.client.organizationalUnit.networkSettings ? 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: 'Menú', value: this.data.client.organizationalUnit.networkSettings && this.data.client.organizationalUnit.networkSettings.menu ? this.data.client.organizationalUnit.networkSettings.menu.description : ''} + { property: 'Url servidor proxy', value: this.data.client.organizationalUnit?.networkSettings?.proxy || '' }, + { property: 'IP DNS', value: this.data.client.organizationalUnit?.networkSettings?.dns || '' }, + { property: 'Máscara de red', value: this.data.client.organizationalUnit?.networkSettings?.netmask || '' }, + { property: 'Router', value: this.data.client.organizationalUnit?.networkSettings?.router || '' }, + { 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 || '' } ]; constructor( private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any - ) { - } + ) {} onNoClick(): void { this.dialogRef.close(); } -} +} \ No newline at end of file