UpdateForm.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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\ServiceInformation\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
  21. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\ServiceInformation\Providers\UpdateProvider;
  23. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\HostnameValidator;
  24. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\SshPublicKeyValidator;
  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\Select;
  28. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
  29. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Textarea;
  30. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\isAdmin;
  31. class UpdateForm extends BaseForm implements ClientArea
  32. {
  33. use ProductService;
  34. use ApiService;
  35. public function initContent()
  36. {
  37. $this->initIds('updateForm');
  38. $this->setFormType('update');
  39. $this->setProvider(new UpdateProvider());
  40. $this->initFields();
  41. $this->loadDataToForm();
  42. }
  43. public function getAllowedActions()
  44. {
  45. return ['update'];
  46. }
  47. private function initFields()
  48. {
  49. $vm = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVm();
  50. //Hostname
  51. $field = new Text("hostname");
  52. $field->addValidator(new HostnameValidator());
  53. $this->addField($field);
  54. if ($this->configuration()->isLxc())
  55. {
  56. return;
  57. }
  58. //ISO
  59. if(isAdmin() || $this->configuration()->isPermissionIsoImage() && $vm->getCdRom()->count()){
  60. $field = new Select("iso");
  61. $field->notEmpty();
  62. $this->addField($field);
  63. }
  64. //boot device 1
  65. $field = new Select("bootOrder0");
  66. $field->notEmpty();
  67. $this->addField($field);
  68. //boot device 2
  69. $field = new Select("bootOrder1");
  70. $field->notEmpty();
  71. $this->addField($field);
  72. //boot device 3
  73. $field = new Select("bootOrder2");
  74. $field->notEmpty();
  75. $this->addField($field);
  76. //sshkeys for kvm only
  77. if($this->configuration()->isPermissionSshkeys()){
  78. $field = new Textarea("sshkeys");
  79. $field->addValidator(new SshPublicKeyValidator(false));
  80. $this->addField($field);
  81. }
  82. }
  83. }