wip
This commit is contained in:
@@ -4,7 +4,8 @@ namespace App\Http\Livewire\Server;
|
||||
|
||||
use App\Actions\Proxy\CheckProxySettingsInSync;
|
||||
use App\Actions\Proxy\InstallProxy;
|
||||
use App\Enums\ActivityTypes;
|
||||
use App\Enums\ProxyTypes;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -12,34 +13,60 @@ class Proxy extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
protected string $selectedProxy = '';
|
||||
|
||||
public ProxyTypes $selectedProxy = ProxyTypes::TRAEFIK_V2;
|
||||
public $is_proxy_installed;
|
||||
|
||||
public $is_check_proxy_complete = false;
|
||||
public $is_proxy_settings_in_sync = false;
|
||||
public $proxy_settings = null;
|
||||
|
||||
public function mount(Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
public function runInstallProxy()
|
||||
public function installProxy()
|
||||
{
|
||||
$this->saveConfiguration($this->server);
|
||||
$activity = resolve(InstallProxy::class)($this->server);
|
||||
|
||||
$this->emit('newMonitorActivity', $activity->id);
|
||||
}
|
||||
|
||||
public function proxyStatus()
|
||||
{
|
||||
$this->server->extra_attributes->proxy_status = checkContainerStatus(server: $this->server, container_id: 'coolify-proxy');
|
||||
$this->server->save();
|
||||
}
|
||||
public function setProxy()
|
||||
{
|
||||
$this->server->extra_attributes->proxy_type = $this->selectedProxy->value;
|
||||
$this->server->extra_attributes->proxy_status = 'exited';
|
||||
$this->server->save();
|
||||
}
|
||||
public function stopProxy()
|
||||
{
|
||||
instantRemoteProcess([
|
||||
"docker rm -f coolify-proxy",
|
||||
], $this->server);
|
||||
$this->server->extra_attributes->proxy_status = 'exited';
|
||||
$this->server->save();
|
||||
}
|
||||
public function saveConfiguration()
|
||||
{
|
||||
try {
|
||||
$proxy_path = config('coolify.proxy_config_path');
|
||||
$this->proxy_settings = Str::of($this->proxy_settings)->trim();
|
||||
$docker_compose_yml_base64 = base64_encode($this->proxy_settings);
|
||||
$this->server->extra_attributes->last_saved_proxy_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
||||
$this->server->save();
|
||||
instantRemoteProcess([
|
||||
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
|
||||
], $this->server);
|
||||
} catch (\Exception $e) {
|
||||
return generalErrorHandler($e);
|
||||
}
|
||||
}
|
||||
public function checkProxySettingsInSync()
|
||||
{
|
||||
$this->is_proxy_settings_in_sync = resolve(CheckProxySettingsInSync::class)($this->server);
|
||||
|
||||
$this->is_check_proxy_complete = true;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.server.proxy');
|
||||
try {
|
||||
$this->proxy_settings = resolve(CheckProxySettingsInSync::class)($this->server);
|
||||
$this->is_check_proxy_complete = true;
|
||||
} catch (\Exception $e) {
|
||||
return generalErrorHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user