coolify/app/Http/Livewire/Server/Proxy/Status.php

35 lines
808 B
PHP
Raw Normal View History

2023-06-02 15:15:12 +02:00
<?php
namespace App\Http\Livewire\Server\Proxy;
2023-09-18 11:49:26 +02:00
use App\Jobs\ContainerStatusJob;
2023-06-02 15:15:12 +02:00
use App\Models\Server;
use Livewire\Component;
class Status extends Component
{
public Server $server;
2023-09-11 22:29:34 +02:00
protected $listeners = ['proxyStatusUpdated'];
2023-09-11 22:43:07 +02:00
public function proxyStatusUpdated()
{
2023-09-11 22:29:34 +02:00
$this->server->refresh();
}
public function getProxyStatus()
2023-06-02 15:15:12 +02:00
{
2023-09-11 22:29:34 +02:00
try {
2023-09-12 13:14:01 +02:00
if ($this->server->isFunctional()) {
2023-09-18 11:49:26 +02:00
dispatch_sync(new ContainerStatusJob($this->server));
2023-09-11 22:29:34 +02:00
$this->emit('proxyStatusUpdated');
}
} catch (\Throwable $e) {
return handleError($e);
2023-08-28 20:29:44 +02:00
}
2023-09-11 22:29:34 +02:00
}
2023-09-11 22:43:07 +02:00
public function getProxyStatusWithNoti()
{
$this->emit('success', 'Refreshed proxy status.');
2023-09-11 22:29:34 +02:00
$this->getProxyStatus();
2023-06-02 15:15:12 +02:00
}
}