refactor(proxy): streamline proxy status handling and improve dashboard availability checks

This commit is contained in:
Andras Bacsai
2025-06-11 12:02:39 +02:00
parent 23d5ada3b8
commit 9ad2304229
20 changed files with 459 additions and 559 deletions

View File

@@ -87,7 +87,7 @@
<x-slide-over @automated.window="slideOverOpen = true" fullScreen>
<x-slot:title>Cloudflare Tunnel Configuration</x-slot:title>
<x-slot:content>
<livewire:activity-monitor header="Logs" showWaiting fullHeight />
<livewire:activity-monitor header="Logs" fullHeight />
</x-slot:content>
</x-slide-over>
<form @submit.prevent="$wire.dispatch('automatedCloudflareConfig')"

View File

@@ -1,41 +1,58 @@
<div class="pb-6">
<x-modal modalId="startProxy">
<x-slot:modalBody>
<livewire:activity-monitor header="Proxy Startup Logs" />
</x-slot:modalBody>
<x-slot:modalSubmit>
<x-forms.button onclick="startProxy.close()" type="submit">
Close
</x-forms.button>
</x-slot:modalSubmit>
</x-modal>
<x-slide-over @startproxy.window="slideOverOpen = true" fullScreen>
<x-slot:title>Proxy Startup Logs</x-slot:title>
<x-slot:content>
<livewire:activity-monitor header="Logs" fullHeight />
</x-slot:content>
</x-slide-over>
<div class="flex items-center gap-2">
<h1>Server</h1>
@if ($server->proxySet())
<div class="flex gap-2">
@if (data_get($server, 'proxy.force_stop', false) === false)
<x-forms.button wire:click='checkProxyStatus()' :disabled="$isChecking" wire:loading.attr="disabled"
wire:target="checkProxyStatus">
<span wire:loading.remove wire:target="checkProxyStatus">Refresh</span>
<span wire:loading wire:target="checkProxyStatus">Checking...</span>
</x-forms.button>
@endif
<div wire:loading.remove wire:target="checkProxyStatus" class="flex items-center 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" />
<div class="flex">
<div class="flex items-center">
@if ($proxyStatus === 'running')
<x-status.running status="Proxy Running" noLoading />
@elseif ($proxyStatus === 'restarting')
<x-status.restarting status="Proxy Restarting" noLoading />
@elseif ($proxyStatus === 'stopping')
<x-status.restarting status="Proxy Stopping" noLoading />
@elseif ($proxyStatus === 'starting')
<x-status.restarting status="Proxy Starting" noLoading />
@elseif (data_get($server, 'proxy.force_stop'))
<x-status.stopped status="Proxy Stopped" />
@elseif (data_get($server, 'proxy.status') === 'exited')
<x-status.stopped status="Proxy Exited" />
@else
<x-status.stopped status="Proxy Not Running" />
<x-status.stopped status="Proxy Stopped (Force Stop)" noLoading />
<div wire:loading wire:target="checkProxy" class="badge badge-warning"></div>
<div wire:loading wire:target="checkProxy"
class="pl-2 pr-1 text-xs font-bold tracking-wider text-warning">
Checking Ports Availability...
</div>
@elseif ($proxyStatus === 'exited')
<x-status.stopped status="Proxy Exited" noLoading />
@endif
@if ($proxyStatus !== 'exited')
<div wire:loading>
<div class="flex items-center">
<svg class="w-4 h-4 mx-1 ml-3 text-coollabs dark:text-warning animate-spin"
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10"
stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
</path>
</svg>
</div>
</div>
<button title="Refresh Status" wire:click='checkProxyStatus'
class="mx-1 dark:hover:fill-white fill-black dark:fill-warning">
<svg class="w-4 h-4" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path
d="M12 2a10.016 10.016 0 0 0-7 2.877V3a1 1 0 1 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2H6.218A7.98 7.98 0 0 1 20 12a1 1 0 0 0 2 0A10.012 10.012 0 0 0 12 2zm7.989 13.5h-4.5a1 1 0 0 0 0 2h2.293A7.98 7.98 0 0 1 4 12a1 1 0 0 0-2 0a9.986 9.986 0 0 0 16.989 7.133V21a1 1 0 0 0 2 0v-4.5a1 1 0 0 0-1-1z" />
</svg>
</button>
@endif
</div>
</div>
@endif
</div>
<div class="subtitle">{{ data_get($server, 'name') }}</div>
@@ -85,7 +102,7 @@
<livewire:activity-monitor header="Logs" />
</x-slot:content>
</x-slide-over>
@if (data_get($server, 'proxy.status') === 'running')
@if ($proxyStatus === 'running')
<div class="flex gap-2">
<div class="mt-1" wire:loading wire:target="loadProxyConfiguration">
<x-loading text="Checking Traefik dashboard" />
@@ -155,7 +172,6 @@
<script>
$wire.$on('checkProxyEvent', () => {
try {
$wire.$dispatch('info', 'Checking if the required ports are not used by other services.');
$wire.$call('checkProxy');
} catch (error) {
console.error(error);
@@ -171,7 +187,6 @@
$wire.$call('startProxy');
});
$wire.$on('stopEvent', () => {
$wire.$dispatch('info', 'Stopping proxy.');
$wire.$call('stop');
});
</script>

View File

@@ -120,7 +120,7 @@
@endif
@endif
<livewire:activity-monitor header="Docker Installation Logs" />
<livewire:activity-monitor header="Docker Installation Logs" :showWaiting="false" />
@isset($error)
<pre class="font-bold whitespace-pre-line text-error">{!! $error !!}</pre>
@endisset