<?php

namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Admin\Product\Sections;

use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Select;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Switcher;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\BoxSection;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\HalfPageSection;

class LoadBalancerSection extends BoxSection implements AdminArea
{
    protected $id = 'loadBalancerSection';
    protected $name = 'loadBalancerSection';
    protected $title = 'loadBalancerSection';
    /**
     * @var HalfPageSection
     */
    private $leftSection;
    /**
     * @var HalfPageSection
     */
    private $rightSection;

    public function initContent()
    {
        $this->leftSection  = new HalfPageSection('leftSection');
        $this->rightSection = new HalfPageSection('rightSection');

        $this->addSection($this->leftSection)
            ->addSection($this->rightSection);
        $this->initFields();
    }

    private function initFields()
    {
        //Enable
        $field = new Switcher('customconfigoption[loadBalancer]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //On Upgrade
        $field = new Select('customconfigoption[loadBalancerOnUpgrade]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Shutdown VM on Upgrade
        $field = new Switcher('customconfigoption[loadBalancerShutdownOnUpgrade]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Stop VM If Shutdown Fails
        $field = new Switcher('customconfigoption[loadBalancerStopOnUpgrade]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
    }

}
