| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?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\CustomTemplate\Pages;
- use MGProvision\Proxmox\v2\VmFactory;
- use ModulesGarden\ProxmoxAddon\App\Models\VmModel;
- use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\CustomTemplate\Buttons\CreateButton;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\CustomTemplate\Buttons\DeleteButton;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\CustomTemplate\Buttons\ImportButton;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\CustomTemplate\Buttons\UpdateButton;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Buttons\ButtonRedirect;
- 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;
- use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
- class CustomTemplateDataTable extends DataTable implements ClientArea
- {
- use ApiService;
- use ProductService;
- protected $id = 'customTemplateDataTable';
- protected $name = 'customTemplateDataTable';
- protected $title = 'customTemplateDataTable';
- protected $searchable = false;
- protected $tableLength = "100";
- public function initContent()
- {
- $this->addClass('lu-text-left');
- //Create
- $this->addButton(new CreateButton());
- //Update
- $this->addActionButton(new UpdateButton());
- //Delete
- $this->addActionButton(new DeleteButton());
- }
- protected function loadHtml()
- {
- $this->addColumn((new Column('name')))
- ->addColumn((new Column('description')));
- }
- public function replaceFieldDescription($key, $row)
- {
- $vmModel = VmModel::ofId($row->id)->firstOrFail();
- $this->api();
- $vm = (new VmFactory())->fromVmModel($vmModel);
- if($vm->config()['description']){
- return $vm->config()['description'];
- }
- return '-';
- }
- protected function loadData()
- {
- $query = VmModel::select("id", "name", "vcpus", "memory", "disk","disks", "vmid","data")
- ->ofHostingId($this->getWhmcsParamByKey('serviceid'))
- ->ofTemplate()
- ->getQuery();
- $dataProv = new QueryDataProvider();
- $dataProv->setDefaultSorting("name", 'ASC');
- $dataProv->setData($query);
- $this->setDataProvider($dataProv);
- }
- }
|