mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 21:13:40 +02:00
The PR is a huge refactor of all Reflect and Vegvisir code. I've merged the API and "Front-end" codebases together into the same root, this will allow for both Reflect and Vegvisir to use the same resources. Not only that, but I've also added proper database modeling with actual OOP inheritance for database tables. Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/23
496 lines
No EOL
16 KiB
PHP
496 lines
No EOL
16 KiB
PHP
<?php
|
|
|
|
use Vegvisir\Path;
|
|
|
|
use VLW\Client\API;
|
|
use VLW\API\Endpoints;
|
|
|
|
use VLW\Database\Tables\Battlestation\{
|
|
MbTable,
|
|
CpuTable,
|
|
GpuTable,
|
|
PsuTable,
|
|
DramTable,
|
|
StorageTable,
|
|
ChassisTable
|
|
};
|
|
use VLW\Database\Tables\Battlestation\Config\{
|
|
MbPsuTable,
|
|
MbGpuTable,
|
|
MbDramTable,
|
|
ConfigModel,
|
|
MbStorageTable,
|
|
ChassisMbTable,
|
|
MbCpuCoolerModel,
|
|
MbStorageSlotFormfactorEnum
|
|
};
|
|
|
|
require_once VV::root("src/client/API.php");
|
|
require_once VV::root("api/src/Endpoints.php");
|
|
|
|
// Load hardware database models
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Mb.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Cpu.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Gpu.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Psu.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Dram.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Storage.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Chassis.php");
|
|
|
|
// Load hardware config database models
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/MbPsu.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/MbGpu.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/MbDram.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/Config.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/MbStorage.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/ChassisMb.php");
|
|
require_once VV::root("api/src/Database/Tables/Battlestation/Config/MbCpuCooler.php");
|
|
|
|
const GIGA = 0x3B9ACA00;
|
|
const MEGA = 0xF4240;
|
|
|
|
// Connect to VLW API
|
|
$api = new API();
|
|
|
|
$config = $api->call(Endpoints::BATTLESTATION->value)->get();
|
|
|
|
?>
|
|
<style><?= VV::css("public/assets/css/pages/about/battlestation") ?></style>
|
|
<?php if ($config->ok): ?>
|
|
<section class="title">
|
|
<h1>Battle­stations</h1>
|
|
<p>I'd be happy to send you, dear reader, any component that you find here for "free" that hasn't been retired yet. The only thing I ask in return is that you pay for shipping.</p>
|
|
<p>I can't guarantee the thing you want will work as expected, or work at all! But I will test the compontent for you if I still have means at hand to do so.</p>
|
|
<div>
|
|
<a href="/about/battlestation-retired"><button class="inline solid">Retired components</button></a>
|
|
<a href="/contact"><button class="inline">Contact me</button></a>
|
|
</div>
|
|
</section>
|
|
|
|
<?php foreach ($config->json() as $config): ?>
|
|
|
|
<?php
|
|
|
|
// Get motherboard details by ref_mb_id from config
|
|
$motherboard = $api->call(Endpoints::BATTLESTATION_MB->value)->params([
|
|
MbTable::ID->value => $config[ChassisMbTable::REF_MB_ID->value]
|
|
])->get()->json()[0];
|
|
|
|
?>
|
|
|
|
<section class="heading">
|
|
<h1><?= $config[ConfigModel::FRIENDLY_NAME->value] ?? "Lucious" ?></h1>
|
|
<p>This rig was built: <?= date(API::DATE_FORMAT, $config[ConfigModel::DATE_BUILT->value]) ?></p>
|
|
</section>
|
|
<section class="config"
|
|
data-mb="1"
|
|
data-cpu="<?= count($motherboard["cpus"]) ?>"
|
|
data-psu="<?= count($motherboard["psus"]) ?>"
|
|
data-gpu="<?= count($motherboard["gpus"]) ?>"
|
|
data-dram="<?= count($motherboard["dram"]) ?>"
|
|
data-case="<?= count($motherboard["chassis"]) ?>"
|
|
data-drives-mdottwo="<?= count(array_keys(array_column($motherboard["storage"], MbStorageTable::SLOT_FORMFACTOR->value), MbStorageSlotFormfactorEnum::MDOTTWO->value)) ?>"
|
|
data-drives-twodotfive="<?= count(array_keys(array_column($motherboard["storage"], MbStorageTable::SLOT_FORMFACTOR->value), MbStorageSlotFormfactorEnum::TWODOTFIVE->value)) ?>"
|
|
data-drives-threedotfive="<?= count(array_keys(array_column($motherboard["storage"], MbStorageTable::SLOT_FORMFACTOR->value), MbStorageSlotFormfactorEnum::THREEDOTFIVE->value)) ?>"
|
|
>
|
|
<?= VV::embed("public/assets/media/battlestation.svg") ?>
|
|
<div class="specs">
|
|
|
|
<?php // Show motherboard details ?>
|
|
<?php if ($motherboard): ?>
|
|
<div data-target="mb" class="spec">
|
|
<p>Motherboard</p>
|
|
<h3><?= $motherboard[MbTable::VENDOR_NAME->value] ?> <span><?= $motherboard[MbTable::VENDOR_MODEL->value] ?></span></h3>
|
|
<div>
|
|
<div>
|
|
<label>Formfactor</label>
|
|
<p><?= $motherboard[MbTable::FORMFACTOR->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $motherboard[MbTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $motherboard[MbTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>LAN</label>
|
|
<p><?= $motherboard[MbTable::NETWORK_ETHERNET->value] ?? "No LAN" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>WLAN</label>
|
|
<p><?= $motherboard[MbTable::NETWORK_WLAN->value] ?? "No WLAN" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Bluetooth</label>
|
|
<p><?= $motherboard[MbTable::NETWORK_BLUETOOTH->value] ?? "No Bluetooth" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $motherboard[MbTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($motherboard[MbTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php // List all cases (lol) ?>
|
|
<?php foreach ($motherboard["chassis"] as $mb_chassis): ?>
|
|
|
|
<?php // Get case details from endpoint by id ?>
|
|
<?php $case = $api->call(Endpoints::BATTLESTATION_CHASSIS->value)->params([
|
|
ChassisTable::ID->value => $mb_chassis[ChassisMbTable::REF_CHASSIS_ID->value]
|
|
])->get()->json()[0]; ?>
|
|
|
|
<div data-target="case" class="spec">
|
|
<p>Case</p>
|
|
<h3><?= $case[ChassisTable::VENDOR_NAME->value] ?> <span><?= $case[ChassisTable::VENDOR_MODEL->value] ?></span></h3>
|
|
<div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $case[ChassisTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $case[ChassisTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Nº 2.5" slots</label>
|
|
<p><?= $case[ChassisTable::STORAGE_TWOINCHFIVE->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Nº 3.5" slots</label>
|
|
<p><?= $case[ChassisTable::STORAGE_THREEINCHFIVE->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $case[ChassisTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($case[ChassisTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php // List all CPUs ?>
|
|
<?php foreach ($motherboard["cpus"] as $mb_cpu): ?>
|
|
|
|
<?php // Get case details from endpoint by id ?>
|
|
<?php $cpu = $api->call(Endpoints::BATTLESTATION_CPU->value)->params([
|
|
CpuTable::ID->value => $mb_cpu[MbCpuCoolerModel::REF_CPU_ID->value]
|
|
])->get()->json()[0]; ?>
|
|
|
|
<div data-target="cpu" class="spec">
|
|
<p>CPU</p>
|
|
<h3><?= $cpu[CpuTable::VENDOR_NAME->value] ?> <span><?= $cpu[CpuTable::VENDOR_MODEL->value] ?></span></h3>
|
|
<div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $cpu[CpuTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $cpu[CpuTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Class</label>
|
|
<p><?= $cpu[CpuTable::CPU_CLASS->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Base Clockspeed</label>
|
|
<p><?= $cpu[CpuTable::CLOCK_BASE->value] / GIGA ?>GHz</p>
|
|
</div>
|
|
<div>
|
|
<label>Turbo Clockspeed</label>
|
|
<p><?= $cpu[CpuTable::CLOCK_TURBO->value] / GIGA ?>GHz</p>
|
|
</div>
|
|
<div>
|
|
<label>Nº cores (P/E)</label>
|
|
<p><?= $cpu[CpuTable::CORE_COUNT_PERFORMANCE->value] + $cpu[CpuTable::CORE_COUNT_EFFICIENCY->value] ?> (<?= $cpu[CpuTable::CORE_COUNT_PERFORMANCE->value] ?>/<?= $cpu[CpuTable::CORE_COUNT_EFFICIENCY->value] ?>)</p>
|
|
</div>
|
|
<div>
|
|
<label>Nº total threads</label>
|
|
<p><?= $cpu[CpuTable::CORE_THREADS->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $cpu[CpuTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($cpu[CpuTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
<label>In motherboard slot number</label>
|
|
<p><?= $mb_cpu[MbCpuCoolerModel::SOCKET->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Motherboard slot type</label>
|
|
<p><?= $mb_cpu[MbCpuCoolerModel::SOCKET_TYPE->value] ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php // List all GPUs ?>
|
|
<?php foreach ($motherboard["gpus"] as $mb_gpu): ?>
|
|
|
|
<?php // Get case details from endpoint by id ?>
|
|
<?php $gpu = $api->call(Endpoints::BATTLESTATION_GPU->value)->params([
|
|
GpuTable::ID->value => $mb_gpu[MbGpuTable::REF_GPU_ID->value]
|
|
])->get()->json()[0]; ?>
|
|
|
|
<div data-target="gpu" class="spec">
|
|
<p>GPU</p>
|
|
<h3><?= $gpu[GpuTable::VENDOR_NAME->value] ?> <span><?= $gpu[GpuTable::VENDOR_CHIP_MODEL->value] ?></span></h3>
|
|
<div>
|
|
<div>
|
|
<label>Chip brand name</label>
|
|
<p><?= $gpu[GpuTable::VENDOR_CHIP_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Chip brand model</label>
|
|
<p><?= $gpu[GpuTable::VENDOR_CHIP_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>VRAM</label>
|
|
<p><?= $gpu[GpuTable::MEMORY->value] / GIGA ?>GB</p>
|
|
</div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $gpu[GpuTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $gpu[GpuTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $gpu[GpuTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($gpu[GpuTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php // List all PSUs ?>
|
|
<?php foreach ($motherboard["psus"] as $mb_psu): ?>
|
|
|
|
<?php // Get case details from endpoint by id ?>
|
|
<?php $psu = $api->call(Endpoints::BATTLESTATION_PSU->value)->params([
|
|
PsuTable::ID->value => $mb_psu[MbPsuTable::REF_PSU_ID->value]
|
|
])->get()->json()[0]; ?>
|
|
|
|
<div data-target="psu" class="spec">
|
|
<p>PSU</p>
|
|
<h3><?= $psu[PsuTable::VENDOR_NAME->value] ?> <span><?= $psu[PsuTable::VENDOR_MODEL->value] ?></span> <span><?= $psu[PsuTable::POWER->value] ?>W</span></h3>
|
|
<div>
|
|
<div>
|
|
<label>Power</label>
|
|
<p><?= $psu[PsuTable::POWER->value] ?>W</p>
|
|
</div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $psu[PsuTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $psu[PsuTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Is modular?</label>
|
|
<p><?= $psu[PsuTable::TYPE_MODULAR->value] === "TRUE" ? "Yes" : "No" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>80+ Rating</label>
|
|
<p><?= $psu[PsuTable::EIGHTYPLUS_RATING->value] ?? "None" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $psu[PsuTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($psu[PsuTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<div class="group">
|
|
<p>DRAM</p>
|
|
<?= VV::embed("public/assets/media/icons/chevron.svg") ?>
|
|
</div>
|
|
|
|
<div class="collection">
|
|
<?php // List all DRAM ?>
|
|
<?php foreach ($motherboard["dram"] as $mb_dram): ?>
|
|
|
|
<?php // Get case details from endpoint by id ?>
|
|
<?php $dram = $api->call(Endpoints::BATTLESTATION_DRAM->value)->params([
|
|
DramTable::ID->value => $mb_dram[MbDramTable::REF_DRAM_ID->value]
|
|
])->get()->json()[0]; ?>
|
|
|
|
<div data-target="dram" class="spec">
|
|
<p>DRAM - <?= $dram[DramTable::TECHNOLOGY->value] ?></p>
|
|
<h3><?= $dram[DramTable::VENDOR_NAME->value] ?>
|
|
<span><?= $dram[DramTable::CAPACITY->value] / GIGA ?>GB</span>
|
|
<span><?= $dram[DramTable::SPEED->value] / MEGA ?>MHz</span>
|
|
</h3>
|
|
<div>
|
|
<div>
|
|
<label>Capacity</label>
|
|
<p><?= $dram[DramTable::CAPACITY->value] / GIGA ?>GB</p>
|
|
</div>
|
|
<div>
|
|
<label>Speed</label>
|
|
<p><?= $dram[DramTable::SPEED->value] / MEGA ?>MHz</p>
|
|
</div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $dram[DramTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $dram[DramTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Formfactor</label>
|
|
<p><?= $dram[DramTable::FORMFACTOR->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Technology</label>
|
|
<p><?= $dram[DramTable::TECHNOLOGY->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Is ECC?</label>
|
|
<p><?= $dram[DramTable::ECC->value] === "TRUE" ? "Yes" : "No" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Is buffered?</label>
|
|
<p><?= $dram[DramTable::BUFFERED->value] === "TRUE" ? "Yes" : "No" ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $dram[DramTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($dram[DramTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
<label>In motherboard slot number</label>
|
|
<p><?= $mb_dram[MbDramTable::SOCKET->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Motherboard slot type</label>
|
|
<p><?= $mb_dram[MbDramTable::SOCKET_TYPE->value] ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div class="group">
|
|
<p>Storage</p>
|
|
<?= VV::embed("public/assets/media/icons/chevron.svg") ?>
|
|
</div>
|
|
|
|
<div class="collection">
|
|
<?php // List all storage ?>
|
|
<?php foreach ($motherboard["storage"] as $mb_storage): ?>
|
|
|
|
<?php // Get case details from endpoint by id ?>
|
|
<?php $storage = $api->call(Endpoints::BATTLESTATION_STORAGE->value)->params([
|
|
StorageTable::ID->value => $mb_storage[MbStorageTable::REF_STORAGE_ID->value]
|
|
])->get()->json()[0]; ?>
|
|
|
|
<div data-target="drive" class="spec">
|
|
<p><?= $storage[StorageTable::DISK_FORMFACTOR->value] ?> <?= $storage[StorageTable::DISK_TYPE->value] ?></p>
|
|
<h3>
|
|
<?= $storage[StorageTable::VENDOR_NAME->value] ?>
|
|
<span><?= floor($storage[StorageTable::DISK_SIZE->value] / GIGA) ?>GB</span>
|
|
</h3>
|
|
<div>
|
|
<div>
|
|
<label>Type</label>
|
|
<p><?= $storage[StorageTable::DISK_TYPE->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Capacity</label>
|
|
<p><?= floor($storage[StorageTable::DISK_SIZE->value] / GIGA) ?>GB</p>
|
|
</div>
|
|
<div>
|
|
<label>Interface</label>
|
|
<p><?= $storage[StorageTable::DISK_INTERFACE->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Formfactor</label>
|
|
<p><?= $storage[StorageTable::DISK_FORMFACTOR->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand name</label>
|
|
<p><?= $storage[StorageTable::VENDOR_NAME->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Brand model</label>
|
|
<p><?= $storage[StorageTable::VENDOR_MODEL->value] ?></p>
|
|
</div>
|
|
<div>
|
|
<label>Aquired</label>
|
|
<p><?= date(API::DATE_FORMAT, $storage[StorageTable::DATE_AQUIRED->value]) ?></p>
|
|
</div>
|
|
|
|
<?php if ($storage[StorageTable::IS_RETIRED->value]): ?>
|
|
<div>
|
|
<label>Retired</label>
|
|
<p>Yes</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
<label>Attatched via interface</label>
|
|
<p><?= $mb_storage[MbStorageTable::INTERFACE->value] ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
</div>
|
|
</section>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
<script type="module"><?= VV::js("public/assets/js/pages/about/battlestation") ?></script>
|