100, 'y' => 200] )] public ?array $position = ['x' => 0, 'y' => 0]; #[Groups(['client:read', 'organizational-unit:read', 'pxe-template:read', 'trace:read', 'subnet:read'])] #[ApiProperty( description: 'El estado actual del cliente', example: 'online' )] public ?string $status = ''; #[Groups(['client:read'])] #[ApiProperty( description: 'Fecha de creación del cliente', example: '2024-01-15T10:30:00+00:00' )] public \DateTime $createdAt; #[Groups(['client:read'])] #[ApiProperty( description: 'Usuario que creó este registro', example: 'admin' )] public ?string $createdBy = null; #[Groups(['client:read', 'organizational-unit:read', 'pxe-template:read', 'trace:read', 'subnet:read'])] #[ApiProperty( description: 'Indica si el cliente está en modo mantenimiento', example: false )] public ?bool $maintenance = false; #[Groups(['client:read'])] #[ApiProperty( description: 'Indica si la configuración PXE está sincronizada', example: true )] public ?bool $pxeSync = false; #[Groups(['client:read'])] #[ApiProperty( description: 'La resolución del cliente', example: '1920x1080' )] public ?string $resolution = null; #[Groups(['client:read'])] #[ApiProperty( description: 'Notas sobre el cliente', example: 'Cliente ubicado en el aula 1' )] public ?string $notes = null; #[Groups(['client:read'])] #[ApiProperty( description: 'El servidor OgBoot asignado al cliente', readableLink: true )] public ?BootServerOutput $bootServer = null; #[Groups(['client:read', 'organizational-unit:read'])] #[ApiProperty( description: 'Indica si el cliente tiene una reserva activa de RemotePC (UDS)', example: false )] public bool $isRemotePcActive = false; public function __construct(Client $client) { parent::__construct($client); $this->name = $client->getName(); $this->serialNumber = $client->getSerialNumber(); $this->mac = $client->getMac(); $this->ip = $client->getIp(); $this->netiface = $client->getNetiface(); $this->netDriver = $client->getNetDriver(); $this->netSpeed = $client->getNetSpeed(); $this->firmwareType = $client->getFirmwareType(); if ($client->getOrganizationalUnit()) { $this->organizationalUnit = new OrganizationalUnitOutput($client->getOrganizationalUnit()); } $this->partitions = $client->getPartitions()->map( fn(Partition $partition) => new PartitionOutput($partition) )->toArray(); $this->menu = $client->getMenu() ? new MenuOutput($client->getMenu()) : null; $this->hardwareProfile = $client->getHardwareProfile() ? new HardwareProfileOutput($client->getHardwareProfile(), includeClients: false) : null; $this->position = $client->getPosition(); $repository = $client->getRepository() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getRepository(); $this->repository = $repository ? new ImageRepositoryOutput($repository) : null; $ogLive = $client->getOgLive() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getOgLive(); $this->ogLive = $ogLive ? new OgLiveOutput($ogLive) : null; $template = $client->getTemplate() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getPxeTemplate(); $this->pxeTemplate = $template ? new PxeTemplateOutput($template) : null; if ($client->getSubnet()){ $this->subnet = $client->getSubnet()?->getIpAddress().'/' . $this->convertMaskToCIDR($client->getSubnet() ? $client->getSubnet()->getNetmask() : $client->getOrganizationalUnit()->getNetworkSettings()->getNetmask()); } $this->status = $client->getStatus(); $this->createdAt = $client->getCreatedAt(); $this->createdBy = $client->getCreatedBy(); $this->maintenance = $client->isMaintenance(); $this->pxeSync = $client->isPxeSync(); $this->resolution = $client->getResolution(); $this->notes = $client->getNotes(); if ($client->getBootServer()) { $this->bootServer = new BootServerOutput($client->getBootServer()); } $this->isRemotePcActive = (bool) $client->getRemotePC()?->isReservedActive(); } public function convertMaskToCIDR($mask): int { $bits = 0; $mask = explode(".", $mask); foreach ($mask as $oct) $bits += strlen(str_replace("0", "", decbin($oct))); return $bits; } }