This commit is contained in:
Andras Bacsai 2023-07-28 21:36:19 +02:00
parent 469e404725
commit b57b4f9bd3
9 changed files with 32 additions and 40 deletions

View File

@ -11,18 +11,13 @@ class Deploy extends Component
{
public Server $server;
public $proxy_settings = null;
protected $listeners = ['proxyStatusUpdated'];
public function proxyStatusUpdated()
{
$this->server->refresh();
}
public function start_proxy()
{
if (
$this->server->proxy->last_applied_settings &&
$this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
) {
$this->saveConfiguration($this->server);
$this->emit('saveConfiguration', $server);
}
$activity = resolve(StartProxy::class)($this->server);
$this->emit('newMonitorActivity', $activity->id);
@ -36,8 +31,4 @@ public function stop()
$this->server->save();
$this->emit('proxyStatusUpdated');
}
private function saveConfiguration(Server $server)
{
$this->emit('saveConfiguration', $server);
}
}
}

View File

@ -9,20 +9,12 @@
class Status extends Component
{
public Server $server;
protected $listeners = ['proxyStatusUpdated'];
public function proxyStatusUpdated()
{
$this->server->refresh();
}
public function get_status()
{
try {
dispatch_sync(new ProxyContainerStatusJob(
server: $this->server
));
$this->emit('proxyStatusUpdated');
} catch (\Exception $e) {
ray($e->getMessage());
}
dispatch_sync(new ProxyContainerStatusJob(
server: $this->server
));
$this->server->refresh();
$this->emit('proxyStatusUpdated');
}
}

View File

@ -1,5 +1,8 @@
<div class="pb-6">
<h1>Server</h1>
<div class="flex items-center gap-2">
<h1>Server</h1>
<livewire:server.proxy.status :server="$server" />
</div>
<div class="pt-2 pb-10 ">{{ data_get($server, 'name') }}</div>
<nav class="navbar-main">
<a class="{{ request()->routeIs('server.show') ? 'text-white' : '' }}"
@ -26,9 +29,7 @@
]) }}">
<button>Destinations</button>
</a>
@if (request()->routeIs('server.proxy'))
<div class="flex-1"></div>
<livewire:server.proxy.deploy :server="$server" />
@endif
<div class="flex-1"></div>
<livewire:server.proxy.deploy :server="$server" />
</nav>
</div>

View File

@ -1,5 +1,8 @@
@props([
'text' => 'Stopped',
])
<x-loading wire:loading.delay />
<div class="flex items-center gap-2 " wire:loading.remove.delay.longer>
<div class="flex items-center gap-2" wire:loading.remove.delay.longer>
<div class="badge badge-error badge-xs"></div>
<div class="text-xs font-medium tracking-wide text-error">Stopped</div>
<div class="text-xs font-medium tracking-wide text-error">{{ $text }}</div>
</div>

View File

@ -1,5 +1,8 @@
@props([
'text' => 'Running',
])
<x-loading wire:loading.delay.longer />
<div class="flex items-center gap-2 " wire:loading.remove.delay.longer>
<div class="badge badge-success badge-xs"></div>
<div class="text-xs font-medium tracking-wide text-success">Running</div>
<div class="text-xs font-medium tracking-wide text-success">{{ $text }}</div>
</div>

View File

@ -1,5 +1,8 @@
@props([
'text' => 'Stopped',
])
<x-loading wire:loading.delay.longer />
<div class="flex items-center gap-2 " wire:loading.remove.delay.longer>
<div class="badge badge-error badge-xs"></div>
<div class="text-xs font-medium tracking-wide text-error">Stopped</div>
<div class="text-xs font-medium tracking-wide text-error">{{ $text }}</div>
</div>

View File

@ -10,7 +10,6 @@
@if ($server->proxy->status === 'exited')
<x-forms.button wire:click.prevent="change_proxy">Switch Proxy</x-forms.button>
@endif
<livewire:server.proxy.status :server="$server" />
</div>
<div class="pt-3 pb-4 ">Traefik v2</div>
@if (

View File

@ -1,9 +1,9 @@
<div wire:poll.10000ms="get_status" x-init="$wire.get_status">
<div wire:poll.3000ms="get_status" x-init="$wire.get_status">
@if ($server->proxy->status === 'running')
<x-status.running />
<x-status.running text="Proxy Running" />
@elseif ($server->proxy->status === 'restarting')
<x-status.restarting />
<x-status.restarting text="Proxy Restarting" />
@else
<x-status.stopped />
<x-status.stopped text="Proxy Stopped" />
@endif
</div>

View File

@ -67,7 +67,7 @@
'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),
]))->name('server.create');
Route::get('/server/{server_uuid}', fn () => view('server.show', [
'server' => Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user'])->whereUuid(request()->server_uuid)->firstOrFail(),
'server' => Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail(),
]))->name('server.show');
Route::get('/server/{server_uuid}/proxy', fn () => view('server.proxy', [
'server' => Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail(),
@ -77,7 +77,7 @@
'privateKeys' => PrivateKey::ownedByCurrentTeam()->get(),
]))->name('server.private-key');
Route::get('/server/{server_uuid}/destinations', fn () => view('server.destinations', [
'server' => Server::ownedByCurrentTeam(['name'])->whereUuid(request()->server_uuid)->firstOrFail()
'server' => Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail()
]))->name('server.destinations');
});