<?php

namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Forms;

use ModulesGarden\ProxmoxAddon\App\Models\VirtualNetwork;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Providers\VmCreateProvider;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections\AdditionalDiskSection;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections\Lxc;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections\Qemu;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections\TopSection;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections\VirtualNetworkSection;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\BaseStandaloneFormExtSections;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\HalfPageSection;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\RawSection;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\BaseSection;

class VmCreateForm extends BaseStandaloneFormExtSections implements ClientArea
{
    use ProductService;

    public function initContent()
    {
        $this->setFormType('create');
        $this->setProvider(new VmCreateProvider());

        $this->addSection(new TopSection());

        if ($this->configuration()->isQemu())
        {
            $this->addSection((new Qemu\GeneralSection())->setMainContainer($this->mainContainer));
        }
        if ($this->configuration()->isLxc())
        {
            $this->addSection((new Lxc\GeneralSection())->setMainContainer($this->mainContainer));
        }

        $networks = (new VirtualNetworkSection())->setMainContainer($this->mainContainer);
        $disks  = (new AdditionalDiskSection())->setMainContainer($this->mainContainer);

        $netdisk = new HalfPageSection('netdisk');
        $netdisk->setMainContainer($this->mainContainer);
        $netdisk->addSection($networks);
        $netdisk->addSection($disks);
        $this->addSection($netdisk);

        $this->loadDataToForm();
    }


}
