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