UpdateForm.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.03.19)
  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\Servers\ProxmoxCloudVps\App\UI\Disk\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  21. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ResourceManager;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Disk\Providers\DiskProvider;
  23. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Disk\Validators\DiskSizeValidator;
  24. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\NumberValidator;
  25. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
  26. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\BaseForm;
  27. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Hidden;
  28. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Switcher;
  29. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
  30. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Range;
  31. class UpdateForm extends BaseForm implements ClientArea
  32. {
  33. use ProductService;
  34. protected $minSize = 0;
  35. public function initContent()
  36. {
  37. logModuleCall(
  38. 'proxmoxCloud',
  39. __FUNCTION__,
  40. parent::getFormData()['id'],
  41. 'Debug',
  42. parent::getFormData()['size']
  43. );
  44. $this->initIds('updateDiskForm');
  45. $this->setFormType('update');
  46. $this->setProvider(new DiskProvider());
  47. $this->initFields();
  48. $this->loadDataToForm();
  49. }
  50. public function getAllowedActions()
  51. {
  52. return ['update'];
  53. }
  54. private function initFields()
  55. {
  56. //entity id
  57. $this->addField(new Hidden("id"));
  58. //size
  59. $this->resourceManager = new ResourceManager();
  60. $field = new Range('additionalDiskSize', $this->minSize, $this->resourceManager->disk()->free());
  61. $field->addValidator(new DiskSizeValidator('additionalDiskSize',true));
  62. $field->setDefaultValue($this->minSize);
  63. $this->addField($field);
  64. //backup
  65. if ($this->configuration()->isPermissionAdditionalDiskBackup())
  66. {
  67. $field = new Switcher('backup');
  68. $this->addField($field);
  69. }
  70. }
  71. }