fix: proxy status
This commit is contained in:
@@ -39,6 +39,7 @@ class Proxy extends Component
|
||||
{
|
||||
$this->server->proxy = null;
|
||||
$this->server->save();
|
||||
$this->dispatch('proxyChanged');
|
||||
}
|
||||
|
||||
public function selectProxy($proxy_type)
|
||||
@@ -47,7 +48,7 @@ class Proxy extends Component
|
||||
$this->server->proxy->set('type', $proxy_type);
|
||||
$this->server->save();
|
||||
$this->selectedProxy = $this->server->proxy->type;
|
||||
if ($this->selectedProxy !== 'NONE') {
|
||||
if ($this->server->proxySet()) {
|
||||
StartProxy::run($this->server, false);
|
||||
}
|
||||
$this->dispatch('proxyStatusUpdated');
|
||||
|
||||
@@ -29,6 +29,7 @@ class Deploy extends Component
|
||||
'serverRefresh' => 'proxyStatusUpdated',
|
||||
'checkProxy',
|
||||
'startProxy',
|
||||
'proxyChanged' => 'proxyStatusUpdated',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class Show extends Component
|
||||
|
||||
public $parameters = [];
|
||||
|
||||
protected $listeners = ['proxyStatusUpdated'];
|
||||
protected $listeners = ['proxyStatusUpdated', 'proxyChanged' => 'proxyStatusUpdated'];
|
||||
|
||||
public function proxyStatusUpdated()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Models;
|
||||
use App\Actions\Server\InstallDocker;
|
||||
use App\Enums\ProxyTypes;
|
||||
use App\Jobs\PullSentinelImageJob;
|
||||
use App\Notifications\Server\Revived;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -156,11 +155,17 @@ class Server extends BaseModel
|
||||
return $this->hasOne(ServerSetting::class);
|
||||
}
|
||||
|
||||
public function proxySet()
|
||||
{
|
||||
return $this->proxyType() && $this->proxyType() !== 'NONE' && $this->isFunctional() && ! $this->isSwarmWorker() && ! $this->settings->is_build_server;
|
||||
}
|
||||
|
||||
public function setupDefault404Redirect()
|
||||
{
|
||||
$dynamic_conf_path = $this->proxyPath().'/dynamic';
|
||||
$proxy_type = $this->proxyType();
|
||||
$redirect_url = $this->proxy->redirect_url;
|
||||
ray($proxy_type);
|
||||
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.yaml";
|
||||
} elseif ($proxy_type === 'CADDY') {
|
||||
@@ -950,12 +955,12 @@ $schema://$host {
|
||||
|
||||
public function isFunctional()
|
||||
{
|
||||
$isFunctional = $this->settings->is_reachable && $this->settings->is_usable && !$this->settings->force_disabled;
|
||||
|
||||
if (!$isFunctional) {
|
||||
$isFunctional = $this->settings->is_reachable && $this->settings->is_usable && ! $this->settings->force_disabled;
|
||||
|
||||
if (! $isFunctional) {
|
||||
Storage::disk('ssh-mux')->delete($this->muxFilename());
|
||||
}
|
||||
|
||||
|
||||
return $isFunctional;
|
||||
}
|
||||
|
||||
@@ -1007,7 +1012,7 @@ $schema://$host {
|
||||
|
||||
public function validateConnection($isManualCheck = true)
|
||||
{
|
||||
config()->set('constants.ssh.mux_enabled', !$isManualCheck);
|
||||
config()->set('constants.ssh.mux_enabled', ! $isManualCheck);
|
||||
// ray('Manual Check: ' . ($isManualCheck ? 'true' : 'false'));
|
||||
|
||||
$server = Server::find($this->id);
|
||||
@@ -1160,16 +1165,18 @@ $schema://$host {
|
||||
$server = new self($data);
|
||||
$server->privateKey()->associate($privateKey);
|
||||
$server->save();
|
||||
|
||||
return $server;
|
||||
}
|
||||
|
||||
public function updateWithPrivateKey(array $data, PrivateKey $privateKey = null)
|
||||
public function updateWithPrivateKey(array $data, ?PrivateKey $privateKey = null)
|
||||
{
|
||||
$this->update($data);
|
||||
if ($privateKey) {
|
||||
$this->privateKey()->associate($privateKey);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
<livewire:server.proxy.modal :server="$server" />
|
||||
<div class="flex items-center gap-2">
|
||||
<h1>Server</h1>
|
||||
<livewire:server.proxy.status :server="$server" />
|
||||
@if ($server->proxySet())
|
||||
<livewire:server.proxy.status :server="$server" />
|
||||
@endif
|
||||
</div>
|
||||
<div class="subtitle">{{ data_get($server, 'name') }}.</div>
|
||||
<div class="navbar-main">
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
<div class="flex h-full pr-4">
|
||||
<div class="flex flex-col w-48 gap-4 min-w-fit">
|
||||
<a class="{{ request()->routeIs('server.proxy') ? 'dark:text-white' : '' }}"
|
||||
href="{{ route('server.proxy', $parameters) }}">
|
||||
<button>Configuration</button>
|
||||
</a>
|
||||
@if ($server->proxyType() !== 'NONE')
|
||||
{{-- @if ($server->proxyType() === 'TRAEFIK') --}}
|
||||
@if ($server->proxySet())
|
||||
<div class="flex h-full pr-4">
|
||||
<div class="flex flex-col w-48 gap-4 min-w-fit">
|
||||
<a class="{{ request()->routeIs('server.proxy') ? 'dark:text-white' : '' }}"
|
||||
href="{{ route('server.proxy', $parameters) }}">
|
||||
<button>Configuration</button>
|
||||
</a>
|
||||
<a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
|
||||
href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
|
||||
<button>Dynamic Configurations</button>
|
||||
</a>
|
||||
{{-- @endif --}}
|
||||
<a class="{{ request()->routeIs('server.proxy.logs') ? 'dark:text-white' : '' }}"
|
||||
href="{{ route('server.proxy.logs', $parameters) }}">
|
||||
<button>Logs</button>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@@ -83,9 +83,9 @@
|
||||
<x-forms.button class="box" wire:click="selectProxy('CADDY')">
|
||||
Caddy
|
||||
</x-forms.button>
|
||||
<x-forms.button disabled class="box">
|
||||
{{-- <x-forms.button disabled class="box">
|
||||
Nginx
|
||||
</x-forms.button>
|
||||
</x-forms.button> --}}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
@php use App\Enums\ProxyTypes; @endphp
|
||||
<div>
|
||||
@if (
|
||||
$server->proxyType() !== 'NONE' &&
|
||||
$server->isFunctional() &&
|
||||
!$server->isSwarmWorker() &&
|
||||
!$server->settings->is_build_server)
|
||||
@if ($server->proxySet())
|
||||
<x-slide-over closeWithX fullScreen @startproxy.window="slideOverOpen = true">
|
||||
<x-slot:title>Proxy Status</x-slot:title>
|
||||
<x-slot:content>
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
<div x-init="$wire.checkProxy()">
|
||||
@if (
|
||||
$server->proxyType() !== 'NONE' &&
|
||||
$server->isFunctional() &&
|
||||
!$server->isSwarmWorker() &&
|
||||
!$server->settings->is_build_server)
|
||||
<div class="flex gap-2">
|
||||
@if (data_get($server, 'proxy.status') === 'running')
|
||||
<x-status.running status="Proxy Running" />
|
||||
@elseif (data_get($server, 'proxy.status') === 'restarting')
|
||||
<x-status.restarting status="Proxy Restarting" />
|
||||
@else
|
||||
<x-status.stopped status="Proxy Stopped" />
|
||||
@endif
|
||||
@if (data_get($server, 'proxy.status') === 'running')
|
||||
<x-forms.button wire:click='checkProxy(true)'>Refresh</x-forms.button>
|
||||
@endif
|
||||
</div>
|
||||
<div x-init="$wire.checkProxy()" class="flex gap-2">
|
||||
@if (data_get($server, 'proxy.status') === 'running')
|
||||
<x-status.running status="Proxy Running" />
|
||||
@elseif (data_get($server, 'proxy.status') === 'restarting')
|
||||
<x-status.restarting status="Proxy Restarting" />
|
||||
@else
|
||||
<x-status.stopped status="Proxy Stopped" />
|
||||
@endif
|
||||
@if (data_get($server, 'proxy.status') === 'running')
|
||||
<x-forms.button wire:click='checkProxy(true)'>Refresh</x-forms.button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user