switch proxy

This commit is contained in:
Andras Bacsai 2023-06-08 08:39:00 +02:00
parent eb9c65d765
commit d029029043
6 changed files with 32 additions and 13 deletions

View File

@ -21,6 +21,11 @@ class Proxy extends Component
{ {
$this->server->refresh(); $this->server->refresh();
} }
public function switchProxy()
{
$this->server->extra_attributes->proxy_type = null;
$this->server->save();
}
public function installProxy() public function installProxy()
{ {
if ( if (

View File

@ -12,7 +12,6 @@ class Status extends Component
protected $listeners = ['proxyStatusUpdated', 'serverValidated' => 'proxyStatusUpdated']; protected $listeners = ['proxyStatusUpdated', 'serverValidated' => 'proxyStatusUpdated'];
public function proxyStatusUpdated() public function proxyStatusUpdated()
{ {
ray('Status: ' . $this->server->extra_attributes->proxy_status);
$this->server->refresh(); $this->server->refresh();
} }
public function proxyStatus() public function proxyStatus()

View File

@ -35,7 +35,7 @@ label {
} }
textarea { textarea {
@apply textarea placeholder:text-neutral-700 text-white rounded-none; @apply textarea placeholder:text-neutral-700 text-white rounded-none scrollbar;
} }
select { select {
@apply select select-sm text-sm disabled:bg-coolgray-200 border-none disabled:opacity-50 font-normal placeholder:text-neutral-700 text-white rounded-none; @apply select select-sm text-sm disabled:bg-coolgray-200 border-none disabled:opacity-50 font-normal placeholder:text-neutral-700 text-white rounded-none;

View File

@ -55,8 +55,8 @@
</div> </div>
@endif @endif
@isset($uptime) @isset($uptime)
<h3>Server Info</h3> <h3 class="py-3">Server Info</h3>
<div class="pt-3 text-sm"> <div class="text-sm">
<p>Uptime: {{ $uptime }}</p> <p>Uptime: {{ $uptime }}</p>
@isset($dockerVersion) @isset($dockerVersion)
<p>Docker Engine {{ $dockerVersion }}</p> <p>Docker Engine {{ $dockerVersion }}</p>

View File

@ -13,9 +13,9 @@
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<h2>Proxy</h2> <h2>Proxy</h2>
<x-forms.button type="submit">Save</x-forms.button> <x-forms.button type="submit">Save</x-forms.button>
<x-forms.button wire:click.prevent="resetProxy"> @if ($server->extra_attributes->proxy_status === 'exited')
Reset to default <x-forms.button wire:click.prevent="switchProxy">Switch Proxy</x-forms.button>
</x-forms.button> @endif
<livewire:server.proxy.status :server="$server" /> <livewire:server.proxy.status :server="$server" />
</div> </div>
<div class="pb-4 text-sm">Traefik v2</div> <div class="pb-4 text-sm">Traefik v2</div>
@ -25,8 +25,13 @@
<div class="text-sm text-red-500">Configuration out of sync. Restart to get the new configs. <div class="text-sm text-red-500">Configuration out of sync. Restart to get the new configs.
</div> </div>
@endif @endif
<x-forms.textarea label="Configuration file: traefik.conf" class="text-xs" noDirty <div class="flex flex-col gap-2">
name="proxy_settings" wire:model.defer="proxy_settings" rows="30" /> <x-forms.textarea label="Configuration file: traefik.conf" class="text-xs" noDirty
name="proxy_settings" wire:model.defer="proxy_settings" rows="30" />
<x-forms.button wire:click.prevent="resetProxy">
Reset configuration to default
</x-forms.button>
</div>
</form> </form>
@endif @endif
@endisset @endisset
@ -34,9 +39,19 @@
@else @else
<div> <div>
<h2>Proxy</h2> <h2>Proxy</h2>
<div class="pt-2 pb-10 text-sm">Select a proxy you would like to use on this server.</div>
<x-forms.button wire:click="setProxy('{{ \App\Enums\ProxyTypes::TRAEFIK_V2 }}')">Traefik v2 <div class="flex gap-2">
</x-forms.button> <x-forms.button class="w-32 box" wire:click="setProxy('{{ \App\Enums\ProxyTypes::TRAEFIK_V2 }}')">
Traefik
v2
</x-forms.button>
<x-forms.button disabled class="w-32 box">
Nginx
</x-forms.button>
<x-forms.button disabled class="w-32 box">
Caddy
</x-forms.button>
</div>
</div> </div>
@endif @endif
<div class="container w-full pt-4 mx-auto"> <div class="container w-full pt-4 mx-auto">

View File

@ -1,6 +1,6 @@
<div> <div>
@if ($server->settings->is_validated) @if ($server->settings->is_validated)
<div wire:poll.5000ms="proxyStatus"> <div wire:poll.10000ms="proxyStatus">
@if ($server->extra_attributes->proxy_status === 'running') @if ($server->extra_attributes->proxy_status === 'running')
<x-loading wire:loading.delay.longer /> <x-loading wire:loading.delay.longer />
<div class="flex items-center gap-2" wire:loading.remove.delay.longer> <div class="flex items-center gap-2" wire:loading.remove.delay.longer>