<?php

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

use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmUpdate\Providers\VmUpdateProvider;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmUpdate\Sections\Qemu\AdditionalDiskSection;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmUpdate\Sections\Lxc;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmUpdate\Sections\Qemu;
use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmUpdate\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\Sections\HalfPageSection;

class VmUpdateForm extends  BaseStandaloneFormExtSections implements ClientArea
{
    use ProductService;

    public function initContent()
    {
        $this->unsetShowTitle();
        $this->title = null;
        $this->addClass("lu-col-md-12");

        $this->setFormType('update');
        $this->setProvider(new VmUpdateProvider());
        //standard
        if($this->configuration()->isQemu() && !$this->configuration()->isDetailsCombinedView()){
            $this->addSection((new Qemu\GeneralSection())->setMainContainer($this->mainContainer));
        }
        if($this->configuration()->isLxc() && !$this->configuration()->isDetailsCombinedView()){
            $this->addSection((new Lxc\GeneralSection())->setMainContainer($this->mainContainer));
        }
        //combined
        if($this->configuration()->isDetailsCombinedView()){
            //rightSection
            $rightSection = new HalfPageSection('rightSection');
            $rightSection->setMainContainer($this->mainContainer);
            //network
            $rightSection->addSection((new VirtualNetworkSection())->setMainContainer($this->mainContainer));
            //kvm
            if($this->configuration()->isQemu()){
                $this->addSection((new Qemu\GeneralCombinedSection())->setMainContainer($this->mainContainer));
                //disk
                $rightSection->addSection((new Qemu\AdditionalDiskSection())->setMainContainer($this->mainContainer));
            }
            //lxc
            if($this->configuration()->isLxc()){
                $this->addSection((new Lxc\GeneralCombinedSection())->setMainContainer($this->mainContainer));
                //disk
                $rightSection->addSection((new Lxc\AdditionalDiskSection())->setMainContainer($this->mainContainer));
            }
            $this->addSection($rightSection);



        }
        $this->loadDataToForm();
    }


}
