UpdateForm.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. if(isAdmin() || $this->configuration()->hasPermissionChangeHostname()){
  51. $field = new Text("hostname");
  52. $field->addValidator(new HostnameValidator());
  53. $this->addField($field);
  54. }
  55. if ($this->configuration()->isLxc())
  56. {
  57. return;
  58. }
  59. //ISO
  60. if(isAdmin() || $this->configuration()->isPermissionIsoImage() && $this->vm()->getCdRom()->count()){
  61. $field = new Select("iso");
  62. $field->notEmpty();
  63. $this->addField($field);
  64. }
  65. /* //boot device 1
  66. $field = new Select("bootOrder0");
  67. $field->notEmpty();
  68. $this->addField($field);
  69. //boot device 2
  70. $field = new Select("bootOrder1");
  71. $field->notEmpty();
  72. $this->addField($field);
  73. //boot device 3
  74. $field = new Select("bootOrder2");
  75. $field->notEmpty();
  76. $this->addField($field); */
  77. //sshkeys for kvm only
  78. if($this->configuration()->isPermissionSshkeys()){
  79. $field = new Textarea("sshkeys");
  80. $field->addValidator(new ShhPublicKeyValidator(false));
  81. $this->addField($field);
  82. }
  83. }
  84. }