diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f39ea..39571c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ # Changelog +## [1.4.0] - 2026-04-08 +### Added +- Entidad Partition: Añadido el campo deployDate expuesto mediante el DTO para registrar la fecha exacta de despliegue de imagen. +- CreatePartitionService: Inclusión de lógica idempotente que asocia la imagen y extrae su fecha real directamente del fichero /.ogimage enviado por el cliente en el parámetro img=. + +### Fixed +- Limpieza explícita del deployDate (null) en caso de que el inventario no informe de fecha o haya alteraciones en el payload para evitar desincronizaciones de trazas de la imagen subyacente. + ## [1.3.0] - 2026-03-31 ### Added -Añadida acción Refresh para actualizar el estado de un cliente o clientes. Se actualiza su configuración de discos y se recarga el ogBrowser por si hubiese cambio del menu. +- Añadida acción Refresh para actualizar el estado de un cliente o clientes. Se actualiza su configuración de discos y se recarga el ogBrowser por si hubiese cambio del menu. ## [1.2.11] - 2026-03-25 ### Added diff --git a/src/Dto/Output/PartitionOutput.php b/src/Dto/Output/PartitionOutput.php index 76e55e2..0063ba6 100644 --- a/src/Dto/Output/PartitionOutput.php +++ b/src/Dto/Output/PartitionOutput.php @@ -74,6 +74,13 @@ class PartitionOutput extends AbstractOutput )] public ?int $memoryUsage = null; + #[Groups(['partition:read', 'client:read'])] + #[ApiProperty( + description: 'Fecha de despliegue de la imagen', + example: '2025-01-01T00:00:00+00:00' + )] + public ?\DateTimeInterface $deployDate = null; + public function __construct(Partition $partition) { parent::__construct($partition); @@ -94,5 +101,6 @@ class PartitionOutput extends AbstractOutput } $this->memoryUsage = $partition->getMemoryUsage() / 100; + $this->deployDate = $partition->getDeployDate(); } } \ No newline at end of file diff --git a/src/Entity/Partition.php b/src/Entity/Partition.php index 3308da9..dde3700 100644 --- a/src/Entity/Partition.php +++ b/src/Entity/Partition.php @@ -43,6 +43,21 @@ class Partition extends AbstractEntity #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?ImageImageRepository $image = null; + #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] + private ?\DateTimeInterface $deployDate = null; + + public function getDeployDate(): ?\DateTimeInterface + { + return $this->deployDate; + } + + public function setDeployDate(?\DateTimeInterface $deployDate): static + { + $this->deployDate = $deployDate; + + return $this; + } + public function getDiskNumber(): ?int { return $this->diskNumber; diff --git a/src/Service/CreatePartitionService.php b/src/Service/CreatePartitionService.php index b72fd91..5798fe8 100644 --- a/src/Service/CreatePartitionService.php +++ b/src/Service/CreatePartitionService.php @@ -63,6 +63,32 @@ class CreatePartitionService $partitionEntity->setOperativeSystem($operativeSystem); } } + + if (isset($cfg['img']) && $cfg['img'] !== '') { + $imgParts = explode(':', $cfg['img']); + $imgName = $imgParts[0]; + $imgDate = $imgParts[1] ?? null; + + $imageImageRepository = $this->entityManager->getRepository(\App\Entity\ImageImageRepository::class) + ->findOneBy(['name' => $imgName]); + + if ($imageImageRepository) { + $partitionEntity->setImage($imageImageRepository); + $partitionEntity->setDeployDate(null); + if ($imgDate) { + $dateObj = \DateTime::createFromFormat('YmdHi', $imgDate); + if ($dateObj) { + $partitionEntity->setDeployDate($dateObj); + } + } + } else { + $partitionEntity->setImage(null); + $partitionEntity->setDeployDate(null); + } + } elseif (isset($cfg['img']) && $cfg['img'] === '') { + $partitionEntity->setImage(null); + $partitionEntity->setDeployDate(null); + } $partitionEntity->setClient($clientEntity); $partitionEntity->setDiskNumber($cfg['disk']);