refs #2956. Added new param clientsPerPage
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/88/head
Manuel Aranda Rosales 2026-04-14 18:18:38 +02:00
parent 2513cef6f3
commit 6a9d8bf8b2
6 changed files with 68 additions and 1 deletions

View File

@ -20,7 +20,7 @@ services:
api_platform.filter.client.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'uuid': exact, 'name': 'partial', 'serialNumber': 'exact', 'template.id': 'exact', status: 'exact', organizationalUnit.id: 'exact', mac: 'exact', ip: 'exact', subnet.id: 'exact' } ]
arguments: [ { 'id': 'exact', 'uuid': exact, 'name': 'partial', 'serialNumber': 'exact', 'template.id': 'exact', status: 'exact', organizationalUnit.id: 'exact', mac: 'exact', ip: 'exact', subnet.id: 'exact', 'notes': 'partial' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.client.exist:

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260414120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add clients_per_page column to user table';
}
public function up(Schema $schema): void
{
$table = $schema->getTable('user');
if (!$table->hasColumn('clients_per_page')) {
$this->addSql('ALTER TABLE `user` ADD clients_per_page INT DEFAULT NULL');
}
}
public function down(Schema $schema): void
{
$table = $schema->getTable('user');
if ($table->hasColumn('clients_per_page')) {
$this->addSql('ALTER TABLE `user` DROP clients_per_page');
}
}
}

View File

@ -49,6 +49,13 @@ final class UserInput
)]
public ?string $groupsView = null;
#[Groups('user:write')]
#[ApiProperty(
description: 'Número de clientes por página en el listado de clientes',
example: 20
)]
public ?int $clientsPerPage = null;
#[Assert\NotNull]
#[Groups('user:write')]
#[ApiProperty(
@ -105,6 +112,7 @@ final class UserInput
$this->username = $user->getUsername();
$this->enabled= $user->isEnabled();
$this->groupsView = $user->getGroupsView();
$this->clientsPerPage = $user->getClientsPerPage();
if ($user->getUserGroups()) {
foreach ($user->getUserGroups() as $userGroup) {
@ -128,6 +136,7 @@ final class UserInput
$user->setUsername($this->username);
$user->setEnabled($this->enabled);
$user->setGroupsView($this->groupsView);
$user->setClientsPerPage($this->clientsPerPage);
foreach ($this->userGroups as $userGroup) {
$userGroupsToAdd[] = $userGroup->getEntity();

View File

@ -54,6 +54,13 @@ final class UserOutput extends AbstractOutput
)]
public ?string $groupsView = 'card';
#[Groups(['user:read'])]
#[ApiProperty(
description: 'Número de clientes por página en el listado de clientes',
example: 20
)]
public ?int $clientsPerPage = null;
#[Groups(['user:read'])]
#[ApiProperty(
description: 'Fecha de creación del usuario',
@ -76,6 +83,7 @@ final class UserOutput extends AbstractOutput
$this->roles = $user->getRoles();
$this->enabled = $user->isEnabled();
$this->groupsView = $user->getGroupsView();
$this->clientsPerPage = $user->getClientsPerPage();
$this->userGroups = $user->getUserGroups()->map(
fn(UserGroup $userGroup) => new UserGroupOutput($userGroup)

View File

@ -54,6 +54,9 @@ class User extends AbstractEntity implements UserInterface, PasswordAuthenticate
#[ORM\Column(length: 255, nullable: true)]
private ?string $groupsView = null;
#[ORM\Column(nullable: true)]
private ?int $clientsPerPage = null;
public function __construct()
{
@ -260,4 +263,16 @@ class User extends AbstractEntity implements UserInterface, PasswordAuthenticate
return $this;
}
public function getClientsPerPage(): ?int
{
return $this->clientsPerPage;
}
public function setClientsPerPage(?int $clientsPerPage): static
{
$this->clientsPerPage = $clientsPerPage;
return $this;
}
}

View File

@ -24,6 +24,7 @@ class JWTCreatedListener
$payload['uuid'] = $user->getUuid();
$payload['roles'] = $user->getRoles();
$payload['groupsView'] = $user->getGroupsView();
$payload['clientsPerPage'] = $user->getClientsPerPage();
$event->setData($payload);
}