fix(proxy): replace CheckConfiguration with GetProxyConfiguration and SaveConfiguration with SaveProxyConfiguration for improved clarity and consistency in proxy management

This commit is contained in:
Andras Bacsai
2025-09-09 12:52:19 +02:00
parent feacedbb04
commit 1ca94b90da
8 changed files with 103 additions and 79 deletions

View File

@@ -2,8 +2,8 @@
namespace App\Livewire\Server;
use App\Actions\Proxy\CheckConfiguration;
use App\Actions\Proxy\SaveConfiguration;
use App\Actions\Proxy\GetProxyConfiguration;
use App\Actions\Proxy\SaveProxyConfiguration;
use App\Models\Server;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
@@ -16,11 +16,11 @@ class Proxy extends Component
public ?string $selectedProxy = null;
public $proxy_settings = null;
public $proxySettings = null;
public bool $redirect_enabled = true;
public bool $redirectEnabled = true;
public ?string $redirect_url = null;
public ?string $redirectUrl = null;
public function getListeners()
{
@@ -39,14 +39,14 @@ class Proxy extends Component
public function mount()
{
$this->selectedProxy = $this->server->proxyType();
$this->redirect_enabled = data_get($this->server, 'proxy.redirect_enabled', true);
$this->redirect_url = data_get($this->server, 'proxy.redirect_url');
$this->redirectEnabled = data_get($this->server, 'proxy.redirect_enabled', true);
$this->redirectUrl = data_get($this->server, 'proxy.redirect_url');
}
// public function proxyStatusUpdated()
// {
// $this->dispatch('refresh')->self();
// }
public function getConfigurationFilePathProperty()
{
return $this->server->proxyPath().'/docker-compose.yml';
}
public function changeProxy()
{
@@ -86,7 +86,7 @@ class Proxy extends Component
{
try {
$this->authorize('update', $this->server);
$this->server->proxy->redirect_enabled = $this->redirect_enabled;
$this->server->proxy->redirect_enabled = $this->redirectEnabled;
$this->server->save();
$this->server->setupDefaultRedirect();
$this->dispatch('success', 'Proxy configuration saved.');
@@ -99,8 +99,8 @@ class Proxy extends Component
{
try {
$this->authorize('update', $this->server);
SaveConfiguration::run($this->server, $this->proxy_settings);
$this->server->proxy->redirect_url = $this->redirect_url;
SaveProxyConfiguration::run($this->server, $this->proxySettings);
$this->server->proxy->redirect_url = $this->redirectUrl;
$this->server->save();
$this->server->setupDefaultRedirect();
$this->dispatch('success', 'Proxy configuration saved.');
@@ -109,14 +109,15 @@ class Proxy extends Component
}
}
public function reset_proxy_configuration()
public function resetProxyConfiguration()
{
try {
$this->authorize('update', $this->server);
$this->proxy_settings = CheckConfiguration::run($this->server, true);
SaveConfiguration::run($this->server, $this->proxy_settings);
// Explicitly regenerate default configuration
$this->proxySettings = GetProxyConfiguration::run($this->server, forceRegenerate: true);
SaveProxyConfiguration::run($this->server, $this->proxySettings);
$this->server->save();
$this->dispatch('success', 'Proxy configuration saved.');
$this->dispatch('success', 'Proxy configuration reset to default.');
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -125,7 +126,7 @@ class Proxy extends Component
public function loadProxyConfiguration()
{
try {
$this->proxy_settings = CheckConfiguration::run($this->server);
$this->proxySettings = GetProxyConfiguration::run($this->server);
} catch (\Throwable $e) {
return handleError($e, $this);
}