proxy updates
This commit is contained in:
		@@ -4,6 +4,7 @@ namespace App\Enums;
 | 
			
		||||
 | 
			
		||||
enum ProxyTypes: string
 | 
			
		||||
{
 | 
			
		||||
    case NONE = 'NONE';
 | 
			
		||||
    case TRAEFIK_V2 = 'TRAEFIK_V2';
 | 
			
		||||
    case NGINX = 'NGINX';
 | 
			
		||||
    case CADDY = 'CADDY';
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Http\Livewire\Server\New;
 | 
			
		||||
 | 
			
		||||
use App\Enums\ProxyStatus;
 | 
			
		||||
use App\Enums\ProxyTypes;
 | 
			
		||||
use App\Models\Server;
 | 
			
		||||
use Livewire\Component;
 | 
			
		||||
 | 
			
		||||
@@ -67,6 +69,11 @@ class ByIp extends Component
 | 
			
		||||
                'port' => $this->port,
 | 
			
		||||
                'team_id' => currentTeam()->id,
 | 
			
		||||
                'private_key_id' => $this->private_key_id,
 | 
			
		||||
                'proxy' => [
 | 
			
		||||
                    "type" => ProxyTypes::TRAEFIK_V2->value,
 | 
			
		||||
                    "status" => ProxyStatus::EXITED->value,
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
            ]);
 | 
			
		||||
            $server->settings->is_part_of_swarm = $this->is_part_of_swarm;
 | 
			
		||||
            $server->settings->save();
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ class Proxy extends Component
 | 
			
		||||
{
 | 
			
		||||
    public Server $server;
 | 
			
		||||
 | 
			
		||||
    public ProxyTypes $selectedProxy = ProxyTypes::TRAEFIK_V2;
 | 
			
		||||
    public ?string $selectedProxy = null;
 | 
			
		||||
    public $proxy_settings = null;
 | 
			
		||||
    public string|null $redirect_url = null;
 | 
			
		||||
 | 
			
		||||
@@ -20,6 +20,7 @@ class Proxy extends Component
 | 
			
		||||
 | 
			
		||||
    public function mount()
 | 
			
		||||
    {
 | 
			
		||||
        $this->selectedProxy = $this->server->proxy->type;
 | 
			
		||||
        $this->redirect_url = $this->server->proxy->redirect_url;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -35,11 +36,12 @@ class Proxy extends Component
 | 
			
		||||
        $this->emit('proxyStatusUpdated');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function select_proxy(ProxyTypes $proxy_type)
 | 
			
		||||
    public function select_proxy($proxy_type)
 | 
			
		||||
    {
 | 
			
		||||
        $this->server->proxy->type = $proxy_type;
 | 
			
		||||
        $this->server->proxy->status = 'exited';
 | 
			
		||||
        $this->server->save();
 | 
			
		||||
        $this->selectedProxy = $this->server->proxy->type;
 | 
			
		||||
        $this->emit('proxyStatusUpdated');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
@php use App\Enums\ProxyTypes; @endphp
 | 
			
		||||
<div>
 | 
			
		||||
    @if ($server->settings->is_usable)
 | 
			
		||||
        @if ($server->proxy->type)
 | 
			
		||||
            <div x-init="$wire.load_proxy_configuration">
 | 
			
		||||
                @if ($selectedProxy->value === 'TRAEFIK_V2')
 | 
			
		||||
                @if ($selectedProxy === 'TRAEFIK_V2')
 | 
			
		||||
                    <form wire:submit.prevent='submit'>
 | 
			
		||||
                        <div class="flex items-center gap-2">
 | 
			
		||||
                            <h2>Proxy</h2>
 | 
			
		||||
@@ -40,13 +39,31 @@
 | 
			
		||||
                            @endif
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </form>
 | 
			
		||||
                @elseif($selectedProxy === 'NONE')
 | 
			
		||||
                    <div class="flex items-center gap-2">
 | 
			
		||||
                        <h2>Proxy</h2>
 | 
			
		||||
                        @if ($server->proxy->status === 'exited')
 | 
			
		||||
                            <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
 | 
			
		||||
                        @endif
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="pt-3 pb-4">None</div>
 | 
			
		||||
                @else
 | 
			
		||||
                <div class="flex items-center gap-2">
 | 
			
		||||
                    <h2>Proxy</h2>
 | 
			
		||||
                    @if ($server->proxy->status === 'exited')
 | 
			
		||||
                        <x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
 | 
			
		||||
                    @endif
 | 
			
		||||
                </div>
 | 
			
		||||
                @endif
 | 
			
		||||
            @else
 | 
			
		||||
                <div>
 | 
			
		||||
                    <h2>Proxy</h2>
 | 
			
		||||
                    <div class="subtitle ">Select a proxy you would like to use on this server.</div>
 | 
			
		||||
                    <div class="flex gap-2">
 | 
			
		||||
                        <x-forms.button class="w-32 box" wire:click="select_proxy('{{ ProxyTypes::TRAEFIK_V2 }}')">
 | 
			
		||||
                        <x-forms.button class="w-32 box" wire:click="select_proxy('NONE')">
 | 
			
		||||
                            Custom (None)
 | 
			
		||||
                        </x-forms.button>
 | 
			
		||||
                        <x-forms.button class="w-32 box" wire:click="select_proxy('TRAEFIK_V2')">
 | 
			
		||||
                            Traefik
 | 
			
		||||
                            v2
 | 
			
		||||
                        </x-forms.button>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user