| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- /**********************************************************************
- * ProxmoxVPS developed. (26.03.19)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- **********************************************************************/
- namespace ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Forms;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Buttons\VirtualizationChangButton;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Providers\ProductProvider;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\AdminNotificationSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\BackupSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\ClientNotificationSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\ConsoleSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\FirewallOptionSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\FirewallSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\HighAvailabilityClusterSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\LoadBalancerSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\Lxc;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\MainSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\MiscellaneousSection;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\Qemu;
- use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\UserSection;
- use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\Servers\ProxmoxVps\Core\UI\MainContainer;
- use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Switcher;
- use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\FormIntegration;
- class MainForm extends FormIntegration implements AdminArea
- {
- public function initContent()
- {
- /**
- *
- */
- $this->initIds('mainForm');
- $this->setProvider(new ProductProvider($this->getRequestValue('id')));
- $this->addSection(new VirtualizationChangButton());
- $this->dataProvider->initData();
- /**
- *
- */
- $isQemu = !$this->dataProvider->getValueById('customconfigoption[virtualization]') || $this->dataProvider->getValueById('customconfigoption[virtualization]') == "qemu";
- /**
- * Main Section
- */
- $section = new MainSection();
- $section->setMainContainer($this->mainContainer);
- $this->addSection($section);
- if ($isQemu)
- {
- // KVM
- $this->addSection((new Qemu\ContainerSection())->enableToggler())
- ->addSection((new Qemu\NetworkSection())->enableToggler())
- ->addSection((new Qemu\DiskSection())->enableToggler())
- ->addSection((new Qemu\DiskSpeedSection())->enableTogglerAndHide())
- ->addSection((new Qemu\AdditonalDisk())->enableToggler())
- ->addSection((new Qemu\AdditonalDiskSpeedSection())->enableToggler())
- ->addSection((new BackupSection())->enableToggler())
- ->addSection((new Qemu\BootSection())->enableTogglerAndHide())
- ->addSection((new FirewallSection())->enableTogglerAndHide())
- ->addSection((new FirewallOptionSection())->enableTogglerAndHide())
- ->addSection((new Qemu\CloudInitSection())->enableTogglerAndHide())
- ->addSection((new Qemu\GuestAgentSection())->enableTogglerAndHide())
- ->addSection((new UserSection())->enableTogglerAndHide())
- ->addSection((new MiscellaneousSection())->enableTogglerAndHide())
- ->addSection((new LoadBalancerSection())->enableTogglerAndHide())
- ->addSection((new Qemu\ConfigurationSection())->enableTogglerAndHide())
- ->addSection((new Qemu\AdvancedSection())->enableTogglerAndHide())
- ->addSection((new HighAvailabilityClusterSection())->enableTogglerAndHide())
- ->addSection((new ConsoleSection())->enableTogglerAndHide())
- ->addSection((new AdminNotificationSection())->enableTogglerAndHide())
- ->addSection((new ClientNotificationSection())->enableTogglerAndHide())
- ->addSection((new Qemu\ClientAreaSection())->enableToggler())
- ->addSection((new Qemu\ConfigurableOptionUnitsSection())->enableToggler());
- }
- else
- {
- //LXC
- $this->addSection((new Lxc\ContainerSection())->enableToggler())
- ->addSection((new Lxc\MountPointSection())->enableToggler())
- ->addSection((new BackupSection())->enableToggler())
- ->addSection((new Lxc\NetworkSection())->enableToggler())
- ->addSection((new FirewallSection())->enableTogglerAndHide())
- ->addSection((new UserSection())->enableTogglerAndHide())
- ->addSection((new MiscellaneousSection())->enableTogglerAndHide())
- ->addSection((new LoadBalancerSection())->enableTogglerAndHide())
- ->addSection((new Lxc\ConfigurationSection())->enableTogglerAndHide())
- ->addSection((new HighAvailabilityClusterSection())->enableTogglerAndHide())
- ->addSection((new ConsoleSection())->enableTogglerAndHide())
- ->addSection((new AdminNotificationSection())->enableTogglerAndHide())
- ->addSection((new ClientNotificationSection())->enableTogglerAndHide())
- ->addSection((new Lxc\ClientAreaSection())->enableToggler())
- ->addSection((new Lxc\ConfigurableOptionUnitsSection())->enableToggler());
- }
- $this->loadDataToForm();
- }
- public function getSwitcherFields()
- {
- $this->setMainContainer(new MainContainer());
- $this->runInitContentProcess();
- $fieldNames = [];
- foreach ($this->getSections() as $section)
- {
- foreach ((array)$section->getSections() as $s)
- {
- foreach ($s->getFields() as $field)
- {
- if (!$field instanceof Switcher)
- {
- continue;
- }
- $name = str_replace(["customconfigoption[", "]"], ["", ""], $field->getName());
- $fieldNames[] = $name;
- }
- }
- }
- return array_unique($fieldNames);
- }
- }
|