import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";

@Component({
  selector: 'app-client-view',
  templateUrl: './client-view.component.html',
  styleUrl: './client-view.component.css'
})
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 }
  ];

  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: '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?.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<ClientViewComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any 
  ) {}

  onNoClick(): void {
    this.dialogRef.close();
  }
}