Vm.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\App\Http\Client;
  3. use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
  4. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  5. use ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers\AppParams;
  6. use ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers\ProxmoxAddonValidator;
  7. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Graph\Pages\ServiceCpuGraph;
  8. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Graph\Pages\VmSmallGraphs;
  9. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Home\Pages\AccountSummary;
  10. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Home\Pages\AccountSummaryBars;
  11. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Home\Pages\ServiceActions;
  12. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Home\Pages\ServiceDetails;
  13. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Vm\Pages\VmTabs;
  14. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Forms\VmCreateForm;
  15. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmUpdate\Forms\VmUpdateForm;
  16. use ModulesGarden\Servers\ProxmoxCloudVps\Core\Http\AbstractClientController;
  17. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits\WhmcsParams;
  18. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
  19. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\view;
  20. class Vm extends AbstractClientController
  21. {
  22. use WhmcsParams;
  23. use ProductService;
  24. use BaseClientController;
  25. use ApiService;
  26. /**
  27. * details
  28. */
  29. public function index()
  30. {
  31. if ($this->getWhmcsParamByKey('status') != 'Active')
  32. {
  33. return;
  34. }
  35. $this->initVm();
  36. (new AppParams())->initFromWhmcsParams();
  37. $this->api();
  38. if (!ProxmoxAddonValidator::isInstalled())
  39. {
  40. ProxmoxAddonValidator::isInstalledOrFail();
  41. }
  42. else
  43. {
  44. if (!$this->isVmCreated(\ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVmModel()))
  45. {
  46. return $this->onVpsBuild();
  47. }
  48. }
  49. $view = view();
  50. $view->initCustomAssetFiles();
  51. $view->addElement(ServiceDetails::class);
  52. $view->addElement(ServiceActions::class);
  53. $view->addElement(VmTabs::class);
  54. return $view;
  55. }
  56. public function create()
  57. {
  58. sl("sidebar")->getSidebar("virtualMachinesProxmoxCloudVps")->getChild("vmcreate")->setActive(true);
  59. (new AppParams())->initFromWhmcsParams();
  60. $view = view();
  61. $view->initCustomAssetFiles();
  62. /**
  63. * @deprecated
  64. * $view->addElement(\ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections\AccountSummary::class);
  65. */
  66. return $view->addElement(VmCreateForm::class);
  67. }
  68. public function update()
  69. {
  70. // sl("sidebar")->getSidebar("virtualMachinesProxmoxCloudVps")->getChild("vmupdate")->setActive(true);
  71. $this->initVm();
  72. (new AppParams())->initFromWhmcsParams();
  73. $this->api();
  74. return view()->addElement(VmUpdateForm::class);
  75. }
  76. }