From 4cfe8ff7080b4777d809cee40d7240e6476a9ae9 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Tue, 21 Oct 2025 16:15:14 +0200 Subject: [PATCH] New version 1.2.0 --- CHANGELOG.md | 11 +++ config/api_platform/Client.yaml | 8 +++ src/Command/ExecutePendingTracesCommand.php | 2 +- .../DeleteMultipleClientsAction.php | 71 +++++++++++++++++++ src/Controller/MenuBrowserController.php | 1 + src/Controller/OgDhcp/Subnet/PutAction.php | 1 + src/Dto/Input/DeleteMultipleClientsInput.php | 21 ++++++ templates/browser/main.html.twig | 5 ++ 8 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/Controller/DeleteMultipleClientsAction.php create mode 100644 src/Dto/Input/DeleteMultipleClientsInput.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 47a0fa8..ff371eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ # Changelog +## [1.2.0] - 2025-10-21 +### Added +- Nueva funcionalidad para poder eliminar equipos a la vez. Nuevo endpoint desde "Client". + +### Improved +- Nuevo campo "mac" en el ogbrowser + +# Fixed +- Se ha añadido el campo "DNS" a la hora de modificar una subred. + +--- ## [1.1.0] - 2025-10-16 ### Added - Se ha añadido un nuevo campo en el cliente, para guardar la resolucion del menu browser. diff --git a/config/api_platform/Client.yaml b/config/api_platform/Client.yaml index 59f385f..3b0e448 100644 --- a/config/api_platform/Client.yaml +++ b/config/api_platform/Client.yaml @@ -27,6 +27,14 @@ resources: ApiPlatform\Metadata\Post: ~ ApiPlatform\Metadata\Delete: ~ + delete_multiple_clients: + class: ApiPlatform\Metadata\Post + method: POST + input: App\Dto\Input\DeleteMultipleClientsInput + output: false + uriTemplate: /clients/delete-multiple + controller: App\Controller\DeleteMultipleClientsAction + change_organizational_units: provider: App\State\Provider\ClientProvider class: ApiPlatform\Metadata\Post diff --git a/src/Command/ExecutePendingTracesCommand.php b/src/Command/ExecutePendingTracesCommand.php index 5b96e1a..8a9c6ae 100644 --- a/src/Command/ExecutePendingTracesCommand.php +++ b/src/Command/ExecutePendingTracesCommand.php @@ -223,7 +223,7 @@ class ExecutePendingTracesCommand extends Command if (isset($input['action']) && $input['action'] === 'create') { $image = new Image(); - $image->setName($input['name'] ); + $image->setName($input['imageName'] ?? $input['name']); $image->setType($input['type'] ?? 'monolithic'); $image->setRemotePc($input['remotePc'] ?? false); $image->setIsGlobal($input['isGlobal'] ?? false); diff --git a/src/Controller/DeleteMultipleClientsAction.php b/src/Controller/DeleteMultipleClientsAction.php new file mode 100644 index 0000000..d0f4d9b --- /dev/null +++ b/src/Controller/DeleteMultipleClientsAction.php @@ -0,0 +1,71 @@ +clients); + + foreach ($input->clients as $clientOutput) { + /** @var Client $client */ + $client = $clientOutput->getEntity(); + + try { + + if ($this->kernel->getEnvironment() !== 'test') { + if ($client->getSubnet()) { + $this->deleteHostAction->__invoke($client->getSubnet(), $client->getUuid()->toString()); + } + $this->deletePxeAction->__invoke($client->getMac()); + } + + $this->clientRepository->delete($client); + $deletedCount++; + } catch (\Exception $e) { + $errors[] = [ + 'client' => $client->getName() ?? $client->getUuid(), + 'error' => $e->getMessage() + ]; + } + } + + $responseData = [ + 'deleted' => $deletedCount, + 'total' => $totalCount, + 'success' => $deletedCount === $totalCount && empty($errors) + ]; + + if (!empty($errors)) { + $responseData['errors'] = $errors; + } + + return new JsonResponse(data: $responseData, status: Response::HTTP_OK); + } +} + diff --git a/src/Controller/MenuBrowserController.php b/src/Controller/MenuBrowserController.php index 3dac9c2..2ca78be 100644 --- a/src/Controller/MenuBrowserController.php +++ b/src/Controller/MenuBrowserController.php @@ -38,6 +38,7 @@ class MenuBrowserController extends AbstractController return $this->render('browser/' . $menuName . '.html.twig', [ 'ip' => $host, + 'mac' => $client ? $client->getMac() : null, 'partitions' => $partitions, ]); } diff --git a/src/Controller/OgDhcp/Subnet/PutAction.php b/src/Controller/OgDhcp/Subnet/PutAction.php index 2d2c91d..c90d626 100644 --- a/src/Controller/OgDhcp/Subnet/PutAction.php +++ b/src/Controller/OgDhcp/Subnet/PutAction.php @@ -37,6 +37,7 @@ class PutAction extends AbstractOgDhcpController 'nextServer' => $data->getNextServer(), 'bootFileName' => $data->getBootFileName(), 'router' => $data->getRouter(), + 'DNS' => $data->getDns() ] ]; diff --git a/src/Dto/Input/DeleteMultipleClientsInput.php b/src/Dto/Input/DeleteMultipleClientsInput.php new file mode 100644 index 0000000..6babd09 --- /dev/null +++ b/src/Dto/Input/DeleteMultipleClientsInput.php @@ -0,0 +1,21 @@ + Logo OpenGnsys

Bienvenido {{ ip }}

+ {% if mac %} +

+ MAC: {{ mac }} +

+ {% endif %}