UpdateForm.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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\ProxmoxVps\App\UI\ServiceInformation\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
  21. use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
  22. use ModulesGarden\Servers\ProxmoxVps\App\UI\ServiceInformation\Providers\UpdateProvider;
  23. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\HostnameValidator;
  24. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\ShhPublicKeyValidator;
  25. use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\isAdmin;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\ClientArea;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\BaseForm;
  28. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Select;
  29. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Text;
  30. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Textarea;
  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. //Hostname
  50. $field = new Text("hostname");
  51. $field->addValidator(new HostnameValidator());
  52. $this->addField($field);
  53. if ($this->configuration()->isLxc())
  54. {
  55. return;
  56. }
  57. //ISO
  58. if(isAdmin() || $this->configuration()->isPermissionIsoImage() && $this->vm()->getCdRom()->count()){
  59. $field = new Select("iso");
  60. $field->notEmpty();
  61. $this->addField($field);
  62. }
  63. //boot device 1
  64. $field = new Select("bootOrder0");
  65. $field->notEmpty();
  66. $this->addField($field);
  67. //boot device 2
  68. $field = new Select("bootOrder1");
  69. $field->notEmpty();
  70. $this->addField($field);
  71. //boot device 3
  72. $field = new Select("bootOrder2");
  73. $field->notEmpty();
  74. $this->addField($field);
  75. //sshkeys for kvm only
  76. if($this->configuration()->isPermissionSshkeys()){
  77. $field = new Textarea("sshkeys");
  78. $field->addValidator(new ShhPublicKeyValidator(false));
  79. $this->addField($field);
  80. }
  81. }
  82. }