coolify/app/Livewire/Project/Service/Configuration.php

46 lines
1.3 KiB
PHP
Raw Normal View History

2024-01-07 16:23:41 +01:00
<?php
namespace App\Livewire\Project\Service;
use App\Jobs\ContainerStatusJob;
use App\Models\Service;
use Livewire\Component;
class Configuration extends Component
{
2024-01-31 13:46:40 +01:00
public ?Service $service = null;
2024-01-07 16:23:41 +01:00
public $applications;
public $databases;
public array $parameters;
public array $query;
public function getListeners()
{
$userId = auth()->user()->id;
return [
2024-03-01 10:36:32 +01:00
"echo-private:user.{$userId},ServiceStatusChanged" => 'check_status',
2024-03-04 08:57:18 +01:00
"check_status"
2024-01-07 16:23:41 +01:00
];
}
public function render()
{
return view('livewire.project.service.configuration');
}
public function mount()
{
$this->parameters = get_route_parameters();
$this->query = request()->query();
$this->service = Service::whereUuid($this->parameters['service_uuid'])->first();
if (!$this->service) {
return redirect()->route('dashboard');
}
2024-01-07 16:23:41 +01:00
$this->applications = $this->service->applications->sort();
$this->databases = $this->service->databases->sort();
}
2024-03-01 10:36:32 +01:00
public function check_status()
2024-01-07 16:23:41 +01:00
{
dispatch_sync(new ContainerStatusJob($this->service->server));
2024-03-01 10:36:32 +01:00
$this->dispatch('refresh')->self();
2024-01-07 16:23:41 +01:00
$this->dispatch('serviceStatusChanged');
}
}