ServiceManagement.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (26.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\Home\Pages;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
  21. use ModulesGarden\ProxmoxAddon\App\Services\Vps\UrlService;
  22. use ModulesGarden\Servers\ProxmoxVps\App\UI\Home\Buttons\RedirectButton;
  23. use ModulesGarden\Servers\ProxmoxVps\Core\Helper\BuildUrl;
  24. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Builder\BaseContainer;
  25. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AdminArea;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\ClientArea;
  27. use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\isAdmin;
  28. class ServiceManagement extends BaseContainer implements ClientArea, AdminArea
  29. {
  30. use ProductService;
  31. /**
  32. * @var UrlService
  33. */
  34. private $urlService;
  35. public function initContent()
  36. {
  37. $this->initIds('serviceManagement');
  38. //Url Service
  39. $this->urlService = new UrlService();
  40. //Reinstall
  41. if (isAdmin() || $this->configuration()->isPermissionReinstall())
  42. {
  43. $this->addServiceButton('reinstall');
  44. }
  45. //Backups
  46. if (isAdmin() || $this->configuration()->isPermissionBackup() || $this->configuration()->isPermissionBackupJob())
  47. {
  48. $this->addServiceButton('backup');
  49. }
  50. //Backup Jobs
  51. if (isAdmin() || $this->configuration()->isPermissionBackupJob())
  52. {
  53. $this->addServiceButton('backupJob');
  54. }
  55. //Graphs
  56. if (isAdmin() || $this->configuration()->isPermissionGraph())
  57. {
  58. $this->addServiceButton('graph');
  59. }
  60. //Task History
  61. if (isAdmin() || $this->configuration()->isPermissionTaskHistory())
  62. {
  63. $this->addServiceButton('taskHistory');
  64. }
  65. //Network
  66. if (isAdmin() || $this->configuration()->isPermissionNetwork())
  67. {
  68. $this->addServiceButton('network');
  69. }
  70. //Snapshots
  71. if (isAdmin() || $this->configuration()->isPermissionSnapshot())
  72. {
  73. $this->addServiceButton('snapshot');
  74. }
  75. //Firewall
  76. if (isAdmin() || $this->configuration()->isPermissionFirewall())
  77. {
  78. $this->addServiceButton('firewall');
  79. }
  80. //Firewall Options
  81. if (isAdmin() || $this->configuration()->isPermissionFirewallOption())
  82. {
  83. $this->addServiceButton('firewallOption');
  84. }
  85. //Disks
  86. if (isAdmin() || $this->configuration()->isPermissionDisk())
  87. {
  88. $this->addServiceButton('disk');
  89. }
  90. }
  91. private function addServiceButton($id)
  92. {
  93. $rd = new RedirectButton($id);
  94. $rd->setHref($this->urlService->getUrl($id));
  95. $rd->setImageUrl(BuildUrl::getAppAssetsURL() . DS . 'img' . DS . 'buttons' . DS . $id . '.png');
  96. $this->addButton($rd);
  97. }
  98. }