| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS Product developed. (26.03.19)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\IpAddress\Pages;
- use ModulesGarden\ProxmoxAddon\App\Models\VmIpAddress;
- use ModulesGarden\ProxmoxAddon\App\Models\VmModel;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\IpAddress\Buttons\CreateButton;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\IpAddress\Buttons\DeleteButton;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\Column;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\DataProviders\Providers\QueryDataProvider;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\DataTable;
- use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\isAdmin;
- class IpAddressDataTable extends DataTable implements ClientArea, AdminArea
- {
- protected $id = 'ipAddressDataTable';
- protected $name = 'ipAddressDataTable';
- protected $title = 'ipAddressDataTable';
- public function initContent()
- {
- $this->addClass('lu-text-left')
- ->addClass('lu-col-md-12');
- if (isAdmin())
- {
- $this->addButton(new CreateButton());
- $this->addActionButton(new DeleteButton());
- }
- else
- {
- $this->unsetShowTitle();
- }
- }
- protected function loadHtml()
- {
- if (isAdmin())
- {
- $this->addColumn((new Column('vmid')));
- }
- $this->addColumn((new Column('ip')))
- ->addColumn((new Column('mac_address')))
- ->addColumn((new Column('subnet_mask')))
- ->addColumn((new Column('gateway')));
- }
- public function replaceFieldMac_address($key, $row)
- {
- return $row->{$key} ? $row->{$key} : '-';
- }
- public function replaceFieldSubnet_mask($key, $row)
- {
- return $row->{$key} ? $row->{$key} : '-';
- }
- public function replaceFieldGateway($key, $row)
- {
- return $row->{$key} ? $row->{$key} : '-';
- }
- public function replaceFieldVmid($key, $row)
- {
- return $row->{$key} ? $row->{$key} : '-';
- }
- protected function loadData()
- {
- $vm = (new VmModel())->getTable();
- $i = (new VmIpAddress)->getTable();
- $query = VmIpAddress::select("{$vm}.vmid", "{$i}.id", "{$i}.ip", "{$i}.mac_address", "{$i}.subnet_mask", "{$i}.gateway")
- ->leftJoin($vm,"{$vm}.id", "=", "{$i}.vm_id")
- ->where("{$i}.hosting_id", $this->getWhmcsParamByKey('serviceid'));
- $query = $query->getQuery();
- $dataProv = new QueryDataProvider();
- $dataProv->setDefaultSorting("ip", 'ASC');
- $dataProv->setData($query);
- $this->setDataProvider($dataProv);
- }
- public function isViewFooter()
- {
- return false;
- }
- public function isViewTopBody()
- {
- return false;
- }
- }
|