/
dimamir
/
coolify
Обзор
Документация
Войти
/
dimamir
/
coolify
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/Livewire/Server/Proxy.php
104 строки
3 KB
Andras Bacsai
feat: add proxy type change to create/update apis
12 ноя 2024, 16:30
12 ноя 2024, 16:30
055c613
Код
Авторство
О чём код?
<?php namespace App\Livewire\Server; use App\Actions\Proxy\CheckConfiguration; use App\Actions\Proxy\SaveConfiguration; use App\Models\Server; use Livewire\Component; class Proxy extends Component { public Server $server; public ?string $selectedProxy = null; public $proxy_settings = null; public ?string $redirect_url = null; protected $listeners = ['proxyStatusUpdated', 'saveConfiguration' => 'submit']; protected $rules = [ 'server.settings.generate_exact_labels' => 'required|boolean', ]; public function mount() { $this->selectedProxy = $this->server->proxyType(); $this->redirect_url = data_get($this->server, 'proxy.redirect_url'); } public function proxyStatusUpdated() { $this->dispatch('refresh')->self(); } public function changeProxy() { $this->server->proxy = null; $this->server->save(); $this->dispatch('proxyChanged'); } public function selectProxy($proxy_type) { try { $this->server->changeProxy($proxy_type, async: false); $this->selectedProxy = $this->server->proxy->type; $this->dispatch('proxyStatusUpdated'); } catch (\Throwable $e) { return handleError($e, $this); } } public function instantSave() { try { $this->validate(); $this->server->settings->save(); $this->dispatch('success', 'Settings saved.'); } catch (\Throwable $e) { return handleError($e, $this); } } public function submit() { try { SaveConfiguration::run($this->server, $this->proxy_settings); $this->server->proxy->redirect_url = $this->redirect_url; $this->server->save(); $this->server->setupDefault404Redirect(); $this->dispatch('success', 'Proxy configuration saved.'); } catch (\Throwable $e) { return handleError($e, $this); } } public function reset_proxy_configuration() { try { $this->proxy_settings = CheckConfiguration::run($this->server, true); SaveConfiguration::run($this->server, $this->proxy_settings); $this->server->save(); $this->dispatch('success', 'Proxy configuration saved.'); } catch (\Throwable $e) { return handleError($e, $this); } } public function loadProxyConfiguration() { try { $this->proxy_settings = CheckConfiguration::run($this->server); if (str($this->proxy_settings)->contains('--api.dashboard=true') && str($this->proxy_settings)->contains('--api.insecure=true')) { $this->dispatch('traefikDashboardAvailable', true); } else { $this->dispatch('traefikDashboardAvailable', false); } } catch (\Throwable $e) { return handleError($e, $this); } } }