UpdateForm.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /* * ********************************************************************
  3. * Wordpress_Manager Product developed. (Dec 11, 2017)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Forms;
  20. use ModulesGarden\ProxmoxAddon as main;
  21. use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Fields\NodeSelect;
  22. use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Providers\IpAddressProvider;
  23. use ModulesGarden\ProxmoxAddon\App\UI\Validators\NumberValidator;
  24. use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
  25. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\BaseForm;
  26. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Fields;
  27. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Sections\HalfPageSection;
  28. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Sections\RawSection;
  29. /**
  30. * Description of CreateForm
  31. *
  32. * @author Pawel Kopec <pawelk@modulesgarden.com>
  33. */
  34. class UpdateForm extends BaseForm implements AdminArea
  35. {
  36. public function initContent()
  37. {
  38. $this->initIds('ipManagementUpdateForm');
  39. $this->setFormType('update');
  40. $this->addClass('lu-row');
  41. $this->setProvider(new IpAddressProvider);
  42. $this->initFields();
  43. $this->loadDataToForm();
  44. }
  45. protected function initFields()
  46. {
  47. $mainSection = new RawSection('mainSection');
  48. $mainSection->setMainContainer($this->mainContainer);
  49. $leftSection = new HalfPageSection('leftSection');
  50. $leftSection->setMainContainer($this->mainContainer);
  51. $rightSection = new HalfPageSection('rightSection');
  52. $rightSection->setMainContainer($this->mainContainer);
  53. //id
  54. $field = new Fields\Hidden('id');
  55. $mainSection->addField($field);
  56. //IP Address
  57. $field = new Fields\Text('ip');
  58. $field->addValidator(new main\App\UI\Validators\IpAddressValidator(true));
  59. $field->setPlaceholder('192.168.0.100');
  60. $mainSection->addField($field);
  61. //MAC Address
  62. $field = new Fields\Text('mac_address');
  63. $field->addValidator(new main\App\UI\Validators\MacAddressValidator());
  64. $field->setPlaceholder('E6:AA:5C:8B:DF:12');
  65. $mainSection->addField($field);
  66. //VLAN Trunks
  67. $field = new Fields\Text('trunks');
  68. $field->addValidator(new NumberValidator());
  69. $leftSection->addField($field);
  70. //Tag
  71. $field = new Fields\Text('tag');
  72. $field->addValidator(new NumberValidator(1, 4094));
  73. $rightSection->addField($field);
  74. //Subnet Mask
  75. $field = new Fields\Text('subnet_mask');
  76. $field->addValidator(new main\App\UI\Validators\IpAddressValidator(false));
  77. $field->setPlaceholder('255.255.255.0');
  78. $mainSection->addField($field);
  79. //Gateway
  80. $field = new Fields\Text('gateway');
  81. $field->addValidator(new main\App\UI\Validators\IpAddressValidator(false, false));
  82. $field->setPlaceholder('192.168.0.1');
  83. $mainSection->addField($field);
  84. //CIDR
  85. $field = new Fields\Text('cidr');
  86. $field->addValidator(new main\App\UI\Validators\CidrValidator(true));
  87. $field->setPlaceholder('24');
  88. $mainSection->addField($field);
  89. //Server
  90. $field = new Fields\Select('sid');
  91. $values = ["0" => main\Core\ServiceLocator::call('lang')->absoluteT('Any')];
  92. $values += (array)main\Core\Models\Whmcs\Server::whereIn("type", ["proxmoxVPS", "ProxmoxCloudVps"])->pluck("name", "id")->toArray();
  93. $field->setAvailableValues($values);
  94. $leftSection->addField($field);
  95. //Node
  96. $field = new NodeSelect('node');
  97. $field->addReloadOnChangeField('sid');
  98. $field->setMainContainer($this->mainContainer);
  99. $rightSection->addField($field);
  100. //Virtualization
  101. $field = new Fields\Select('visualization');
  102. $field->setAvailableValues(["Auto" => main\Core\ServiceLocator::call('lang')->absoluteT('Auto'), "KVM" => "KVM", "LXC" => "LXC"]);
  103. $mainSection->addField($field);
  104. //Private Address
  105. $field = new Fields\Switcher('private');
  106. $mainSection->addField($field);
  107. $this->addSection($mainSection);
  108. $this->addSection($leftSection);
  109. $this->addSection($rightSection);
  110. }
  111. protected function getDefaultActions()
  112. {
  113. return ['update'];
  114. }
  115. }