2023-09-20 13:42:41 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Service;
|
2023-09-20 13:42:41 +00:00
|
|
|
|
|
|
|
use App\Models\Service;
|
2024-01-07 15:23:41 +00:00
|
|
|
use App\Models\ServiceApplication;
|
|
|
|
use App\Models\ServiceDatabase;
|
|
|
|
use Illuminate\Support\Collection;
|
2023-09-20 13:42:41 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Index extends Component
|
|
|
|
{
|
2024-04-08 09:16:20 +00:00
|
|
|
public ?Service $service = null;
|
2024-01-07 15:23:41 +00:00
|
|
|
public ?ServiceApplication $serviceApplication = null;
|
|
|
|
public ?ServiceDatabase $serviceDatabase = null;
|
2023-09-20 13:42:41 +00:00
|
|
|
public array $parameters;
|
|
|
|
public array $query;
|
2024-01-07 15:23:41 +00:00
|
|
|
public Collection $services;
|
|
|
|
public $s3s;
|
|
|
|
|
|
|
|
protected $listeners = ['generateDockerCompose'];
|
|
|
|
|
2023-09-30 13:08:40 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
2024-01-07 15:23:41 +00:00
|
|
|
try {
|
|
|
|
$this->services = collect([]);
|
|
|
|
$this->parameters = get_route_parameters();
|
|
|
|
$this->query = request()->query();
|
2024-04-08 09:16:20 +00:00
|
|
|
$this->service = Service::whereUuid($this->parameters['service_uuid'])->first();
|
|
|
|
if (!$this->service) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
2024-02-11 14:44:02 +00:00
|
|
|
$service = $this->service->applications()->whereUuid($this->parameters['stack_service_uuid'])->first();
|
2024-01-07 15:23:41 +00:00
|
|
|
if ($service) {
|
|
|
|
$this->serviceApplication = $service;
|
|
|
|
$this->serviceApplication->getFilesFromServer();
|
|
|
|
} else {
|
2024-02-11 14:44:02 +00:00
|
|
|
$this->serviceDatabase = $this->service->databases()->whereUuid($this->parameters['stack_service_uuid'])->first();
|
2024-01-07 15:23:41 +00:00
|
|
|
$this->serviceDatabase->getFilesFromServer();
|
|
|
|
}
|
|
|
|
$this->s3s = currentTeam()->s3s;
|
|
|
|
} catch(\Throwable $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
|
|
|
|
2023-09-30 13:08:40 +00:00
|
|
|
}
|
2024-01-07 15:23:41 +00:00
|
|
|
public function generateDockerCompose()
|
2023-09-30 13:08:40 +00:00
|
|
|
{
|
2024-01-07 15:23:41 +00:00
|
|
|
$this->service->parse();
|
2023-09-26 12:45:52 +00:00
|
|
|
}
|
2024-01-07 15:23:41 +00:00
|
|
|
public function render()
|
2023-09-26 12:45:52 +00:00
|
|
|
{
|
2024-01-07 15:23:41 +00:00
|
|
|
return view('livewire.project.service.index');
|
2023-09-26 12:45:52 +00:00
|
|
|
}
|
2023-09-20 13:42:41 +00:00
|
|
|
}
|