| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?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\Admin\User\Pages;
- use MGProvision\Proxmox\v2\models\User;
- use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\UserService;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\Column;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\DataProviders\Providers\ArrayDataProvider;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\DataTable\DataTable;
- use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
- class UserDataTable extends DataTable implements AdminArea
- {
- use ProductService;
- use UserService;
- use ApiService;
- protected $id = 'userDataTable';
- protected $title = 'userDataTable';
- protected $searchable = false;
- protected $tableLength = "100";
- protected function loadHtml()
- {
- $this->addColumn((new Column('username')))
- ->addColumn((new Column('realm')))
- ->addColumn((new Column('password')))
- ->addColumn((new Column('enable')))
- ->addColumn((new Column('expire')))
- ->addColumn((new Column('name')))
- ->addColumn((new Column('comment')));
- }
- public function replaceFieldExpire($key, $row)
- {
- if ($row[$key] == 0)
- {
- return sl("lang")->tr("Never");
- }
- return $row[$key];
- }
- public function replaceFieldEnable($key, $row)
- {
- if ($row[$key])
- {
- return '<span class="lu-label lu-label--success lu-label--status">' . sl('lang')->tr("Yes") . '</span>';
- }
- return '<span class="lu-label lu-label--danger lu-label--status">' . sl('lang')->tr("No") . '</span>';
- }
- protected function loadData()
- {
- $data = [];
- if ($this->isUser())
- {
- $user = $this->getUser();
- $userService = new User("{$user->username}@{$user->realm}");
- $userService->setApi($this->api());
- $configuration = $userService->configuration();
- $data[] = [
- 'username' => $user->username,
- 'password' => $user->getPassword(),
- 'realm' => $user->realm,
- 'enable' => $configuration['enable'],
- 'expire' => $configuration['expire'],
- 'name' => $configuration['firstname'] . " " . $configuration['lastname'],
- 'comment' => $configuration['comment'],
- ];
- }
- $dataProv = new ArrayDataProvider();
- $dataProv->setData($data);
- $this->setDataProvider($dataProv);
- }
- public function initContent()
- {
- }
- public function isViewFooter()
- {
- return false;
- }
- public function isViewTopBody()
- {
- return false;
- }
- }
|