MigrateForm.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Vms\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  21. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Vms\Providers\MigrateProvider;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Helpers\AlertTypesConstants;
  23. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
  24. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\BaseForm;
  25. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Hidden;
  26. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Select;
  27. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Switcher;
  28. class MigrateForm extends BaseForm implements AdminArea
  29. {
  30. use ProductService;
  31. public function initContent()
  32. {
  33. $this->initIds('migrateForm');
  34. $this->setFormType('update');
  35. $this->setProvider(new MigrateProvider());
  36. $this->setInternalAlertMessage('confirmMigrate');
  37. $this->setInternalAlertMessageType(AlertTypesConstants::DANGER);
  38. $this->initFields();
  39. $this->loadDataToForm();
  40. }
  41. public function getAllowedActions()
  42. {
  43. return ['update'];
  44. }
  45. private function initFields()
  46. {
  47. //id
  48. $this->addField(new Hidden('vmId'));
  49. //target
  50. $field = new Select('target');
  51. $field->notEmpty();
  52. $this->addField($field);
  53. //online
  54. $this->addField((new Switcher('online'))->setDescription('tip'));
  55. //with-local-disks kvm only
  56. if($this->configuration()->isQemu()){
  57. $this->addField((new Switcher('with-local-disks'))->setDescription('tip')->setDefaultValue('on'));
  58. }
  59. }
  60. }