mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added ability to modify the EDA data via the Part-DB API
This commit is contained in:
parent
9994dbd9db
commit
f4b4f14a67
7 changed files with 25 additions and 3 deletions
|
@ -26,6 +26,7 @@ namespace App\Entity\EDA;
|
|||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Embeddable;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
#[Embeddable]
|
||||
class EDACategoryInfo
|
||||
|
@ -34,26 +35,32 @@ class EDACategoryInfo
|
|||
* @var string|null The reference prefix of the Part in the schematic. E.g. "R" for resistors, or "C" for capacitors.
|
||||
*/
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
private ?string $reference_prefix = null;
|
||||
|
||||
/** @var bool|null If this is true, then this part is invisible for the EDA software */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
private ?bool $invisible = null;
|
||||
|
||||
/** @var bool|null If this is set to true, then this part will be excluded from the BOM */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
private ?bool $exclude_from_bom = null;
|
||||
|
||||
/** @var bool|null If this is set to true, then this part will be excluded from the board/the PCB */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
private ?bool $exclude_from_board = null;
|
||||
|
||||
/** @var bool|null If this is set to true, then this part will be excluded in the simulation */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
private ?bool $exclude_from_sim = true;
|
||||
|
||||
/** @var string|null The KiCAD schematic symbol, which should be used (the path to the library) */
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
private ?string $kicad_symbol = null;
|
||||
|
||||
public function getReferencePrefix(): ?string
|
||||
|
|
|
@ -26,12 +26,14 @@ namespace App\Entity\EDA;
|
|||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Embeddable;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
#[Embeddable]
|
||||
class EDAFootprintInfo
|
||||
{
|
||||
/** @var string|null The KiCAD footprint, which should be used (the path to the library) */
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'footprint:read', 'footprint:write'])]
|
||||
private ?string $kicad_footprint = null;
|
||||
|
||||
public function getKicadFootprint(): ?string
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Entity\EDA;
|
|||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Embeddable;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
#[Embeddable]
|
||||
class EDAPartInfo
|
||||
|
@ -34,34 +35,42 @@ class EDAPartInfo
|
|||
* @var string|null The reference prefix of the Part in the schematic. E.g. "R" for resistors, or "C" for capacitors.
|
||||
*/
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?string $reference_prefix = null;
|
||||
|
||||
/** @var string|null The value, which should be shown together with the part (e.g. 470 for a 470 Ohm resistor) */
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?string $value = null;
|
||||
|
||||
/** @var bool|null If this is true, then this part is invisible for the EDA software */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?bool $invisible = null;
|
||||
|
||||
/** @var bool|null If this is set to true, then this part will be excluded from the BOM */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?bool $exclude_from_bom = null;
|
||||
|
||||
/** @var bool|null If this is set to true, then this part will be excluded from the board/the PCB */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?bool $exclude_from_board = null;
|
||||
|
||||
/** @var bool|null If this is set to true, then this part will be excluded in the simulation */
|
||||
#[Column(type: Types::BOOLEAN, nullable: true)]
|
||||
private ?bool $exclude_from_sim = true;
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?bool $exclude_from_sim = null;
|
||||
|
||||
/** @var string|null The KiCAD schematic symbol, which should be used (the path to the library) */
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?string $kicad_symbol = null;
|
||||
|
||||
/** @var string|null The KiCAD footprint, which should be used (the path to the library) */
|
||||
#[Column(type: Types::STRING, nullable: true)]
|
||||
#[Groups(['full', 'eda_info:read', 'eda_info:write'])]
|
||||
private ?string $kicad_footprint = null;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -190,6 +190,7 @@ class Category extends AbstractPartsContainingDBElement
|
|||
|
||||
#[Assert\Valid]
|
||||
#[ORM\Embedded(class: EDACategoryInfo::class)]
|
||||
#[Groups(['full', 'category:read', 'category:write'])]
|
||||
protected EDACategoryInfo $eda_info;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -143,6 +143,7 @@ class Footprint extends AbstractPartsContainingDBElement
|
|||
|
||||
#[Assert\Valid]
|
||||
#[ORM\Embedded(class: EDAFootprintInfo::class)]
|
||||
#[Groups(['full', 'footprint:read', 'footprint:write'])]
|
||||
protected EDAFootprintInfo $eda_info;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -85,7 +85,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read',
|
||||
'orderdetail:read', 'pricedetail:read', 'parameter:read', 'attachment:read'],
|
||||
'orderdetail:read', 'pricedetail:read', 'parameter:read', 'attachment:read', 'eda_info:read'],
|
||||
'openapi_definition_name' => 'Read',
|
||||
], security: 'is_granted("read", object)'),
|
||||
new GetCollection(security: 'is_granted("@parts.read")'),
|
||||
|
@ -94,7 +94,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
new Delete(security: 'is_granted("delete", object)'),
|
||||
],
|
||||
normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read'], 'openapi_definition_name' => 'Read'],
|
||||
denormalizationContext: ['groups' => ['part:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'],
|
||||
denormalizationContext: ['groups' => ['part:write', 'api:basic:write', 'eda_info:write'], 'openapi_definition_name' => 'Write'],
|
||||
)]
|
||||
#[ApiFilter(PropertyFilter::class)]
|
||||
#[ApiFilter(EntityFilter::class, properties: ["category", "footprint", "manufacturer", "partUnit"])]
|
||||
|
|
|
@ -26,12 +26,14 @@ namespace App\Entity\Parts\PartTraits;
|
|||
use App\Entity\EDA\EDAPartInfo;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Embedded;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
|
||||
trait EDATrait
|
||||
{
|
||||
#[Valid]
|
||||
#[Embedded(class: EDAPartInfo::class)]
|
||||
#[Groups(['full', 'part:read', 'part:write'])]
|
||||
protected EDAPartInfo $eda_info;
|
||||
|
||||
public function getEdaInfo(): EDAPartInfo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue