2023-09-22 09:23:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Project\Service;
|
|
|
|
|
|
|
|
use App\Models\Service;
|
|
|
|
use App\Models\ServiceApplication;
|
|
|
|
use App\Models\ServiceDatabase;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Show extends Component
|
|
|
|
{
|
|
|
|
public Service $service;
|
2023-09-28 11:15:14 +00:00
|
|
|
public ?ServiceApplication $serviceApplication = null;
|
|
|
|
public ?ServiceDatabase $serviceDatabase = null;
|
2023-09-22 09:23:49 +00:00
|
|
|
public array $parameters;
|
|
|
|
public array $query;
|
|
|
|
public Collection $services;
|
2023-11-07 13:09:24 +00:00
|
|
|
public $s3s;
|
|
|
|
|
2023-09-22 09:23:49 +00:00
|
|
|
protected $listeners = ['generateDockerCompose'];
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
{
|
2023-09-30 13:08:40 +00:00
|
|
|
try {
|
|
|
|
$this->services = collect([]);
|
|
|
|
$this->parameters = get_route_parameters();
|
|
|
|
$this->query = request()->query();
|
|
|
|
$this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
|
|
|
|
$service = $this->service->applications()->whereName($this->parameters['service_name'])->first();
|
|
|
|
if ($service) {
|
|
|
|
$this->serviceApplication = $service;
|
|
|
|
$this->serviceApplication->getFilesFromServer();
|
|
|
|
} else {
|
|
|
|
$this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
|
|
|
|
$this->serviceDatabase->getFilesFromServer();
|
|
|
|
}
|
2023-11-07 13:09:24 +00:00
|
|
|
$this->s3s = currentTeam()->s3s;
|
2023-09-30 13:08:40 +00:00
|
|
|
} catch(\Throwable $e) {
|
|
|
|
return handleError($e, $this);
|
2023-09-22 09:23:49 +00:00
|
|
|
}
|
2023-09-30 13:08:40 +00:00
|
|
|
|
2023-09-22 09:23:49 +00:00
|
|
|
}
|
|
|
|
public function generateDockerCompose()
|
|
|
|
{
|
|
|
|
$this->service->parse();
|
|
|
|
}
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.service.show');
|
|
|
|
}
|
|
|
|
}
|