Home.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Aug 14, 2018)
  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\Http\Admin;
  20. use ModulesGarden\ProxmoxAddon\App\Services\RecoveryVmDumpService;
  21. use ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages\Subscription;
  22. use ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages\Summary;
  23. use ModulesGarden\ProxmoxAddon\Core\Helper;
  24. use ModulesGarden\ProxmoxAddon\Core\Http\AbstractController;
  25. use Symfony\Component\HttpFoundation\StreamedResponse;
  26. /**
  27. * Example admin home page controler
  28. */
  29. class Home extends AbstractController
  30. {
  31. /**
  32. * Example of static page
  33. * @return type
  34. */
  35. public function index()
  36. {
  37. return Helper\redirect('home', 'servers');
  38. }
  39. public function servers()
  40. {
  41. return Helper\view()->addElement(\ModulesGarden\ProxmoxAddon\App\UI\Servers\Pages\ServersDataTable::class);
  42. }
  43. public function vms()
  44. {
  45. return Helper\view()->addElement(\ModulesGarden\ProxmoxAddon\App\UI\Vms\Pages\VmsDataTable::class);
  46. }
  47. public function recoveryVms()
  48. {
  49. return Helper\view()->addElement(\ModulesGarden\ProxmoxAddon\App\UI\RecoveryVms\Pages\RecoveryVmsDataTable::class);
  50. }
  51. public function recoveryToFile()
  52. {
  53. $response = new StreamedResponse();
  54. $response->setStatusCode(200);
  55. $response->headers->set('Content-Type', 'application/x-pem-file; charset=utf-8');
  56. $response->setCallback(function ()
  57. {
  58. echo (new RecoveryVmDumpService())->generate();
  59. });
  60. $response->headers->set(
  61. 'Content-Disposition', 'attachment; filename="recover_vm_list_' . date("Y-m-d H:i:s") . '.txt"'
  62. );
  63. $response->send();
  64. }
  65. public function taskHistory()
  66. {
  67. return Helper\view()->addElement(\ModulesGarden\ProxmoxAddon\App\UI\TaskHistory\Pages\TaskHistoryDataTable::class);
  68. }
  69. public function serverDetail()
  70. {
  71. return Helper\view()->addElement(\ModulesGarden\ProxmoxAddon\App\UI\ServerDetail\Pages\ServerDetailContainer::class);
  72. }
  73. public function nodeDetail()
  74. {
  75. return Helper\view()->setCustomJsCode()
  76. ->addElement(Summary::class)
  77. ->addElement(Subscription::class)
  78. ->addElement(\ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages\CpuGraph::class)
  79. ->addElement(\ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages\ServerLoadGraph::class)
  80. ->addElement(\ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages\MemoryGraph::class)
  81. ->addElement(\ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages\NetworkGraph::class);
  82. }
  83. }