refs #632. Create new fields and updated API
parent
36863bff7b
commit
fa2ee36cb9
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240820063513 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE client ADD og_live_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
|
||||
$this->addSql('CREATE INDEX IDX_C7440455F7E54CF3 ON client (og_live_id)');
|
||||
$this->addSql('ALTER TABLE network_settings ADD og_live_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
|
||||
$this->addSql('CREATE INDEX IDX_48869B54F7E54CF3 ON network_settings (og_live_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54F7E54CF3');
|
||||
$this->addSql('DROP INDEX IDX_48869B54F7E54CF3 ON network_settings');
|
||||
$this->addSql('ALTER TABLE network_settings DROP og_live_id');
|
||||
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3');
|
||||
$this->addSql('DROP INDEX IDX_C7440455F7E54CF3 ON client');
|
||||
$this->addSql('ALTER TABLE client DROP og_live_id');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240820064106 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE og_live CHANGE `default` is_default TINYINT(1) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE og_live CHANGE is_default `default` TINYINT(1) DEFAULT NULL');
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ namespace App\Dto\Input;
|
|||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\HardwareProfileOutput;
|
||||
use App\Dto\Output\MenuOutput;
|
||||
use App\Dto\Output\OgLiveOutput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\OgRepository;
|
||||
|
@ -76,6 +77,12 @@ final class ClientInput
|
|||
)]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['client:write'])]
|
||||
#[ApiProperty(
|
||||
description: 'OgLive del cliente'
|
||||
)]
|
||||
public ?OgLiveOutput $ogLive = null;
|
||||
|
||||
#[Groups(['client:write'])]
|
||||
#[ApiProperty(
|
||||
description: 'La posición del cliente dentro del aula'
|
||||
|
@ -107,6 +114,10 @@ final class ClientInput
|
|||
$this->menu = new MenuOutput($client->getMenu());
|
||||
}
|
||||
|
||||
if ($client->getOgLive()) {
|
||||
$this->ogLive = new OgLiveOutput($client->getOgLive());
|
||||
}
|
||||
|
||||
if ($client->getHardwareProfile()) {
|
||||
$this->hardwareProfile = new HardwareProfileOutput($client->getHardwareProfile());
|
||||
}
|
||||
|
@ -126,6 +137,7 @@ final class ClientInput
|
|||
$client->setMac($this->mac);
|
||||
$client->setIp($this->ip);
|
||||
$client->setMenu($this->menu?->getEntity());
|
||||
$client->setOgLive($this->ogLive?->getEntity());
|
||||
$client->setHardwareProfile($this->hardwareProfile?->getEntity());
|
||||
$client->setPosition($this->position);
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\HardwareProfileOutput;
|
||||
use App\Dto\Output\MenuOutput;
|
||||
use App\Dto\Output\OgLiveOutput;
|
||||
use App\Entity\HardwareProfile;
|
||||
use App\Entity\Menu;
|
||||
use App\Entity\NetworkSettings;
|
||||
|
@ -62,6 +64,9 @@ class NetworkSettingsInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?OgLiveOutput $ogLive = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
|
@ -91,6 +96,10 @@ class NetworkSettingsInput
|
|||
$this->hardwareProfile = new HardwareProfileOutput($networkSettings->getHardwareProfile());
|
||||
}
|
||||
|
||||
if ($networkSettings->getOgLive()) {
|
||||
$this->ogLive = new OgLiveOutput($networkSettings->getOgLive());
|
||||
}
|
||||
|
||||
$this->validation = $networkSettings->getValidation();
|
||||
}
|
||||
|
||||
|
@ -120,6 +129,10 @@ class NetworkSettingsInput
|
|||
$networkSettings->setHardwareProfile($this->hardwareProfile->getEntity());
|
||||
}
|
||||
|
||||
if ($this->ogLive) {
|
||||
$networkSettings->setOgLive($this->ogLive->getEntity());
|
||||
}
|
||||
|
||||
$networkSettings->setValidation($this->validation);
|
||||
|
||||
return $networkSettings;
|
||||
|
|
|
@ -48,6 +48,10 @@ final class ClientOutput extends AbstractOutput
|
|||
#[ApiProperty(readableLink: true )]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
#[ApiProperty(readableLink: true )]
|
||||
public ?OgLiveOutput $ogLive = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
public ?array $position = ['x' => 0, 'y' => 0];
|
||||
|
||||
|
@ -79,6 +83,7 @@ final class ClientOutput extends AbstractOutput
|
|||
$this->menu = $client->getMenu() ? new MenuOutput($client->getMenu()) : null;
|
||||
$this->position = $client->getPosition();
|
||||
$this->hardwareProfile = $client->getHardwareProfile() ? new HardwareProfileOutput($client->getHardwareProfile()) : null;
|
||||
$this->ogLive = $client->getOgLive() ? new OgLiveOutput($client->getOgLive()) : null;
|
||||
$this->createdAt = $client->getCreatedAt();
|
||||
$this->createdBy = $client->getCreatedBy();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,9 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?OgLiveOutput $ogLive = null;
|
||||
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
|
@ -81,6 +84,10 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
$this->hardwareProfile = new HardwareProfileOutput($networkSettings->getHardwareProfile());
|
||||
}
|
||||
|
||||
if ($networkSettings->getOgLive()) {
|
||||
$this->ogLive = new OgLiveOutput($networkSettings->getOgLive());
|
||||
}
|
||||
|
||||
$this->validation = $networkSettings->getValidation();
|
||||
$this->createdAt = $networkSettings->getCreatedAt();
|
||||
$this->createdBy = $networkSettings->getCreatedBy();
|
||||
|
|
|
@ -20,7 +20,7 @@ final class OgLiveOutput extends AbstractOutput
|
|||
public ?bool $installed = false;
|
||||
|
||||
#[Groups(['og-live:read'])]
|
||||
public ?bool $default = false;
|
||||
public ?bool $isDefault = false;
|
||||
|
||||
#[Groups(['og-live:read'])]
|
||||
public ?string $downloadUrl = '';
|
||||
|
@ -38,7 +38,7 @@ final class OgLiveOutput extends AbstractOutput
|
|||
$this->name = $ogLive->getName();
|
||||
$this->synchronized = $ogLive->isSynchronized();
|
||||
$this->installed = $ogLive->isInstalled();
|
||||
$this->default = $ogLive->isDefault();
|
||||
$this->isDefault = $ogLive->getIsDefault();
|
||||
$this->downloadUrl = $ogLive->getDownloadUrl();
|
||||
$this->createdAt = $ogLive->getCreatedAt();
|
||||
$this->createdBy = $ogLive->getCreatedBy();
|
||||
|
|
|
@ -63,6 +63,9 @@ class Client extends AbstractEntity
|
|||
#[ORM\ManyToOne(inversedBy: 'clients')]
|
||||
private ?OgRepository $repository = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'clients')]
|
||||
private ?OgLive $ogLive = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -254,4 +257,16 @@ class Client extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOgLive(): ?OgLive
|
||||
{
|
||||
return $this->ogLive;
|
||||
}
|
||||
|
||||
public function setOgLive(?OgLive $ogLive): static
|
||||
{
|
||||
$this->ogLive = $ogLive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,9 @@ class NetworkSettings extends AbstractEntity
|
|||
#[ORM\ManyToOne]
|
||||
private ?OgRepository $repository = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?OgLive $ogLive = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -283,4 +286,16 @@ class NetworkSettings extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOgLive(): ?OgLive
|
||||
{
|
||||
return $this->ogLive;
|
||||
}
|
||||
|
||||
public function setOgLive(?OgLive $ogLive): static
|
||||
{
|
||||
$this->ogLive = $ogLive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\OgLiveRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
|
@ -42,7 +44,19 @@ class OgLive extends AbstractEntity
|
|||
private ?bool $installed = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $default = null;
|
||||
private ?bool $isDefault = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Client>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'ogLive', targetEntity: Client::class)]
|
||||
private Collection $clients;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->clients = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getDownloadUrl(): ?string
|
||||
{
|
||||
|
@ -152,14 +166,42 @@ class OgLive extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function isDefault(): ?bool
|
||||
public function getIsDefault(): ?bool
|
||||
{
|
||||
return $this->default;
|
||||
return $this->isDefault;
|
||||
}
|
||||
|
||||
public function setDefault(?bool $default): static
|
||||
public function setIsDefault(?bool $isDefault): void
|
||||
{
|
||||
$this->default = $default;
|
||||
$this->isDefault = $isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Client>
|
||||
*/
|
||||
public function getClients(): Collection
|
||||
{
|
||||
return $this->clients;
|
||||
}
|
||||
|
||||
public function addClient(Client $client): static
|
||||
{
|
||||
if (!$this->clients->contains($client)) {
|
||||
$this->clients->add($client);
|
||||
$client->setOgLive($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeClient(Client $client): static
|
||||
{
|
||||
if ($this->clients->removeElement($client)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($client->getOgLive() === $this) {
|
||||
$client->setOgLive(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue