Update source into github
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\Module\Datacenter\DatacenterRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Datacenter extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public DatacenterRepositoryInterface $datacenterRepository
|
||||
)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$vcenterId = $this->model?->vCenter?->id;
|
||||
|
||||
$datacenters = null;
|
||||
|
||||
if ($vcenterId) {
|
||||
$datacenters = $this->datacenterRepository->filter(
|
||||
['vcenter_id' => $vcenterId],
|
||||
[],
|
||||
[],
|
||||
['id', 'name']
|
||||
);
|
||||
}
|
||||
|
||||
return view('components.module.datacenter', compact('datacenters'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\Module\Host\HostRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Host extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public HostRepositoryInterface $hostRepository
|
||||
)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$hosts = null;
|
||||
if(
|
||||
$this->model &&
|
||||
(
|
||||
isset($this->model->ipaddress->host->module_datacenter_id) ||
|
||||
isset($this->model->host->module_datacenter_id)
|
||||
)
|
||||
)
|
||||
{
|
||||
$hosts = $this->hostRepository->filter(
|
||||
[
|
||||
'module_datacenter_id' => $this->model->ipaddress->host->module_datacenter_id ?? $this->model->host->module_datacenter_id
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['id', 'name']
|
||||
);
|
||||
}
|
||||
return view('components.module.host',compact('hosts'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\Module\IpAddress\IpAddressRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class IpAddress extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public IpAddressRepositoryInterface $ipAddressRepository
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$ipaddress = null;
|
||||
if ($this->model && isset($this->model->ipaddress->module_host_id)) {
|
||||
$ipaddress = $this->ipAddressRepository->filter(
|
||||
[
|
||||
'module_host_id' => $this->model->ipaddress->module_host_id
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['id', 'ip']
|
||||
);
|
||||
}
|
||||
return view('components.module.ip-address',compact('ipaddress'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\Module\Network\NetworkRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Network extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public NetworkRepositoryInterface $networkRepository
|
||||
)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$networks = null;
|
||||
if($this->model && (
|
||||
isset($this->model->ipaddress->module_host_id) ||
|
||||
isset($this->model->module_host_id)
|
||||
))
|
||||
{
|
||||
$networks = $this->networkRepository->filter(
|
||||
[
|
||||
'module_host_id' => $this->model->ipaddress->module_host_id ?? $this->model->module_host_id
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['id', 'name']
|
||||
);
|
||||
}
|
||||
return view('components.module.network',compact('networks'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\OsGroup\OsGroupRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Os extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public OsGroupRepositoryInterface $osGroupRepository
|
||||
)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$lists = null;
|
||||
if($this->model && (
|
||||
isset($this->model->ipaddress->modulVe_host_id) ||
|
||||
isset($this->model->module_host_id)
|
||||
))
|
||||
{
|
||||
$lists = $this->osGroupRepository->filter(
|
||||
[
|
||||
'module_host_id' => $this->model->ipaddress->module_host_id ?? $this->model->module_host_id
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['id', 'name']
|
||||
);
|
||||
}
|
||||
return view('components.module.os',compact('lists'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Http\Services\vCenter;
|
||||
use App\Repositories\vCenter\vCenterRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class OsServerVersion extends Component
|
||||
{
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public vCenter $vCenter,
|
||||
public vCenterRepositoryInterface $vCenterRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$versions = $this->fetchVersions();
|
||||
return view('components.module.os-server-version', compact('versions'));
|
||||
}
|
||||
|
||||
protected function fetchVersions()
|
||||
{
|
||||
$vCenter = optional($this->model?->osGroup?->host?->datacenter?->vCenter);
|
||||
|
||||
if (!$vCenter || !$vCenter->host) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->vCenter->token = $vCenter->token ?? '';
|
||||
$this->vCenter->apiUri = $vCenter->host ?? '';
|
||||
|
||||
$templateId = $this->model?->osGroup?->host?->template;
|
||||
|
||||
$versions = $this->vCenter->getAllVersion($templateId);
|
||||
|
||||
if ($versions === "Login_Again") {
|
||||
$token = $this->vCenter->loginServer($vCenter);
|
||||
if ($token) {
|
||||
$this->vCenterRepository->update($vCenter->id, ['token' => $token]);
|
||||
$this->vCenter->token = $token;
|
||||
$versions = $this->vCenter->getAllVersion($templateId);
|
||||
}
|
||||
}
|
||||
|
||||
return $versions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\Os\OsRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class OsVersion extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public OsRepositoryInterface $osRepositoryInterface,
|
||||
public $model = null,
|
||||
public $os = null
|
||||
)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$os_versions = null;
|
||||
if($this->model && isset($this->model->os_id))
|
||||
{
|
||||
// First get the current OS to find its group
|
||||
$currentOs = $this->osRepositoryInterface->find($this->model->os_id);
|
||||
if($currentOs && $currentOs->os_group_id) {
|
||||
// Then get all OS versions in the same group
|
||||
$os_versions = $this->osRepositoryInterface->filter(
|
||||
[
|
||||
'os_group_id' => $currentOs->os_group_id
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['id', 'version']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return view('components.module.os-version', [
|
||||
'os_versions' => $os_versions,
|
||||
'os' => $this->os,
|
||||
'model' => $this->model
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Module;
|
||||
|
||||
use App\Repositories\vCenter\vCenterRepositoryInterface;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class VCenter extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public $model = null,
|
||||
public vCenterRepositoryInterface $vCenterRepository,
|
||||
public $selected = null
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
$vcenters = $this->vCenterRepository->filter(
|
||||
[
|
||||
'status' => 1
|
||||
],
|
||||
[],
|
||||
[],
|
||||
['id', 'host']
|
||||
);
|
||||
|
||||
return view('components.module.v-center', compact('vcenters'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user