fix: restart proxy does not work + status indicator on the UI

This commit is contained in:
Andras Bacsai 2024-07-23 11:11:54 +02:00
parent 320204d854
commit f134171855
2 changed files with 8 additions and 5 deletions

View File

@ -50,7 +50,7 @@ public function traefikDashboardAvailable(bool $data)
public function proxyStarted() public function proxyStarted()
{ {
CheckProxy::run($this->server, true); CheckProxy::run($this->server, true);
$this->dispatch('success', 'Proxy started.'); $this->dispatch('proxyStatusUpdated');
} }
public function proxyStatusUpdated() public function proxyStatusUpdated()
@ -61,7 +61,7 @@ public function proxyStatusUpdated()
public function restart() public function restart()
{ {
try { try {
$this->stop(); $this->stop(forceStop: false);
$this->dispatch('checkProxy'); $this->dispatch('checkProxy');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
@ -91,7 +91,7 @@ public function startProxy()
} }
} }
public function stop() public function stop(bool $forceStop = true)
{ {
try { try {
if ($this->server->isSwarm()) { if ($this->server->isSwarm()) {
@ -104,7 +104,7 @@ public function stop()
], $this->server); ], $this->server);
} }
$this->server->proxy->status = 'exited'; $this->server->proxy->status = 'exited';
$this->server->proxy->force_stop = true; $this->server->proxy->force_stop = $forceStop;
$this->server->save(); $this->server->save();
$this->dispatch('proxyStatusUpdated'); $this->dispatch('proxyStatusUpdated');
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -16,7 +16,10 @@ class Status extends Component
public int $numberOfPolls = 0; public int $numberOfPolls = 0;
protected $listeners = ['proxyStatusUpdated' => '$refresh', 'startProxyPolling']; protected $listeners = [
'proxyStatusUpdated',
'startProxyPolling',
];
public function startProxyPolling() public function startProxyPolling()
{ {