IsoTrait.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.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\ProxmoxCloudVps\App\UI\Reinstall\Pages;
  20. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Reinstall\Buttons\IsoInstallButton;
  21. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\Column;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\DataProviders\Providers\ArrayDataProvider;
  23. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
  24. trait IsoTrait
  25. {
  26. public function initContent()
  27. {
  28. $this->setInternalAlertMessage("Select the template for reinstallation. If you proceed, all data located on the virtual machine will be lost.");
  29. $this->unsetShowTitle();
  30. //Install
  31. $this->addActionButton(new IsoInstallButton());
  32. }
  33. protected function loadHtml()
  34. {
  35. $this->addColumn((new Column('name'))->setSearchable(true, "string")->setOrderable('ASC'));
  36. }
  37. public function replaceFieldName($key, $row)
  38. {
  39. return sl("lang")->abtr("template", $row[$key]);
  40. }
  41. protected function loadData()
  42. {
  43. $data = [];
  44. foreach ($this->isoRepository()->fetch() as $entity)
  45. {
  46. if ($this->configuration()->isPermissionIsoImages() && !in_array($entity->getVolid(), $this->configuration()->getPermissionIsoImages()))
  47. {
  48. continue;
  49. }
  50. $data[] = [
  51. "id" => $entity->getVolid(),
  52. "name" => $entity->getFriendlyName(),
  53. ];
  54. }
  55. $dataProv = new ArrayDataProvider();
  56. $dataProv->setDefaultSorting("name", 'ASC');
  57. $dataProv->setData($data);
  58. $this->setDataProvider($dataProv);
  59. }
  60. }