Ugly progress commit

This commit is contained in:
Timothy Warren 2022-10-07 16:04:34 -04:00
parent fb296c1034
commit 58e7519462
8 changed files with 603 additions and 33 deletions

View File

@ -0,0 +1,56 @@
<?php declare(strict_types=1);
namespace App\Controller;
use App\Entity\Gpu;
use App\Form\GpuType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu')]
class GpuController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = Gpu::class;
protected const TEMPLATE_PATH = 'gpu/';
protected const ROUTE_PREFIX = 'gpu_';
protected const FORM = GpuType::class;
public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
#[Route('/', name: 'gpu_index', methods: ['GET'])]
public function index(): Response
{
return $this->itemListView('gpus');
}
#[Route('/new', name: 'gpu_new', methods: ['GET', 'POST'])]
public function new(Request $request): Response
{
return $this->itemCreate($request, 'gpu');
}
#[Route('/{id}', name: 'gpu_show', methods: ['GET'])]
public function show(Gpu $gpu): Response
{
return $this->itemView($gpu, 'gpu');
}
#[Route('/{id}/edit', name: 'gpu_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Gpu $gpu): Response
{
return $this->itemUpdate($request, $gpu, 'gpu');
}
#[Route('/{id}', name: 'gpu_delete', methods: ['POST'])]
public function delete(Request $request, Gpu $gpu): Response
{
return $this->deleteCSRF($request, $gpu);
}
}

View File

@ -28,10 +28,12 @@ class GpuCoreController extends AbstractController
public function index(): Response
{
return $this->indexView('gpu_cores', [
'brand' => 'asc',
'architecture' => 'asc',
'name' => 'asc',
'variant' => 'asc',
'brand' => 'asc',
'processNode' => 'desc',
'generationName' => 'asc',
'architecture' => 'asc',
'name' => 'asc',
'variant' => 'asc',
]);
}

View File

@ -16,28 +16,109 @@ class Gpu
private int $id;
#[ORM\ManyToOne(targetEntity: 'Brand')]
#[ORM\JoinColumn(name: 'board_brand_id', referencedColumnName: 'id', nullable: TRUE)]
private readonly Brand $boardBrand;
#[ORM\ManyToOne(targetEntity: 'Brand')]
#[ORM\OrderBy(['name' => 'asc'])]
#[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)]
private readonly Brand $gpuBrand;
#[ORM\ManyToOne(targetEntity: 'GpuCore')]
#[ORM\OrderBy(['brand' => 'asc', 'name' => 'asc'])]
#[ORM\JoinColumn(name: 'gpu_core_id', referencedColumnName: 'id', nullable: TRUE)]
private readonly GpuCore $gpuCore;
#[ORM\Column(name: 'reference_model_name', nullable: FALSE)]
private readonly string $modelName;
#[ORM\ManyToOne(targetEntity: 'Brand')]
#[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 readonly string $alternateModelName;
private ?string $alternateModelName = '';
#[ORM\Column(name: 'card_key', nullable: TRUE)]
private readonly ?string $cardKey;
#[ORM\Column(name: 'bus_interface')]
private readonly ?string $busInterface;
#[ORM\Column(name: 'slot_width')]
private int $slotWidth = 1;
#[ORM\Column(name: 'molex_power')]
private int $molexPower = 0;
#[ORM\Column(name: 'pcie_6_pin')]
private int $pcie6power = 0;
#[ORM\Column(name: 'pcie_8_pin')]
private int $pcie8power = 0;
#[ORM\Column(name: 'tdp', nullable: TRUE)]
private readonly ?int $tdp;
#[ORM\Column(name: 'base_clock')]
private readonly ?int $baseClock;
#[ORM\Column(name: 'boost_clock')]
private readonly ?int $boostClock;
#[ORM\Column(name: 'memory_clock')]
private readonly ?int $memoryClock;
#[ORM\Column(name: 'memory_size')]
private readonly ?int $memorySize;
#[ORM\Column(name: 'memory_bus')]
private readonly ?int $memoryBus;
#[ORM\Column(name: 'memory_type')]
private readonly ?string $memoryType;
#[ORM\Column(name: 'shading_units')]
private readonly ?int $shadingUnits;
#[ORM\Column(name: 'tmus')]
private readonly ?int $tmus;
#[ORM\Column(name: 'rops')]
private readonly ?int $rops;
#[ORM\Column(name: 'compute_units')]
private readonly ?int $computeUnits;
#[ORM\Column(name: 'l1_cache')]
private readonly ?string $l1cache;
#[ORM\Column(name: 'l2_cache')]
private readonly ?string $l2cache;
#[ORM\Column(name: 'direct_x_support')]
private readonly ?string $directXSupport;
#[ORM\Column(name: 'opengl_support')]
private readonly ?string $openGLSupport;
#[ORM\Column(name: 'opencl_support')]
private readonly ?string $openCLSupport;
#[ORM\Column(name: 'vulkan_support')]
private readonly ?string $vulkanSupport;
#[ORM\Column(name: 'shader_model')]
private readonly ?string $shaderModel;
#[ORM\Column(name: 'link')]
private readonly string $link;
#[ORM\Column(name: 'count', nullable: FALSE)]
private readonly int $count;
private int $count = 1;
#[ORM\Column(name: 'acquired')]
private bool $acquired;
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]
private readonly string $notes;
private ?string $notes = '';
public function getId(): ?int
{
@ -68,6 +149,306 @@ class Gpu
return $this;
}
public function getCardKey(): ?string
{
return $this->cardKey;
}
public function setCardKey(?string $cardKey): self
{
$this->cardKey = $cardKey;
return $this;
}
public function getBusInterface(): ?string
{
return $this->busInterface;
}
public function setBusInterface(string $busInterface): self
{
$this->busInterface = $busInterface;
return $this;
}
public function getSlotWidth(): ?int
{
return $this->slotWidth;
}
public function setSlotWidth(int $slotWidth): self
{
$this->slotWidth = $slotWidth;
return $this;
}
public function getMolexPower(): ?int
{
return $this->molexPower;
}
public function setMolexPower(int $molexPower): self
{
$this->molexPower = $molexPower;
return $this;
}
public function getPcie6power(): ?int
{
return $this->pcie6power;
}
public function setPcie6power(int $pcie6power): self
{
$this->pcie6power = $pcie6power;
return $this;
}
public function getPcie8power(): ?int
{
return $this->pcie8power;
}
public function setPcie8power(int $pcie8power): self
{
$this->pcie8power = $pcie8power;
return $this;
}
public function getTdp(): ?int
{
return $this->tdp;
}
public function setTdp(?int $tdp): self
{
$this->tdp = $tdp;
return $this;
}
public function getBaseClock(): ?int
{
return $this->baseClock;
}
public function setBaseClock(int $baseClock): self
{
$this->baseClock = $baseClock;
return $this;
}
public function getBoostClock(): ?int
{
return $this->boostClock;
}
public function setBoostClock(int $boostClock): self
{
$this->boostClock = $boostClock;
return $this;
}
public function getMemoryClock(): ?int
{
return $this->memoryClock;
}
public function setMemoryClock(int $memoryClock): self
{
$this->memoryClock = $memoryClock;
return $this;
}
public function getMemorySize(): ?int
{
return $this->memorySize;
}
public function setMemorySize(int $memorySize): self
{
$this->memorySize = $memorySize;
return $this;
}
public function getMemoryBus(): ?int
{
return $this->memoryBus;
}
public function setMemoryBus(int $memoryBus): self
{
$this->memoryBus = $memoryBus;
return $this;
}
public function getMemoryType(): ?string
{
return $this->memoryType;
}
public function setMemoryType(string $memoryType): self
{
$this->memoryType = $memoryType;
return $this;
}
public function getShadingUnits(): ?int
{
return $this->shadingUnits;
}
public function setShadingUnits(int $shadingUnits): self
{
$this->shadingUnits = $shadingUnits;
return $this;
}
public function getTmus(): ?int
{
return $this->tmus;
}
public function setTmus(int $tmus): self
{
$this->tmus = $tmus;
return $this;
}
public function getRops(): ?int
{
return $this->rops;
}
public function setRops(int $rops): self
{
$this->rops = $rops;
return $this;
}
public function getComputeUnits(): ?int
{
return $this->computeUnits;
}
public function setComputeUnits(int $computeUnits): self
{
$this->computeUnits = $computeUnits;
return $this;
}
public function getL1cache(): ?string
{
return $this->l1cache;
}
public function setL1cache(string $l1cache): self
{
$this->l1cache = $l1cache;
return $this;
}
public function getL2cache(): ?string
{
return $this->l2cache;
}
public function setL2cache(string $l2cache): self
{
$this->l2cache = $l2cache;
return $this;
}
public function getDirectXSupport(): ?string
{
return $this->directXSupport;
}
public function setDirectXSupport(string $directXSupport): self
{
$this->directXSupport = $directXSupport;
return $this;
}
public function getOpenGLSupport(): ?string
{
return $this->openGLSupport;
}
public function setOpenGLSupport(string $openGLSupport): self
{
$this->openGLSupport = $openGLSupport;
return $this;
}
public function getOpenCLSupport(): ?string
{
return $this->openCLSupport;
}
public function setOpenCLSupport(string $openCLSupport): self
{
$this->openCLSupport = $openCLSupport;
return $this;
}
public function getVulkanSupport(): ?string
{
return $this->vulkanSupport;
}
public function setVulkanSupport(string $vulkanSupport): self
{
$this->vulkanSupport = $vulkanSupport;
return $this;
}
public function getShaderModel(): ?string
{
return $this->shaderModel;
}
public function setShaderModel(string $shaderModel): self
{
$this->shaderModel = $shaderModel;
return $this;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(string $link): self
{
$this->link = $link;
return $this;
}
public function getCount(): ?int
{
return $this->count;
@ -80,6 +461,18 @@ class Gpu
return $this;
}
public function isAcquired(): ?bool
{
return $this->acquired;
}
public function setAcquired(bool $acquired): self
{
$this->acquired = $acquired;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
@ -92,18 +485,6 @@ class Gpu
return $this;
}
public function getBoardBrand(): ?Brand
{
return $this->boardBrand;
}
public function setBoardBrand(?Brand $boardBrand): self
{
$this->boardBrand = $boardBrand;
return $this;
}
public function getGpuBrand(): ?Brand
{
return $this->gpuBrand;
@ -127,4 +508,16 @@ class Gpu
return $this;
}
public function getBoardBrand(): ?Brand
{
return $this->boardBrand;
}
public function setBoardBrand(?Brand $boardBrand): self
{
$this->boardBrand = $boardBrand;
return $this;
}
}

View File

@ -3,10 +3,11 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Stringable;
#[ORM\Table(name: 'gpu_core', schema: 'collection')]
#[ORM\Entity]
class GpuCore
class GpuCore implements Stringable
{
use GetSetTrait;
@ -16,6 +17,7 @@ class GpuCore
private int $id;
#[ORM\ManyToOne(targetEntity: 'Brand')]
#[ORM\OrderBy(['name' => 'asc'])]
#[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')]
private Brand $brand;
@ -28,6 +30,9 @@ class GpuCore
#[ORM\Column(name: 'generation_name')]
private readonly string $generationName;
#[ORM\Column(name: 'generation_link', nullable: TRUE)]
private ?string $generationLink = '';
#[ORM\Column(name: 'architecture')]
private readonly string $architecture;
@ -83,6 +88,18 @@ class GpuCore
return $this;
}
public function getGenerationLink(): ?string
{
return $this->generationLink;
}
public function setGenerationLink(?string $generationLink): self
{
$this->generationLink = $generationLink;
return $this;
}
public function getArchitecture(): ?string
{
return $this->architecture;

View File

@ -2,7 +2,9 @@
namespace App\Form;
use App\Entity\GpuCore;
use App\Entity\{Brand, GpuCore};
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -11,12 +13,16 @@ class GPUCoreType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('brand')
->add('brand', EntityType::class, [
'class' => Brand::class,
'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('b')->orderBy('b.name', 'ASC'),
])
->add('name')
->add('variant')
->add('architecture')
->add('architectureLink')
->add('generationName')
->add('generationLink')
->add('processNode');
}

69
src/Form/GpuType.php Normal file
View File

@ -0,0 +1,69 @@
<?php declare(strict_types=1);
namespace App\Form;
use App\Entity\{Brand, Gpu, GpuCore};
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\OptionsResolver\OptionsResolver;
class GpuType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$brandQueryBuilder = static fn (EntityRepository $e) => $e->createQueryBuilder('b')->orderBy('b.name', 'ASC');
$builder
->add('gpuBrand', EntityType::class, [
'class' => Brand::class,
'query_builder' => $brandQueryBuilder,
])
->add('modelName')
->add('gpuCore', EntityType::class, [
'class' => GpuCore::class,
'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('gc')->orderBy('gc.brand', 'ASC')->orderBy('gc.name', 'ASC'),
])
->add('boardBrand', EntityType::class, [
'class' => Brand::class,
'query_builder' => $brandQueryBuilder,
'empty_data' => NULL,
])
->add('alternateModelName')
->add('cardKey')
->add('busInterface')
->add('slotWidth')
->add('molexPower')
->add('pcie6power')
->add('pcie8power')
->add('tdp')
->add('baseClock')
->add('boostClock')
->add('memoryClock')
->add('memorySize')
->add('memoryBus')
->add('memoryType')
->add('shadingUnits')
->add('tmus')
->add('rops')
->add('computeUnits')
->add('l1cache')
->add('l2cache')
->add('directXSupport')
->add('openGLSupport')
->add('openCLSupport')
->add('vulkanSupport')
->add('shaderModel')
->add('link')
->add('count')
->add('acquired')
->add('notes');
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Gpu::class,
]);
}
}

View File

@ -21,7 +21,7 @@
<th>Brand</th>
<th>Name</th>
<th>Variant</th>
<th>GenerationName</th>
<th>Generation</th>
<th>Architecture</th>
<th>ProcessNode</th>
</tr>
@ -43,9 +43,24 @@
<td>{{ gpu_core.brand.name }}</td>
<td>{{ gpu_core.name }}</td>
<td>{{ gpu_core.variant }}</td>
<td>{{ gpu_core.generationName }}</td>
<td><a href="{{ gpu_core.architectureLink }}">{{ gpu_core.architecture }}</a></td>
<td>{{ gpu_core.processNode }}nm</td>
{% if gpu_core.generationLink %}
<td><a href="{{ gpu_core.generationLink }}">{{ gpu_core.generationName }}</a></td>
{% else %}
<td>{{ gpu_core.generationName }}</td>
{% endif %}
{% if gpu_core.architectureLink %}
<td><a href="{{ gpu_core.architectureLink }}">{{ gpu_core.architecture }}</a></td>
{% else %}
<td>{{ gpu_core.architecture }}</td>
{% endif %}
{% if gpu_core.processNode %}
<td>{{ gpu_core.processNode }} nm</td>
{% else %}
<td>?</td>
{% endif %}
</tr>
{% else %}

View File

@ -42,15 +42,27 @@
</tr>
<tr>
<th>GenerationName</th>
<td>{{ gpu_core.generationName }}</td>
{% if gpu_core.generationLink %}
<td><a href="{{ gpu_core.generationLink }}">{{ gpu_core.generationName }}</a></td>
{% else %}
<td>{{ gpu_core.generationName }}</td>
{% endif %}
</tr>
<tr>
<th>Architecture</th>
<td><a href="{{ gpu_core.architectureLink }}">{{ gpu_core.architecture }}</a></td>
{% if gpu_core.architectureLink %}
<td><a href="{{ gpu_core.architectureLink }}">{{ gpu_core.architecture }}</a></td>
{% else %}
<td>{{ gpu_core.architecture }}</td>
{% endif %}
</tr>
<tr>
<th>ProcessNode</th>
<td>{{ gpu_core.processNode }}nm</td>
{% if gpu_core.processNode %}
<td>{{ gpu_core.processNode }} nm</td>
{% else %}
<td>?</td>
{% endif %}
</tr>
</tbody>
</table>