Merge pull request 'develop' (#69) from develop into main
testing/ogcore-api/pipeline/head This commit looks good Details
ogcore-debian-package/pipeline/tag This commit looks good Details
ogcore-debian-package/pipeline/head This commit looks good Details

Reviewed-on: #69
develop^2 1.2.0
Manuel Aranda Rosales 2025-10-21 16:16:22 +02:00
commit 4707b5e719
8 changed files with 119 additions and 1 deletions

View File

@ -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.

View File

@ -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

View File

@ -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);

View File

@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Dto\Input\DeleteMultipleClientsInput;
use App\Repository\ClientRepository;
use Doctrine\ORM\EntityManagerInterface;
use App\Controller\OgDhcp\Subnet\DeleteHostAction;
use App\Controller\OgBoot\PxeBootFile\DeleteAction;
use App\Entity\Client;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
class DeleteMultipleClientsAction extends AbstractController
{
public function __construct(
private readonly ClientRepository $clientRepository,
private readonly EntityManagerInterface $entityManager,
private readonly KernelInterface $kernel,
private readonly DeleteHostAction $deleteHostAction,
private readonly DeleteAction $deletePxeAction,
) {
}
public function __invoke(DeleteMultipleClientsInput $input): JsonResponse
{
$errors = [];
$deletedCount = 0;
$totalCount = count($input->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);
}
}

View File

@ -38,6 +38,7 @@ class MenuBrowserController extends AbstractController
return $this->render('browser/' . $menuName . '.html.twig', [
'ip' => $host,
'mac' => $client ? $client->getMac() : null,
'partitions' => $partitions,
]);
}

View File

@ -37,6 +37,7 @@ class PutAction extends AbstractOgDhcpController
'nextServer' => $data->getNextServer(),
'bootFileName' => $data->getBootFileName(),
'router' => $data->getRouter(),
'DNS' => $data->getDns()
]
];

View File

@ -0,0 +1,21 @@
<?php
namespace App\Dto\Input;
use ApiPlatform\Metadata\ApiProperty;
use App\Dto\Output\ClientOutput;
use Symfony\Component\Serializer\Annotation\Groups;
final class DeleteMultipleClientsInput
{
/**
* @var ClientOutput[]
*/
#[Groups(['client:write'])]
#[ApiProperty(
description: 'Los clientes a eliminar',
example: []
)]
public array $clients = [];
}

View File

@ -467,6 +467,11 @@
<section class="welcome-section">
<img src="{{ asset('assets/img.png') }}" alt="Logo OpenGnsys">
<h1>Bienvenido {{ ip }}</h1>
{% if mac %}
<p style="font-size: 1.2rem; color: #64748b; margin-top: 0.5rem;">
<i class="fas fa-network-wired"></i> MAC: <strong>{{ mac }}</strong>
</p>
{% endif %}
</section>
<section class="partitions-section">