diff --git a/app/Data/Node/Storage/StorageData.php b/app/Data/Node/Storage/StorageData.php new file mode 100644 index 00000000000..8c28807ac04 --- /dev/null +++ b/app/Data/Node/Storage/StorageData.php @@ -0,0 +1,24 @@ + 'required|boolean', 'has_lxc_templates' => 'required|boolean', 'has_backups' => 'required|boolean', - 'has_isos' => 'required|boolean', + 'has_iso' => 'required|boolean', 'has_snippets' => 'required|boolean', ]; diff --git a/app/Repositories/Proxmox/Node/ProxmoxStorageRepository.php b/app/Repositories/Proxmox/Node/ProxmoxStorageRepository.php index 1d64087fd35..e22cfd6c6da 100644 --- a/app/Repositories/Proxmox/Node/ProxmoxStorageRepository.php +++ b/app/Repositories/Proxmox/Node/ProxmoxStorageRepository.php @@ -2,25 +2,59 @@ namespace App\Repositories\Proxmox\Node; -use Carbon\CarbonImmutable; use App\Data\Helpers\ChecksumData; use App\Data\Node\Storage\FileMetaData; use App\Data\Node\Storage\IsoData; +use App\Data\Node\Storage\StorageData; use App\Enums\Node\Storage\ContentType; use App\Exceptions\Repository\Proxmox\ProxmoxConnectionException; use App\Exceptions\Service\Node\IsoLibrary\InvalidIsoLinkException; use App\Models\Node; use App\Repositories\Proxmox\ProxmoxRepository; +use Carbon\CarbonImmutable; use Illuminate\Support\Arr; +use Illuminate\Support\Str; use Spatie\LaravelData\DataCollection; use Webmozart\Assert\Assert; class ProxmoxStorageRepository extends ProxmoxRepository { + public function getStorage(string $name): StorageData + { + Assert::isInstanceOf($this->node, Node::class); + + $response = $this->getHttpClient() + ->withUrlParameters([ + 'node' => $this->node->cluster, + 'storage' => $name, + ]) + ->get('/api2/json/nodes/{node}/storage/{storage}/status') + ->json(); + + $response = $this->getData($response); + + $has = fn (string $content) => Str::contains($response['content'], $content); + + return new StorageData( + name : $name, + used : $response['used'], + free : $response['avail'], + total : $response['total'], + enabled: $response['enabled'], + online : $response['active'], + has_kvm: $has('images'), + has_lxc: $has('rootdir'), + has_lxc_templates: $has('templates'), + has_backups: $has('backup'), + has_iso: $has('iso'), + has_snippets: $has('snippets'), + ); + } + public function download( ContentType $contentType, - string $fileName, - string $link, + string $fileName, + string $link, ?bool $verifyCertificates = true, ?ChecksumData $checksumData = null, ) { @@ -83,11 +117,11 @@ public function getIsos(): DataCollection $isos = []; foreach ($response as $iso) { - $isos[] = IsoData::from([ - 'file_name' => explode('/', $iso['volid'])[1], - 'size' => $iso['size'], - 'created_at' => CarbonImmutable::createFromTimestamp($iso['ctime']), - ]); + $isos[] = new IsoData( + file_name : explode('/', $iso['volid'])[1], + size : $iso['size'], + created_at: CarbonImmutable::createFromTimestamp($iso['ctime']), + ); } return IsoData::collection($isos); diff --git a/database/migrations/2024_10_10_011714_create_storages_table.php b/database/migrations/2024_10_10_011714_create_storages_table.php index f9fbf91a2e9..5840326b4b8 100644 --- a/database/migrations/2024_10_10_011714_create_storages_table.php +++ b/database/migrations/2024_10_10_011714_create_storages_table.php @@ -21,7 +21,7 @@ public function up(): void $table->boolean('has_lxc'); $table->boolean('has_lxc_templates'); $table->boolean('has_backups'); - $table->boolean('has_isos'); + $table->boolean('has_iso'); $table->boolean('has_snippets'); }); } diff --git a/resources/scripts/components/interfaces/Client/Server/Rebuild/TemplateGroupCard.tsx b/resources/scripts/components/interfaces/Client/Server/Rebuild/TemplateGroupCard.tsx new file mode 100644 index 00000000000..e69de29bb2d diff --git a/resources/scripts/routes/_app/servers.$serverUuid/rebuild.lazy.tsx b/resources/scripts/routes/_app/servers.$serverUuid/rebuild.lazy.tsx new file mode 100644 index 00000000000..e259e4e180b --- /dev/null +++ b/resources/scripts/routes/_app/servers.$serverUuid/rebuild.lazy.tsx @@ -0,0 +1,17 @@ +import { createLazyFileRoute } from '@tanstack/react-router' + +import { Heading } from '@/components/ui/Typography' + +export const Route = createLazyFileRoute('/_app/servers/$serverUuid/rebuild')({ + component: RebuildServerPage, + // @ts-ignore + meta: () => [{ title: 'Rebuild' }], +}) + +function RebuildServerPage() { + return ( + <> + Rebuild Server + + ) +} diff --git a/resources/scripts/types/template.ts b/resources/scripts/types/template.ts new file mode 100644 index 00000000000..6b3eaf1d0c3 --- /dev/null +++ b/resources/scripts/types/template.ts @@ -0,0 +1,14 @@ +export interface TemplateGroup { + uuid: string + name: string + hidden: boolean + templates: Template[] + orderColumn: number +} + +export interface Template { + uuid: string + name: string + hidden: boolean + orderColumn: number +}