diff --git a/src/Controller/FpuController.php b/src/Controller/FpuController.php new file mode 100644 index 0000000..803b346 --- /dev/null +++ b/src/Controller/FpuController.php @@ -0,0 +1,57 @@ +indexView('fpus', []); + } + + #[Route('/new', name: 'fpu_new', methods: ['GET', 'POST'])] + public function new(Request $request): Response + { + return $this->itemCreate($request, 'fpu'); + } + + #[Route('/{id}', name: 'fpu_show', methods: ['GET'])] + public function show(Fpu $fpu): Response + { + return $this->itemView($fpu, 'fpu'); + } + + #[Route('/{id}/edit', name: 'fpu_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Fpu $fpu): Response + { + return $this->itemUpdate($request, $fpu, 'fpu'); + } + + #[Route('/{id}', name: 'fpu_delete', methods: ['POST'])] + public function delete(Request $request, Fpu $fpu): Response + { + return $this->deleteCSRF($request, $fpu); + } +} diff --git a/src/Entity/Brand.php b/src/Entity/Brand.php index a0f1f22..e211fbc 100644 --- a/src/Entity/Brand.php +++ b/src/Entity/Brand.php @@ -9,52 +9,52 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Table(name: 'brand', schema: 'collection')] #[ORM\Entity] #[ORM\UniqueConstraint(name: 'brand_unq', columns: ["name"])] -class Brand -{ - use GetSetTrait; +class Brand { + use GetSetTrait; - #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] - #[ORM\Id] - #[ORM\GeneratedValue(strategy: 'IDENTITY')] - #[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)] - private int $id; + #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + #[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)] + private int $id; /** * @var Collection */ - #[ORM\ManyToMany(targetEntity: BrandCategory::class)] + #[ORM\ManyToMany(targetEntity: BrandCategory::class, fetch: 'EAGER')] #[ORM\JoinTable(name: 'collection.brand_category_link')] #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')] #[ORM\InverseJoinColumn(name: 'brand_category', referencedColumnName: 'category_name')] #[ORM\OrderBy(['name' => 'asc'])] private Collection $categories; - #[ORM\Column(name: 'name', unique: TRUE, nullable: FALSE)] - private string $name; + #[ORM\Column(name: 'name', unique: TRUE, nullable: FALSE)] + private string $name; - public function __construct() - { - $this->categories = new ArrayCollection(); - } + public function __construct() + { + $this->categories = new ArrayCollection(); + } - public function __toString(): string - { - return $this->name; - } + public function __toString(): string + { + return $this->name; + } - public function addCategory(BrandCategory $category): self - { - if (!$this->categories->contains($category)) { - $this->categories->add($category); - } + public function addCategory(BrandCategory $category): self + { + if ( ! $this->categories->contains($category)) + { + $this->categories->add($category); + } - return $this; - } + return $this; + } - public function removeCategory(BrandCategory $category): self - { - $this->categories->removeElement($category); + public function removeCategory(BrandCategory $category): self + { + $this->categories->removeElement($category); - return $this; - } + return $this; + } } diff --git a/src/Entity/Cpu.php b/src/Entity/Cpu.php index fb7d456..a0762ae 100644 --- a/src/Entity/Cpu.php +++ b/src/Entity/Cpu.php @@ -15,7 +15,7 @@ class Cpu { #[ORM\GeneratedValue(strategy: 'IDENTITY')] private int $id; - #[ORM\ManyToOne(targetEntity: 'Brand')] + #[ORM\ManyToOne(targetEntity: 'Brand', fetch: 'EAGER')] #[ORM\OrderBy(['name' => 'asc'])] #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id', nullable: FALSE)] private Brand $brand; diff --git a/src/Entity/Fpu.php b/src/Entity/Fpu.php index e69de29..60b9288 100644 --- a/src/Entity/Fpu.php +++ b/src/Entity/Fpu.php @@ -0,0 +1,41 @@ + 'asc'])] + #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id', nullable: FALSE)] + private Brand $brand; + + #[ORM\ManyToOne(targetEntity: 'Socket', fetch: 'EAGER')] + #[ORM\OrderBy(['name' => 'asc'])] + #[ORM\JoinColumn(name: 'socket_id', referencedColumnName: 'id', nullable: FALSE)] + private Socket $socket; + + #[ORM\Column(name: 'series', type: 'string', nullable: TRUE)] + private ?string $series = ''; + + #[ORM\Column(name: 'model', type: 'string')] + private string $model; + + #[ORM\Column(name: 'clock_speed', type: 'integer')] + private int $clockSpeed = 33; + + #[ORM\Column(name: 'count', nullable: FALSE, options: array('default' => 1))] + private int $count = 1; + + #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] + private ?string $notes = ''; +} diff --git a/src/Entity/Gpu.php b/src/Entity/Gpu.php index 924b2cf..e97ded7 100644 --- a/src/Entity/Gpu.php +++ b/src/Entity/Gpu.php @@ -10,37 +10,36 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Table(name: 'gpu', schema: 'collection')] #[ORM\Entity] -class Gpu -{ - use GetSetTrait; +class Gpu { + use GetSetTrait; - #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] - #[ORM\Id] - #[ORM\GeneratedValue(strategy: 'IDENTITY')] - private int $id; + #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + private int $id; - #[ORM\ManyToOne(targetEntity: 'Brand')] - #[ORM\OrderBy(['name' => 'asc'])] - #[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)] - private Brand $gpuBrand; + #[ORM\ManyToOne(targetEntity: 'Brand', fetch: 'EAGER')] + #[ORM\OrderBy(['name' => 'asc'])] + #[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)] + private Brand $gpuBrand; - #[ORM\ManyToOne(targetEntity: 'GpuCore')] - #[ORM\OrderBy(['brand' => 'asc', 'name' => 'asc'])] - #[ORM\JoinColumn(name: 'gpu_core_id', referencedColumnName: 'id', nullable: TRUE)] - private ?GpuCore $gpuCore = null; + #[ORM\ManyToOne(targetEntity: 'GpuCore', fetch: 'EAGER')] + #[ORM\OrderBy(['brand' => 'asc', 'name' => 'asc'])] + #[ORM\JoinColumn(name: 'gpu_core_id', referencedColumnName: 'id', nullable: TRUE)] + private ?GpuCore $gpuCore = NULL; - #[ORM\Column(name: 'reference_model_name', nullable: FALSE)] - private string $modelName; + #[ORM\Column(name: 'reference_model_name', nullable: FALSE)] + private string $modelName; - #[ORM\ManyToOne(targetEntity: 'Brand')] + #[ORM\ManyToOne(targetEntity: 'Brand', fetch: 'EAGER')] #[ORM\OrderBy(['name' => 'asc'])] #[ORM\JoinColumn(name: 'board_brand_id', referencedColumnName: 'id', nullable: TRUE)] private ?Brand $boardBrand = NULL; - #[ORM\Column(name: 'alternate_model_name', nullable: TRUE)] - private ?string $alternateModelName = ''; + #[ORM\Column(name: 'alternate_model_name', nullable: TRUE)] + private ?string $alternateModelName = ''; - #[ORM\Column( + #[ORM\Column( name: 'card_key', type: 'string', enumType: SlotKeyEnum::class, @@ -49,9 +48,9 @@ class Gpu 'default' => "PCIe x16" ) )] - private SlotKeyEnum $cardKey = SlotKeyEnum::PCIE_X16; + private SlotKeyEnum $cardKey = SlotKeyEnum::PCIE_X16; - #[ORM\Column( + #[ORM\Column( name: 'bus_interface', type: 'string', nullable: TRUE, @@ -60,7 +59,7 @@ class Gpu )] private ?CardBusEnum $busInterface; - #[ORM\Column( + #[ORM\Column( name: 'slot_span', options: array( 'comment' => "How many expansion slots the card occupies", @@ -69,102 +68,102 @@ class Gpu )] private int $slotSpan = 1; - #[ORM\Column(name: 'molex_power', options: array('default' => 0))] + #[ORM\Column(name: 'molex_power', options: array('default' => 0))] private int $molexPower = 0; - #[ORM\Column(name: 'pcie_6_pin', options: array('default' => 0))] + #[ORM\Column(name: 'pcie_6_pin', options: array('default' => 0))] private int $pcie6power = 0; - #[ORM\Column(name: 'pcie_8_pin', options: array('default' => 0))] + #[ORM\Column(name: 'pcie_8_pin', options: array('default' => 0))] private int $pcie8power = 0; - #[ORM\Column( + #[ORM\Column( name: 'tdp', nullable: TRUE, options: array('comment' => "Thermal Design Power (in Watts)") )] - private ?int $tdp = 0; + private ?int $tdp = 0; - #[ORM\Column( + #[ORM\Column( name: 'base_clock', nullable: TRUE, options: array('comment' => "Base speed of the gpu core, in MHz") )] private ?int $baseClock; - #[ORM\Column( + #[ORM\Column( name: 'boost_clock', nullable: TRUE, options: array('comment' => "GPU core boost clock, in MHz") )] private ?int $boostClock; - #[ORM\Column( + #[ORM\Column( name: 'memory_clock', nullable: TRUE, options: array('comment' => "Clock speed of the VRAM, in MHz") )] private ?int $memoryClock; - #[ORM\Column( + #[ORM\Column( name: 'memory_size', nullable: TRUE, options: array('comment' => 'VRAM size, in MiB') )] private ?int $memorySize; - #[ORM\Column( + #[ORM\Column( name: 'memory_bus', nullable: TRUE, options: array("comment" => 'The width of the memory bus in bits') )] private ?int $memoryBus; - #[ORM\Column(name: 'memory_type', nullable: TRUE)] + #[ORM\Column(name: 'memory_type', nullable: TRUE)] private ?string $memoryType; - #[ORM\Column(name: 'shading_units', nullable: TRUE)] + #[ORM\Column(name: 'shading_units', nullable: TRUE)] private ?int $shadingUnits; - #[ORM\Column(name: 'tmus', nullable: TRUE)] + #[ORM\Column(name: 'tmus', nullable: TRUE)] private ?int $tmus; - #[ORM\Column(name: 'rops', nullable: TRUE)] + #[ORM\Column(name: 'rops', nullable: TRUE)] private ?int $rops; - #[ORM\Column(name: 'compute_units', nullable: TRUE)] + #[ORM\Column(name: 'compute_units', nullable: TRUE)] private ?int $computeUnits; - #[ORM\Column(name: 'l1_cache', nullable: TRUE)] + #[ORM\Column(name: 'l1_cache', nullable: TRUE)] private ?string $l1cache; - #[ORM\Column(name: 'l2_cache', nullable: TRUE)] + #[ORM\Column(name: 'l2_cache', nullable: TRUE)] private ?string $l2cache; - #[ORM\Column(name: 'direct_x_support', nullable: TRUE)] + #[ORM\Column(name: 'direct_x_support', nullable: TRUE)] private ?string $directXSupport; - #[ORM\Column(name: 'opengl_support', nullable: TRUE)] + #[ORM\Column(name: 'opengl_support', nullable: TRUE)] private ?string $openGLSupport; - #[ORM\Column(name: 'opencl_support', nullable: TRUE)] + #[ORM\Column(name: 'opencl_support', nullable: TRUE)] private ?string $openCLSupport; - #[ORM\Column(name: 'vulkan_support', nullable: TRUE)] + #[ORM\Column(name: 'vulkan_support', nullable: TRUE)] private ?string $vulkanSupport; - #[ORM\Column(name: 'shader_model', nullable: TRUE)] + #[ORM\Column(name: 'shader_model', nullable: TRUE)] private ?string $shaderModel; - #[ORM\Column(name: 'link', nullable: TRUE)] - private ?string $link; + #[ORM\Column(name: 'link', nullable: TRUE)] + private ?string $link; - #[ORM\Column(name: 'count', nullable: FALSE, options: array('default' => 1))] - private int $count = 1; + #[ORM\Column(name: 'count', nullable: FALSE, options: array('default' => 1))] + private int $count = 1; - #[ORM\Column(name: 'acquired', nullable: FALSE, options: array('default' => true))] + #[ORM\Column(name: 'acquired', nullable: FALSE, options: array('default' => TRUE))] private bool $acquired; - #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] - private ?string $notes = ''; + #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] + private ?string $notes = ''; } diff --git a/src/Entity/GpuCore.php b/src/Entity/GpuCore.php index 5e6c2e9..48e7f14 100644 --- a/src/Entity/GpuCore.php +++ b/src/Entity/GpuCore.php @@ -7,47 +7,46 @@ use Stringable; #[ORM\Table(name: 'gpu_core', schema: 'collection')] #[ORM\Entity] -class GpuCore implements Stringable -{ - use GetSetTrait; +class GpuCore implements Stringable { + use GetSetTrait; - #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] - #[ORM\Id] - #[ORM\GeneratedValue(strategy: 'IDENTITY')] - private int $id; + #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + private int $id; - #[ORM\ManyToOne(targetEntity: 'Brand')] - #[ORM\OrderBy(['name' => 'asc'])] - #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id', nullable: FALSE)] - private Brand $brand; + #[ORM\ManyToOne(targetEntity: 'Brand', fetch: 'EAGER')] + #[ORM\OrderBy(['name' => 'asc'])] + #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id', nullable: FALSE)] + private Brand $brand; - #[ORM\Column(name: 'name')] - private string $name; + #[ORM\Column(name: 'name')] + private string $name; - #[ORM\Column(name: 'variant', nullable: TRUE)] - private ?string $variant; + #[ORM\Column(name: 'variant', nullable: TRUE)] + private ?string $variant; - #[ORM\Column(name: 'generation_name', nullable: TRUE)] - private string $generationName; + #[ORM\Column(name: 'generation_name', nullable: TRUE)] + private string $generationName; - #[ORM\Column(name: 'generation_link', nullable: TRUE)] - private ?string $generationLink = ''; + #[ORM\Column(name: 'generation_link', nullable: TRUE)] + private ?string $generationLink = ''; - #[ORM\Column(name: 'architecture', nullable: TRUE)] - private string $architecture; + #[ORM\Column(name: 'architecture', nullable: TRUE)] + private string $architecture; - #[ORM\Column(name: 'architecture_link', nullable: TRUE)] - private string $architectureLink; + #[ORM\Column(name: 'architecture_link', nullable: TRUE)] + private string $architectureLink; - #[ORM\Column(name: 'process_node', nullable: TRUE)] - private ?int $processNode; + #[ORM\Column(name: 'process_node', nullable: TRUE)] + private ?int $processNode; - public function __toString(): string - { + public function __toString(): string + { $name = ( ! empty($this->variant)) - ? "{$this->name} ({$this->variant})" + ? "$this->name ($this->variant)" : $this->name; - return "{$name} - [{$this->brand}] $this->generationName"; - } + return "$name - [$this->brand] $this->generationName"; + } } diff --git a/src/Entity/Socket.php b/src/Entity/Socket.php index ae2458a..be08b6c 100644 --- a/src/Entity/Socket.php +++ b/src/Entity/Socket.php @@ -22,7 +22,7 @@ class Socket { private string $name; #[ORM\Column(name: 'other_name', type: 'string', nullable: TRUE)] - private ?string $otherName = null; + private ?string $otherName = NULL; #[ORM\Column(name: 'pin_count', type: 'integer', nullable: FALSE)] private int $pinCount; @@ -38,6 +38,6 @@ class Socket { { $name = ( ! empty($this->otherName)) ? "$this->name/$this->otherName" : $this->name; - return "$name ($this->type->value $this->pinCount)"; + return "$name ({$this->type->value} $this->pinCount)"; } } diff --git a/src/Form/FpuType.php b/src/Form/FpuType.php new file mode 100644 index 0000000..bc5166e --- /dev/null +++ b/src/Form/FpuType.php @@ -0,0 +1,43 @@ +add('socket', EntityType::class, [ + 'class' => Socket::class, + 'query_builder' => static fn(EntityRepository $e) => $e->createQueryBuilder('s')->orderBy('s.name', 'ASC'), + ]) + ->add('brand', EntityType::class, [ + 'class' => Brand::class, + 'query_builder' => self::filterBrands('fpu'), + ]) + ->add('series') + ->add('model') + ->add('clockSpeed') + ->add('count') + ->add('notes') + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Fpu::class, + ]); + } +} diff --git a/src/Migrations/Version20221025152435.php b/src/Migrations/Version20221025152435.php new file mode 100644 index 0000000..cd06516 --- /dev/null +++ b/src/Migrations/Version20221025152435.php @@ -0,0 +1,46 @@ +addSql('CREATE TABLE collection.cpu_socket_link (socket_id INT NOT NULL, cpu_id INT NOT NULL, PRIMARY KEY(socket_id, cpu_id))'); + $this->addSql('CREATE INDEX IDX_B1ADF47DD20E239C ON collection.cpu_socket_link (socket_id)'); + $this->addSql('CREATE INDEX IDX_B1ADF47D3917014 ON collection.cpu_socket_link (cpu_id)'); + $this->addSql('CREATE TABLE collection.fpu (id SERIAL NOT NULL, brand_id INT NOT NULL, socket_id INT NOT NULL, model VARCHAR(255) NOT NULL, clock_speed INT NOT NULL, count INT DEFAULT 1 NOT NULL, notes TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_C741FA5844F5D008 ON collection.fpu (brand_id)'); + $this->addSql('CREATE INDEX IDX_C741FA58D20E239C ON collection.fpu (socket_id)'); + $this->addSql('ALTER TABLE collection.cpu_socket_link ADD CONSTRAINT FK_B1ADF47DD20E239C FOREIGN KEY (socket_id) REFERENCES collection.cpu (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE collection.cpu_socket_link ADD CONSTRAINT FK_B1ADF47D3917014 FOREIGN KEY (cpu_id) REFERENCES collection.socket (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE collection.fpu ADD CONSTRAINT FK_C741FA5844F5D008 FOREIGN KEY (brand_id) REFERENCES collection.brand (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE collection.fpu ADD CONSTRAINT FK_C741FA58D20E239C FOREIGN KEY (socket_id) REFERENCES collection.socket (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE collection.cpu_socket_link DROP CONSTRAINT FK_B1ADF47DD20E239C'); + $this->addSql('ALTER TABLE collection.cpu_socket_link DROP CONSTRAINT FK_B1ADF47D3917014'); + $this->addSql('ALTER TABLE collection.fpu DROP CONSTRAINT FK_C741FA5844F5D008'); + $this->addSql('ALTER TABLE collection.fpu DROP CONSTRAINT FK_C741FA58D20E239C'); + $this->addSql('DROP TABLE collection.cpu_socket_link'); + $this->addSql('DROP TABLE collection.fpu'); + } +} diff --git a/src/Migrations/Version20221025172539.php b/src/Migrations/Version20221025172539.php new file mode 100644 index 0000000..a558dd4 --- /dev/null +++ b/src/Migrations/Version20221025172539.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE collection.fpu ADD series VARCHAR(255) NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE collection.fpu DROP series'); + } +} diff --git a/templates/fpu/edit.html.twig b/templates/fpu/edit.html.twig new file mode 100644 index 0000000..f3e7174 --- /dev/null +++ b/templates/fpu/edit.html.twig @@ -0,0 +1,31 @@ +{% extends 'form.html.twig' %} + +{% block title %}Edit Fpu{% endblock %} + +{% block form %} +

Edit Fpu

+ +
+ +
+ +
+ {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + + +
+ + +
+
+{% endblock %} diff --git a/templates/fpu/index.html.twig b/templates/fpu/index.html.twig new file mode 100644 index 0000000..54104c9 --- /dev/null +++ b/templates/fpu/index.html.twig @@ -0,0 +1,57 @@ +{% extends 'base.html.twig' %} + +{% block title %}Fpu index{% endblock %} + +{% block body %} +

Fpu index

+ +
+ +
+ + + + + + + + + + + + + + + + {% for fpu in fpus %} + + + + + + + + + + + {% else %} + + + + {% endfor %} + +
 IdSocketBrand SeriesModelClock SpeedCountNotes
+ + {{ fpu.id }}{{ fpu.socket }}{{ fpu.brand.name }} {{ fpu.series }}{{ fpu.model }}{{ fpu.clockSpeed }} MHz{{ fpu.count }}{{ fpu.notes }}
no records found
+{% endblock %} diff --git a/templates/fpu/new.html.twig b/templates/fpu/new.html.twig new file mode 100644 index 0000000..1713a8f --- /dev/null +++ b/templates/fpu/new.html.twig @@ -0,0 +1,25 @@ +{% extends 'form.html.twig' %} + +{% block title %}New Fpu{% endblock %} + +{% block form %} +

Add Fpu

+ +
+ +
+ +
+ {{ form_start(form) }} + {{ form_widget(form) }} + + {{ form_end(form) }} +
+{% endblock %} diff --git a/templates/fpu/show.html.twig b/templates/fpu/show.html.twig new file mode 100644 index 0000000..5ef8d71 --- /dev/null +++ b/templates/fpu/show.html.twig @@ -0,0 +1,58 @@ +{% extends 'form.html.twig' %} + +{% block title %}Fpu{% endblock %} + +{% block form %} +

Fpu

+ +
+ + + +
+ + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ fpu.id }}
Series{{ fpu.series }}
Model{{ fpu.model }}
ClockSpeed{{ fpu.clockSpeed }}
Count{{ fpu.count }}
Notes{{ fpu.notes }}
+
+{% endblock %} diff --git a/templates/header.html.twig b/templates/header.html.twig index e20dcb1..53232d4 100644 --- a/templates/header.html.twig +++ b/templates/header.html.twig @@ -9,6 +9,9 @@
  • 💃 Brand Categories
  • +
  • + 🌀 GPU Cores +
  • 📍Sockets
  • @@ -30,16 +33,16 @@ @@ -53,19 +56,16 @@