ClientAreaSection.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections\Qemu;
  3. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AdminArea;
  4. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Select;
  5. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Switcher;
  6. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Sections\BoxSection;
  7. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Sections\HalfPageSection;
  8. class ClientAreaSection extends BoxSection implements AdminArea
  9. {
  10. protected $id = 'clientAreaSection';
  11. protected $name = 'clientAreaSection';
  12. protected $title = 'clientAreaSection';
  13. /**
  14. * @var HalfPageSection
  15. */
  16. private $leftSection;
  17. /**
  18. * @var HalfPageSection
  19. */
  20. private $rightSection;
  21. public function initContent()
  22. {
  23. $this->leftSection = new HalfPageSection('leftSection');
  24. $this->rightSection = new HalfPageSection('rightSection');
  25. $this->addSection($this->leftSection)
  26. ->addSection($this->rightSection);
  27. $this->initFields();
  28. }
  29. private function initFields()
  30. {
  31. //Start
  32. $field = new Switcher('customconfigoption[permissionStart]');
  33. $field->setDescription('tip');
  34. $field->setDefaultValue("on");
  35. $this->leftSection->addField($field);
  36. //Reboot
  37. $field = new Switcher('customconfigoption[permissionReboot]');
  38. $field->setDescription('tip');
  39. $field->setDefaultValue("on");
  40. $this->rightSection->addField($field);
  41. //Stop
  42. $field = new Switcher('customconfigoption[permissionStop]');
  43. $field->setDescription('tip');
  44. $field->setDefaultValue("on");
  45. $this->leftSection->addField($field);
  46. //Shutdown
  47. $field = new Switcher('customconfigoption[permissionShutdown]');
  48. $field->setDescription('tip');
  49. $field->setDefaultValue("on");
  50. $this->rightSection->addField($field);
  51. //noVNC Console
  52. $field = new Switcher('customconfigoption[permissionNovnc]');
  53. $field->setDescription('tip');
  54. $field->setDefaultValue("on");
  55. $this->leftSection->addField($field);
  56. //SPICE Console
  57. $field = new Switcher('customconfigoption[permissionSpice]');
  58. $field->setDescription('tip');
  59. $field->setDefaultValue("on");
  60. $this->rightSection->addField($field);
  61. //xterm.js Console
  62. $field = new Switcher('customconfigoption[permissionXtermjs]');
  63. $field->setDescription('tip');
  64. $this->leftSection->addField($field);
  65. //Reinstallation
  66. $field = new Switcher('customconfigoption[permissionReinstall]');
  67. $field->setDescription('tip');
  68. $field->setDefaultValue("on");
  69. $this->rightSection->addField($field);
  70. //KVM Templates
  71. $field = new Switcher('customconfigoption[permissionOsTemplate]');
  72. $field->setDescription('tip');
  73. $field->setDefaultValue("on");
  74. $this->leftSection->addField($field);
  75. //OS Templates
  76. $field = new Select('customconfigoption[permissionOsTemplates][]');
  77. $field->setDescription('tip');
  78. $field->enableMultiple();
  79. $this->rightSection->addField($field);
  80. //ISO Images
  81. $field = new Switcher('customconfigoption[permissionIsoImage]');
  82. $field->setDescription('tip');
  83. $field->setDefaultValue("on");
  84. $this->rightSection->addField($field);
  85. //ISO Images
  86. $field = new Select('customconfigoption[permissionIsoImages][]');
  87. $field->setDescription('tip');
  88. $field->enableMultiple();
  89. $this->leftSection->addField($field);
  90. //MRTG Graphics
  91. $field = new Switcher('customconfigoption[permissionGraph]');
  92. $field->setDescription('tip');
  93. $field->setDefaultValue("on");
  94. $this->leftSection->addField($field);
  95. //Backup
  96. $field = new Switcher('customconfigoption[permissionBackup]');
  97. $field->setDescription('tip');
  98. $field->setDefaultValue("on");
  99. $this->rightSection->addField($field);
  100. //Scheduled Backup Jobs
  101. $field = new Switcher('customconfigoption[permissionBackupJob]');
  102. $field->setDescription('tip');
  103. $field->setDefaultValue("on");
  104. $this->leftSection->addField($field);
  105. //Task History
  106. $field = new Switcher('customconfigoption[permissionTaskHistory]');
  107. $field->setDescription('tip');
  108. $field->setDefaultValue("on");
  109. $this->rightSection->addField($field);
  110. //Network
  111. $field = new Switcher('customconfigoption[permissionNetwork]');
  112. $field->setDescription('tip');
  113. $field->setDefaultValue("on");
  114. $this->leftSection->addField($field);
  115. //Snapshots
  116. $field = new Switcher('customconfigoption[permissionSnapshot]');
  117. $field->setDescription('tip');
  118. $field->setDefaultValue("on");
  119. $this->rightSection->addField($field);
  120. //Firewall
  121. $field = new Switcher('customconfigoption[permissionFirewall]');
  122. $field->setDescription('tip');
  123. $field->setDefaultValue("on");
  124. $this->leftSection->addField($field);
  125. //Firewall Options
  126. $field = new Switcher('customconfigoption[permissionFirewallOption]');
  127. $field->setDescription('tip');
  128. $field->setDefaultValue("on");
  129. $this->rightSection->addField($field);
  130. //Disks Management
  131. $field = new Switcher('customconfigoption[permissionDisk]');
  132. $field->setDescription('tip');
  133. $field->setDefaultValue("on");
  134. $this->leftSection->addField($field);
  135. //sshkeys
  136. $field = new Switcher('customconfigoption[permissionSshkeys]');
  137. $field->setDescription('tip');
  138. $field->setDefaultValue("on");
  139. $this->rightSection->addField($field);
  140. //Snapshot Jobs
  141. $field = new Switcher('customconfigoption[permissionSnapshotJob]');
  142. $field->setDescription('tip');
  143. $field->setDefaultValue("on");
  144. $this->leftSection->addField($field);
  145. //How Often
  146. $field = new Select('customconfigoption[permissionSnapshotJobPeriod][]');
  147. $field->setDescription('tip');
  148. $field->enableMultiple();
  149. $this->rightSection->addField($field);
  150. //permissionfirewalOptions
  151. $field = new Select("customconfigoption[permissionFirewalOptions][]");
  152. $field->enableMultiple();
  153. $field->setDescription('description');
  154. $this->addField($field);
  155. }
  156. public function addField($field){
  157. $total = count($this->leftSection->getFields()) + count($this->rightSection->getFields());
  158. if($total % 2 == 0){
  159. $this->leftSection->addField($field);
  160. }else{
  161. $this->rightSection->addField($field);
  162. }
  163. return $this;
  164. }
  165. }