lasthourcloud/app/Livewire/Project/Resource/Index.php

176 lines
7.2 KiB
PHP
Raw Normal View History

2024-01-07 15:23:41 +00:00
<?php
namespace App\Livewire\Project\Resource;
use App\Models\Environment;
use App\Models\Project;
use Livewire\Component;
class Index extends Component
{
public Project $project;
2024-06-10 20:43:34 +00:00
2024-01-07 15:23:41 +00:00
public Environment $environment;
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $applications = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $postgresqls = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $redis = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $mongodbs = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $mysqls = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $mariadbs = [];
2024-06-10 20:43:34 +00:00
2024-04-10 13:00:46 +00:00
public $keydbs = [];
2024-06-10 20:43:34 +00:00
2024-04-10 13:00:46 +00:00
public $dragonflies = [];
2024-06-10 20:43:34 +00:00
2024-04-10 13:00:46 +00:00
public $clickhouses = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public $services = [];
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
public function mount()
{
2024-01-07 15:23:41 +00:00
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
2024-06-10 20:43:34 +00:00
if (! $project) {
2024-01-07 15:23:41 +00:00
return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
2024-06-10 20:43:34 +00:00
if (! $environment) {
2024-01-07 15:23:41 +00:00
return redirect()->route('dashboard');
}
$this->project = $project;
$this->environment = $environment;
$this->applications = $this->environment->applications->load(['tags']);
2024-01-12 10:25:20 +00:00
$this->applications = $this->applications->map(function ($application) {
if (data_get($application, 'environment.project.uuid')) {
$application->hrefLink = route('project.application.configuration', [
'project_uuid' => data_get($application, 'environment.project.uuid'),
'environment_name' => data_get($application, 'environment.name'),
2024-06-10 20:43:34 +00:00
'application_uuid' => data_get($application, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $application;
});
$this->postgresqls = $this->environment->postgresqls->load(['tags'])->sortBy('name');
$this->postgresqls = $this->postgresqls->map(function ($postgresql) {
2024-01-12 10:25:20 +00:00
if (data_get($postgresql, 'environment.project.uuid')) {
$postgresql->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($postgresql, 'environment.project.uuid'),
'environment_name' => data_get($postgresql, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($postgresql, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $postgresql;
});
$this->redis = $this->environment->redis->load(['tags'])->sortBy('name');
2024-01-12 10:25:20 +00:00
$this->redis = $this->redis->map(function ($redis) {
if (data_get($redis, 'environment.project.uuid')) {
$redis->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($redis, 'environment.project.uuid'),
'environment_name' => data_get($redis, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($redis, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $redis;
});
$this->mongodbs = $this->environment->mongodbs->load(['tags'])->sortBy('name');
2024-01-12 10:25:20 +00:00
$this->mongodbs = $this->mongodbs->map(function ($mongodb) {
if (data_get($mongodb, 'environment.project.uuid')) {
$mongodb->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($mongodb, 'environment.project.uuid'),
'environment_name' => data_get($mongodb, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($mongodb, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $mongodb;
});
$this->mysqls = $this->environment->mysqls->load(['tags'])->sortBy('name');
2024-01-12 10:25:20 +00:00
$this->mysqls = $this->mysqls->map(function ($mysql) {
if (data_get($mysql, 'environment.project.uuid')) {
$mysql->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($mysql, 'environment.project.uuid'),
'environment_name' => data_get($mysql, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($mysql, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $mysql;
});
$this->mariadbs = $this->environment->mariadbs->load(['tags'])->sortBy('name');
2024-01-12 10:25:20 +00:00
$this->mariadbs = $this->mariadbs->map(function ($mariadb) {
if (data_get($mariadb, 'environment.project.uuid')) {
$mariadb->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($mariadb, 'environment.project.uuid'),
'environment_name' => data_get($mariadb, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($mariadb, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $mariadb;
});
2024-04-10 13:00:46 +00:00
$this->keydbs = $this->environment->keydbs->load(['tags'])->sortBy('name');
$this->keydbs = $this->keydbs->map(function ($keydb) {
if (data_get($keydb, 'environment.project.uuid')) {
$keydb->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($keydb, 'environment.project.uuid'),
'environment_name' => data_get($keydb, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($keydb, 'uuid'),
2024-04-10 13:00:46 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-04-10 13:00:46 +00:00
return $keydb;
});
$this->dragonflies = $this->environment->dragonflies->load(['tags'])->sortBy('name');
$this->dragonflies = $this->dragonflies->map(function ($dragonfly) {
if (data_get($dragonfly, 'environment.project.uuid')) {
$dragonfly->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($dragonfly, 'environment.project.uuid'),
'environment_name' => data_get($dragonfly, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($dragonfly, 'uuid'),
2024-04-10 13:00:46 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-04-10 13:00:46 +00:00
return $dragonfly;
});
$this->clickhouses = $this->environment->clickhouses->load(['tags'])->sortBy('name');
$this->clickhouses = $this->clickhouses->map(function ($clickhouse) {
if (data_get($clickhouse, 'environment.project.uuid')) {
$clickhouse->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($clickhouse, 'environment.project.uuid'),
'environment_name' => data_get($clickhouse, 'environment.name'),
2024-06-10 20:43:34 +00:00
'database_uuid' => data_get($clickhouse, 'uuid'),
2024-04-10 13:00:46 +00:00
]);
}
2024-06-10 20:43:34 +00:00
2024-04-10 13:00:46 +00:00
return $clickhouse;
});
$this->services = $this->environment->services->load(['tags'])->sortBy('name');
2024-01-12 10:25:20 +00:00
$this->services = $this->services->map(function ($service) {
if (data_get($service, 'environment.project.uuid')) {
$service->hrefLink = route('project.service.configuration', [
'project_uuid' => data_get($service, 'environment.project.uuid'),
'environment_name' => data_get($service, 'environment.name'),
2024-06-10 20:43:34 +00:00
'service_uuid' => data_get($service, 'uuid'),
2024-01-12 10:25:20 +00:00
]);
$service->status = $service->status();
2024-01-12 10:25:20 +00:00
}
2024-06-10 20:43:34 +00:00
2024-01-12 10:25:20 +00:00
return $service;
});
2024-01-07 15:23:41 +00:00
}
2024-06-10 20:43:34 +00:00
2024-01-07 15:23:41 +00:00
public function render()
{
return view('livewire.project.resource.index');
}
}