IpAddressDataTable.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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\IpAddress\Pages;
  20. use ModulesGarden\ProxmoxAddon\App\Models\VmIpAddress;
  21. use ModulesGarden\Servers\ProxmoxVps\App\UI\IpAddress\Buttons\CreateButton;
  22. use ModulesGarden\Servers\ProxmoxVps\App\UI\IpAddress\Buttons\DeleteButton;
  23. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AdminArea;
  24. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\ClientArea;
  25. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\DataTable\Column;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\DataTable\DataProviders\Providers\QueryDataProvider;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\DataTable\DataTable;
  28. use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\isAdmin;
  29. class IpAddressDataTable extends DataTable implements ClientArea, AdminArea
  30. {
  31. protected $id = 'ipAddressDataTable';
  32. protected $title = 'ipAddressDataTable';
  33. protected $searchable = false;
  34. protected $tableLength = "100";
  35. public function initContent()
  36. {
  37. $this->addClass('lu-text-left');
  38. if (isAdmin())
  39. {
  40. $this->addButton(new CreateButton());
  41. $this->addActionButton(new DeleteButton());
  42. }
  43. }
  44. protected function loadHtml()
  45. {
  46. $this->addColumn((new Column('ip')))
  47. ->addColumn((new Column('mac_address')))
  48. ->addColumn((new Column('subnet_mask')))
  49. ->addColumn((new Column('gateway')));
  50. }
  51. public function replaceFieldMac_address($key, $row)
  52. {
  53. return $row->{$key} ? $row->{$key} : '-';
  54. }
  55. public function replaceFieldSubnet_mask($key, $row)
  56. {
  57. return $row->{$key} ? $row->{$key} : '-';
  58. }
  59. public function replaceFieldGateway($key, $row)
  60. {
  61. return $row->{$key} ? $row->{$key} : '-';
  62. }
  63. protected function loadData()
  64. {
  65. $query = VmIpAddress::select("id", "ip", "mac_address", "subnet_mask", "gateway")
  66. ->ofHostingId($this->getWhmcsParamByKey('serviceid'))
  67. ->getQuery();
  68. $dataProv = new QueryDataProvider();
  69. $dataProv->setDefaultSorting("ip", 'ASC');
  70. $dataProv->setData($query);
  71. $this->setDataProvider($dataProv);
  72. }
  73. public function isViewFooter()
  74. {
  75. return false;
  76. }
  77. public function isViewTopBody()
  78. {
  79. return isAdmin();
  80. }
  81. }