DetailForm.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /* * ********************************************************************
  3. * Proxmox Product developed. (Dec 11, 2017)
  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\ProxmoxAddon\App\UI\RecoveryVms\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Models\RecoveryVm;
  21. use ModulesGarden\ProxmoxAddon\App\UI\RecoveryVms\Sections\TabContent;
  22. use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
  23. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\BaseTabsForm;
  24. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\FormConstants;
  25. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Sections\TabSection;
  26. use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
  27. class DetailForm extends BaseTabsForm implements AdminArea
  28. {
  29. private $recoveryVm;
  30. public function initContent()
  31. {
  32. $this->initIds('detailForm');
  33. $this->setFormType(FormConstants::READ);
  34. if (!$this->getRequestValue('actionElementId'))
  35. {
  36. return;
  37. }
  38. $this->recoveryVm = RecoveryVm::findOrFail($this->getRequestValue('actionElementId'));
  39. $this->tabConfig();
  40. $this->tabStatus();
  41. $this->tabDns();
  42. }
  43. private function tabConfig()
  44. {
  45. $section = new TabSection();
  46. $section->initIds(__FUNCTION__);
  47. $section->enableGroupBySectionName();
  48. $section->setMainContainer($this->mainContainer);
  49. $section->setName(sl('lang')->T(__FUNCTION__));
  50. $this->addSection($section);
  51. $content = new TabContent();
  52. $section->addSection($content);
  53. $vars = $this->recoveryVm->getConfig();
  54. foreach ($vars as $k => $v)
  55. {
  56. if (is_array($v))
  57. {
  58. unset($vars[$k]);
  59. }
  60. }
  61. $content->setCustomTplVars($vars);
  62. }
  63. private function tabStatus()
  64. {
  65. $section = new TabSection();
  66. $section->initIds(__FUNCTION__);
  67. $section->enableGroupBySectionName();
  68. $section->setMainContainer($this->mainContainer);
  69. $section->setName(sl('lang')->T(__FUNCTION__));
  70. $this->addSection($section);
  71. $content = new TabContent();
  72. $section->addSection($content);
  73. $vars = $this->recoveryVm->getStatus();
  74. unset($vars['pid']);
  75. unset($vars['template']);
  76. foreach ($vars as $k => $v)
  77. {
  78. if (is_array($v))
  79. {
  80. unset($vars[$k]);
  81. }
  82. }
  83. $content->setCustomTplVars($vars);
  84. }
  85. private function tabDns()
  86. {
  87. $section = new TabSection();
  88. $section->initIds(__FUNCTION__);
  89. $section->enableGroupBySectionName();
  90. $section->setMainContainer($this->mainContainer);
  91. $section->setName(sl('lang')->T(__FUNCTION__));
  92. $this->addSection($section);
  93. $content = new TabContent();
  94. $section->addSection($content);
  95. $vars = $this->recoveryVm->getDns();
  96. foreach ($vars as $k => $v)
  97. {
  98. if (is_array($v))
  99. {
  100. unset($vars[$k]);
  101. }
  102. }
  103. $content->setCustomTplVars($vars);
  104. }
  105. }