IsoTrait.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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\ProxmoxVps\App\UI\Reinstall\Pages;
  20. use ModulesGarden\Servers\ProxmoxVps\App\UI\Reinstall\Buttons\IsoInstallButton;
  21. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\DataTable\Column;
  22. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\DataTable\DataProviders\Providers\ArrayDataProvider;
  23. use function ModulesGarden\Servers\ProxmoxVps\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. //Install
  30. $this->addActionButton(new IsoInstallButton());
  31. }
  32. protected function loadHtml()
  33. {
  34. $this->addColumn((new Column('name'))->setSearchable(true, "string")->setOrderable('ASC'));
  35. }
  36. public function replaceFieldName($key, $row)
  37. {
  38. return sl("lang")->abtr("template", $row[$key]);
  39. }
  40. protected function loadData()
  41. {
  42. $data = [];
  43. foreach ($this->isoRepository()->fetch() as $entity)
  44. {
  45. if ($this->configuration()->isPermissionIsoImages() && !in_array($entity->getVolid(), $this->configuration()->getPermissionIsoImages()))
  46. {
  47. continue;
  48. }
  49. $data[] = [
  50. "id" => $entity->getVolid(),
  51. "name" => $entity->getFriendlyName(),
  52. ];
  53. }
  54. $dataProv = new ArrayDataProvider();
  55. $dataProv->setDefaultSorting("name", 'ASC');
  56. $dataProv->setData($data);
  57. $this->setDataProvider($dataProv);
  58. }
  59. }