fix: destinations livewire refactor
removed unnecessary livewire components, renamed them ,etc etc
This commit is contained in:
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Destination;
|
|
||||||
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Form extends Component
|
|
||||||
{
|
|
||||||
public mixed $destination;
|
|
||||||
|
|
||||||
protected $rules = [
|
|
||||||
'destination.name' => 'required',
|
|
||||||
'destination.network' => 'required',
|
|
||||||
'destination.server.ip' => 'required',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $validationAttributes = [
|
|
||||||
'destination.name' => 'name',
|
|
||||||
'destination.network' => 'network',
|
|
||||||
'destination.server.ip' => 'IP Address/Domain',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function submit()
|
|
||||||
{
|
|
||||||
$this->validate();
|
|
||||||
$this->destination->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if ($this->destination->getMorphClass() === \App\Models\StandaloneDocker::class) {
|
|
||||||
if ($this->destination->attachedTo()) {
|
|
||||||
return $this->dispatch('error', 'You must delete all resources before deleting this destination.');
|
|
||||||
}
|
|
||||||
instant_remote_process(["docker network disconnect {$this->destination->network} coolify-proxy"], $this->destination->server, throwError: false);
|
|
||||||
instant_remote_process(['docker network rm -f '.$this->destination->network], $this->destination->server);
|
|
||||||
}
|
|
||||||
$this->destination->delete();
|
|
||||||
|
|
||||||
return redirect()->route('destination.all');
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
23
app/Livewire/Destination/Index.php
Normal file
23
app/Livewire/Destination/Index.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Destination;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Attributes\Locked;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
#[Locked]
|
||||||
|
public $servers;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->servers = Server::isUsable()->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.destination.index');
|
||||||
|
}
|
||||||
|
}
|
@@ -3,73 +3,91 @@
|
|||||||
namespace App\Livewire\Destination;
|
namespace App\Livewire\Destination;
|
||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker;
|
use Livewire\Attributes\Locked;
|
||||||
use App\Models\SwarmDocker;
|
use Livewire\Attributes\Rule;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Show extends Component
|
class Show extends Component
|
||||||
{
|
{
|
||||||
public Server $server;
|
#[Locked]
|
||||||
|
public $destination;
|
||||||
|
|
||||||
public Collection|array $networks = [];
|
#[Rule(['string', 'required'])]
|
||||||
|
public string $name;
|
||||||
|
|
||||||
private function createNetworkAndAttachToProxy()
|
#[Rule(['string', 'required'])]
|
||||||
|
public string $network;
|
||||||
|
|
||||||
|
#[Rule(['string', 'required'])]
|
||||||
|
public string $serverIp;
|
||||||
|
|
||||||
|
public function mount(string $destination_uuid)
|
||||||
{
|
{
|
||||||
$connectProxyToDockerNetworks = connectProxyToNetworks($this->server);
|
try {
|
||||||
instant_remote_process($connectProxyToDockerNetworks, $this->server, false);
|
$destination = Server::isUsable()->whereHas('standaloneDockers', function ($query) use ($destination_uuid) {
|
||||||
|
$query->where('uuid', $destination_uuid);
|
||||||
|
})->first()->standaloneDockers()->where('uuid', $destination_uuid)->first();
|
||||||
|
|
||||||
|
if (! $destination) {
|
||||||
|
$destination = Server::isUsable()->whereHas('swarmDockers', function ($query) use ($destination_uuid) {
|
||||||
|
$query->where('uuid', $destination_uuid);
|
||||||
|
})->first()->swarmDockers()->where('uuid', $destination_uuid)->first();
|
||||||
|
}
|
||||||
|
if (! $destination) {
|
||||||
|
throw new \Exception('Destination not found');
|
||||||
|
}
|
||||||
|
$this->destination = $destination;
|
||||||
|
$this->syncData();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($name)
|
public function syncData(bool $toModel = false)
|
||||||
{
|
{
|
||||||
if ($this->server->isSwarm()) {
|
if ($toModel) {
|
||||||
$found = $this->server->swarmDockers()->where('network', $name)->first();
|
$this->validate();
|
||||||
if ($found) {
|
$this->destination->name = $this->name;
|
||||||
$this->dispatch('error', 'Network already added to this server.');
|
$this->destination->network = $this->network;
|
||||||
|
$this->destination->server->ip = $this->serverIp;
|
||||||
return;
|
$this->destination->save();
|
||||||
} else {
|
} else {
|
||||||
SwarmDocker::create([
|
$this->name = $this->destination->name;
|
||||||
'name' => $this->server->name.'-'.$name,
|
$this->network = $this->destination->network;
|
||||||
'network' => $this->name,
|
$this->serverIp = $this->destination->server->ip;
|
||||||
'server_id' => $this->server->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$found = $this->server->standaloneDockers()->where('network', $name)->first();
|
|
||||||
if ($found) {
|
|
||||||
$this->dispatch('error', 'Network already added to this server.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
StandaloneDocker::create([
|
|
||||||
'name' => $this->server->name.'-'.$name,
|
|
||||||
'network' => $name,
|
|
||||||
'server_id' => $this->server->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$this->createNetworkAndAttachToProxy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scan()
|
public function submit()
|
||||||
{
|
{
|
||||||
if ($this->server->isSwarm()) {
|
try {
|
||||||
$alreadyAddedNetworks = $this->server->swarmDockers;
|
$this->syncData(true);
|
||||||
} else {
|
$this->dispatch('success', 'Destination saved.');
|
||||||
$alreadyAddedNetworks = $this->server->standaloneDockers;
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$networks = instant_remote_process(['docker network ls --format "{{json .}}"'], $this->server, false);
|
|
||||||
$this->networks = format_docker_command_output_to_json($networks)->filter(function ($network) {
|
|
||||||
return $network['Name'] !== 'bridge' && $network['Name'] !== 'host' && $network['Name'] !== 'none';
|
|
||||||
})->filter(function ($network) use ($alreadyAddedNetworks) {
|
|
||||||
return ! $alreadyAddedNetworks->contains('network', $network['Name']);
|
|
||||||
});
|
|
||||||
if ($this->networks->count() === 0) {
|
|
||||||
$this->dispatch('success', 'No new destinations found on this server.');
|
|
||||||
|
|
||||||
return;
|
public function delete()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($this->destination->getMorphClass() === \App\Models\StandaloneDocker::class) {
|
||||||
|
if ($this->destination->attachedTo()) {
|
||||||
|
return $this->dispatch('error', 'You must delete all resources before deleting this destination.');
|
||||||
}
|
}
|
||||||
$this->dispatch('success', 'Scan done.');
|
instant_remote_process(["docker network disconnect {$this->destination->network} coolify-proxy"], $this->destination->server, throwError: false);
|
||||||
|
instant_remote_process(['docker network rm -f '.$this->destination->network], $this->destination->server);
|
||||||
|
}
|
||||||
|
$this->destination->delete();
|
||||||
|
|
||||||
|
return redirect()->route('destination.index');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.destination.show');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Livewire\Server\Destination;
|
namespace App\Livewire\Server;
|
||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
@@ -8,7 +8,7 @@ use App\Models\SwarmDocker;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Show extends Component
|
class Destinations extends Component
|
||||||
{
|
{
|
||||||
public Server $server;
|
public Server $server;
|
||||||
|
|
||||||
@@ -86,6 +86,6 @@ class Show extends Component
|
|||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.server.destination.show');
|
return view('livewire.server.destinations');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -148,7 +148,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<a title="Destinations"
|
<a title="Destinations"
|
||||||
class="{{ request()->is('destination*') ? 'menu-item-active menu-item' : 'menu-item' }}"
|
class="{{ request()->is('destination*') ? 'menu-item-active menu-item' : 'menu-item' }}"
|
||||||
href="{{ route('destination.all') }}">
|
href="{{ route('destination.index') }}" wire:navigate>
|
||||||
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24">
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24">
|
||||||
<path fill="none" stroke="currentColor" stroke-linecap="round"
|
<path fill="none" stroke="currentColor" stroke-linecap="round"
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
<x-layout>
|
|
||||||
<x-slot:title>
|
|
||||||
Destinations | Coolify
|
|
||||||
</x-slot>
|
|
||||||
<div class="flex items-start gap-2">
|
|
||||||
<h1>Destinations</h1>
|
|
||||||
@if ($servers->count() > 0)
|
|
||||||
<x-modal-input buttonTitle="+ Add" title="New Destination">
|
|
||||||
<livewire:destination.new.docker :server_id="$server_id" />
|
|
||||||
</x-modal-input>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
<div class="subtitle">Network endpoints to deploy your resources.</div>
|
|
||||||
<div class="grid gap-2 lg:grid-cols-1">
|
|
||||||
@forelse ($destinations as $destination)
|
|
||||||
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
|
||||||
<a class="box group"
|
|
||||||
href="{{ route('destination.show', ['destination_uuid' => data_get($destination, 'uuid')]) }}">
|
|
||||||
<div class="flex flex-col mx-6">
|
|
||||||
<div class="box-title">{{ $destination->name }}</div>
|
|
||||||
<div class="box-description">server: {{ $destination->server->name }}</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
@if ($destination->getMorphClass() === 'App\Models\SwarmDocker')
|
|
||||||
<a class="box group"
|
|
||||||
href="{{ route('destination.show', ['destination_uuid' => data_get($destination, 'uuid')]) }}">
|
|
||||||
<div class="flex flex-col mx-6">
|
|
||||||
<div class="box-title">{{ $destination->name }}</div>
|
|
||||||
<div class="box-description">server: {{ $destination->server->name }}</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
@empty
|
|
||||||
<div>
|
|
||||||
@if ($servers->count() === 0)
|
|
||||||
<div>No servers found. Please add one first.</div>
|
|
||||||
@else
|
|
||||||
<div>No destinations found.</div>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@endforelse
|
|
||||||
</div>
|
|
||||||
</x-layout>
|
|
@@ -1,3 +0,0 @@
|
|||||||
<x-layout>
|
|
||||||
<livewire:destination.form :destination="$destination" />
|
|
||||||
</x-layout>
|
|
@@ -1,29 +0,0 @@
|
|||||||
<div>
|
|
||||||
<form class="flex flex-col">
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<h1>Destination</h1>
|
|
||||||
<x-forms.button wire:click.prevent='submit' type="submit">
|
|
||||||
Save
|
|
||||||
</x-forms.button>
|
|
||||||
@if ($destination->network !== 'coolify')
|
|
||||||
<x-modal-confirmation title="Confirm Destination Deletion?" buttonTitle="Delete Destination" isErrorButton
|
|
||||||
submitAction="delete" :actions="['This will delete the selected destination/network.']" confirmationText="{{ $destination->name }}"
|
|
||||||
confirmationLabel="Please confirm the execution of the actions by entering the Destination Name below"
|
|
||||||
shortConfirmationLabel="Destination Name" :confirmWithPassword="false" step2ButtonText="Permanently Delete" />
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
|
||||||
<div class="subtitle ">A Docker network in a non-swarm environment.</div>
|
|
||||||
@else
|
|
||||||
<div class="subtitle ">Your swarm docker network. WIP</div>
|
|
||||||
@endif
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<x-forms.input id="destination.name" label="Name" />
|
|
||||||
<x-forms.input id="destination.server.ip" label="Server IP" readonly />
|
|
||||||
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
|
||||||
<x-forms.input id="destination.network" label="Docker Network" readonly />
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
44
resources/views/livewire/destination/index.blade.php
Normal file
44
resources/views/livewire/destination/index.blade.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<div>
|
||||||
|
<x-slot:title>
|
||||||
|
Destinations | Coolify
|
||||||
|
</x-slot>
|
||||||
|
<div class="flex items-start gap-2">
|
||||||
|
<h1>Destinations</h1>
|
||||||
|
@if ($servers->count() > 0)
|
||||||
|
<x-modal-input buttonTitle="+ Add" title="New Destination">
|
||||||
|
<livewire:destination.new.docker />
|
||||||
|
</x-modal-input>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="subtitle">Network endpoints to deploy your resources.</div>
|
||||||
|
<div class="grid gap-2 lg:grid-cols-1">
|
||||||
|
@forelse ($servers as $server)
|
||||||
|
@forelse ($server->destinations() as $destination)
|
||||||
|
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
||||||
|
<a class="box group"
|
||||||
|
href="{{ route('destination.show', ['destination_uuid' => data_get($destination, 'uuid')]) }}"
|
||||||
|
wire:navigate>
|
||||||
|
<div class="flex flex-col mx-6">
|
||||||
|
<div class="box-title">{{ $destination->name }}</div>
|
||||||
|
<div class="box-description">Server: {{ $destination->server->name }}</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
@if ($destination->getMorphClass() === 'App\Models\SwarmDocker')
|
||||||
|
<a class="box group"
|
||||||
|
href="{{ route('destination.show', ['destination_uuid' => data_get($destination, 'uuid')]) }}"
|
||||||
|
wire:navigate>
|
||||||
|
<div class="flex flex-col mx-6">
|
||||||
|
<div class="box-title">{{ $destination->name }}</div>
|
||||||
|
<div class="box-description">server: {{ $destination->server->name }}</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
@empty
|
||||||
|
<div>No destinations found.</div>
|
||||||
|
@endforelse
|
||||||
|
@empty
|
||||||
|
<div>No servers found.</div>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -1,42 +1,29 @@
|
|||||||
<div>
|
<div>
|
||||||
@if ($server->isFunctional())
|
<form class="flex flex-col">
|
||||||
<div class="flex items-end gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<h2>Destinations</h2>
|
<h1>Destination</h1>
|
||||||
<x-modal-input buttonTitle="+ Add" title="New Destination">
|
<x-forms.button wire:click.prevent='submit' type="submit">
|
||||||
<livewire:destination.new.docker :server_id="$server->id" />
|
Save
|
||||||
</x-modal-input>
|
</x-forms.button>
|
||||||
<x-forms.button wire:click='scan'>Scan for Destinations</x-forms.button>
|
@if ($network !== 'coolify')
|
||||||
</div>
|
<x-modal-confirmation title="Confirm Destination Deletion?" buttonTitle="Delete Destination" isErrorButton
|
||||||
<div>Destinations are used to segregate resources by network.</div>
|
submitAction="delete" :actions="['This will delete the selected destination/network.']" confirmationText="{{ $destination->name }}"
|
||||||
<div class="flex gap-2 pt-6">
|
confirmationLabel="Please confirm the execution of the actions by entering the Destination Name below"
|
||||||
Available for using:
|
shortConfirmationLabel="Destination Name" :confirmWithPassword="false" step2ButtonText="Permanently Delete" />
|
||||||
@forelse ($server->standaloneDockers as $docker)
|
|
||||||
<a href="{{ route('destination.show', ['destination_uuid' => data_get($docker, 'uuid')]) }}">
|
|
||||||
<button class="dark:text-white btn-link">{{ data_get($docker, 'network') }} </button>
|
|
||||||
</a>
|
|
||||||
@empty
|
|
||||||
@endforelse
|
|
||||||
@forelse ($server->swarmDockers as $docker)
|
|
||||||
<a href="{{ route('destination.show', ['destination_uuid' => data_get($docker, 'uuid')]) }}">
|
|
||||||
<button class="dark:text-white btn-link">{{ data_get($docker, 'network') }} </button>
|
|
||||||
</a>
|
|
||||||
@empty
|
|
||||||
@endforelse
|
|
||||||
</div>
|
|
||||||
<div class="pt-2">
|
|
||||||
@if (count($networks) > 0)
|
|
||||||
<h3 class="pb-4">Found Destinations</h3>
|
|
||||||
@endif
|
@endif
|
||||||
<div class="flex flex-wrap gap-2 ">
|
|
||||||
@foreach ($networks as $network)
|
|
||||||
<div class="min-w-fit">
|
|
||||||
<x-forms.button wire:click="add('{{ data_get($network, 'Name') }}')">Add
|
|
||||||
{{ data_get($network, 'Name') }}</x-forms.button>
|
|
||||||
</div>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
||||||
|
<div class="subtitle ">A Docker network in a non-swarm environment.</div>
|
||||||
@else
|
@else
|
||||||
<div>Server is not validated. Validate first.</div>
|
<div class="subtitle ">Your swarm docker network. WIP</div>
|
||||||
@endif
|
@endif
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<x-forms.input id="name" label="Name" />
|
||||||
|
<x-forms.input id="serverIp" label="Server IP" readonly />
|
||||||
|
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
||||||
|
<x-forms.input id="network" label="Docker Network" readonly />
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
49
resources/views/livewire/server/destinations.blade.php
Normal file
49
resources/views/livewire/server/destinations.blade.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<div>
|
||||||
|
<x-slot:title>
|
||||||
|
{{ data_get_str($server, 'name')->limit(10) }} > Destinations | Coolify
|
||||||
|
</x-slot>
|
||||||
|
<x-server.navbar :server="$server" />
|
||||||
|
<div class="flex flex-col h-full gap-8 sm:flex-row">
|
||||||
|
<x-server.sidebar :server="$server" activeMenu="destinations" />
|
||||||
|
<div class="w-full">
|
||||||
|
@if ($server->isFunctional())
|
||||||
|
<div class="flex items-end gap-2">
|
||||||
|
<h2>Destinations</h2>
|
||||||
|
<x-modal-input buttonTitle="+ Add" title="New Destination">
|
||||||
|
<livewire:destination.new.docker :server_id="$server->id" />
|
||||||
|
</x-modal-input>
|
||||||
|
<x-forms.button isHighlighted wire:click='scan'>Scan for Destinations</x-forms.button>
|
||||||
|
</div>
|
||||||
|
<div>Destinations are used to segregate resources by network.</div>
|
||||||
|
<h4 class="pt-4 pb-2">Available Destinations</h4>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
@foreach ($server->standaloneDockers as $docker)
|
||||||
|
<a href="{{ route('destination.show', ['destination_uuid' => data_get($docker, 'uuid')]) }}">
|
||||||
|
<x-forms.button>{{ data_get($docker, 'network') }} </x-forms.button>
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
@foreach ($server->swarmDockers as $docker)
|
||||||
|
<a href="{{ route('destination.show', ['destination_uuid' => data_get($docker, 'uuid')]) }}">
|
||||||
|
<x-forms.button>{{ data_get($docker, 'network') }} </x-forms.button>
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@if ($networks->count() > 0)
|
||||||
|
<div class="pt-2">
|
||||||
|
<h3 class="pb-4">Found Destinations</h3>
|
||||||
|
<div class="flex flex-wrap gap-2 ">
|
||||||
|
@foreach ($networks as $network)
|
||||||
|
<div class="min-w-fit">
|
||||||
|
<x-forms.button wire:click="add('{{ data_get($network, 'Name') }}')">Add
|
||||||
|
{{ data_get($network, 'Name') }}</x-forms.button>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<div>Server is not validated. Validate first.</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -7,6 +7,8 @@ use App\Http\Controllers\UploadController;
|
|||||||
use App\Livewire\Admin\Index as AdminIndex;
|
use App\Livewire\Admin\Index as AdminIndex;
|
||||||
use App\Livewire\Boarding\Index as BoardingIndex;
|
use App\Livewire\Boarding\Index as BoardingIndex;
|
||||||
use App\Livewire\Dashboard;
|
use App\Livewire\Dashboard;
|
||||||
|
use App\Livewire\Destination\Index as DestinationIndex;
|
||||||
|
use App\Livewire\Destination\Show as DestinationShow;
|
||||||
use App\Livewire\Dev\Compose as Compose;
|
use App\Livewire\Dev\Compose as Compose;
|
||||||
use App\Livewire\ForcePasswordReset;
|
use App\Livewire\ForcePasswordReset;
|
||||||
use App\Livewire\Notifications\Discord as NotificationDiscord;
|
use App\Livewire\Notifications\Discord as NotificationDiscord;
|
||||||
@@ -38,7 +40,7 @@ use App\Livewire\Server\Advanced as ServerAdvanced;
|
|||||||
use App\Livewire\Server\Charts as ServerCharts;
|
use App\Livewire\Server\Charts as ServerCharts;
|
||||||
use App\Livewire\Server\CloudflareTunnels;
|
use App\Livewire\Server\CloudflareTunnels;
|
||||||
use App\Livewire\Server\Delete as DeleteServer;
|
use App\Livewire\Server\Delete as DeleteServer;
|
||||||
use App\Livewire\Server\Destination\Show as DestinationShow;
|
use App\Livewire\Server\Destinations as ServerDestinations;
|
||||||
use App\Livewire\Server\Index as ServerIndex;
|
use App\Livewire\Server\Index as ServerIndex;
|
||||||
use App\Livewire\Server\LogDrains;
|
use App\Livewire\Server\LogDrains;
|
||||||
use App\Livewire\Server\PrivateKey\Show as PrivateKeyShow;
|
use App\Livewire\Server\PrivateKey\Show as PrivateKeyShow;
|
||||||
@@ -72,8 +74,6 @@ use App\Livewire\Terminal\Index as TerminalIndex;
|
|||||||
use App\Models\GitlabApp;
|
use App\Models\GitlabApp;
|
||||||
use App\Models\ScheduledDatabaseBackupExecution;
|
use App\Models\ScheduledDatabaseBackupExecution;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker;
|
|
||||||
use App\Models\SwarmDocker;
|
|
||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -212,7 +212,7 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
|||||||
Route::get('/private-key', PrivateKeyShow::class)->name('server.private-key');
|
Route::get('/private-key', PrivateKeyShow::class)->name('server.private-key');
|
||||||
Route::get('/resources', ResourcesShow::class)->name('server.resources');
|
Route::get('/resources', ResourcesShow::class)->name('server.resources');
|
||||||
Route::get('/cloudflare-tunnels', CloudflareTunnels::class)->name('server.cloudflare-tunnels');
|
Route::get('/cloudflare-tunnels', CloudflareTunnels::class)->name('server.cloudflare-tunnels');
|
||||||
Route::get('/destinations', DestinationShow::class)->name('server.destinations');
|
Route::get('/destinations', ServerDestinations::class)->name('server.destinations');
|
||||||
Route::get('/log-drains', LogDrains::class)->name('server.log-drains');
|
Route::get('/log-drains', LogDrains::class)->name('server.log-drains');
|
||||||
Route::get('/metrics', ServerCharts::class)->name('server.charts');
|
Route::get('/metrics', ServerCharts::class)->name('server.charts');
|
||||||
Route::get('/danger', DeleteServer::class)->name('server.delete');
|
Route::get('/danger', DeleteServer::class)->name('server.delete');
|
||||||
@@ -312,52 +312,8 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
return response()->json(['message' => $e->getMessage()], 500);
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
})->name('download.backup');
|
})->name('download.backup');
|
||||||
Route::get('/destinations', function () {
|
Route::get('/destinations', DestinationIndex::class)->name('destination.index');
|
||||||
$servers = Server::isUsable()->get();
|
Route::get('/destination/{destination_uuid}', DestinationShow::class)->name('destination.show');
|
||||||
$destinations = collect([]);
|
|
||||||
foreach ($servers as $server) {
|
|
||||||
$destinations = $destinations->merge($server->destinations());
|
|
||||||
}
|
|
||||||
$pre_selected_server_uuid = data_get(request()->query(), 'server');
|
|
||||||
if ($pre_selected_server_uuid) {
|
|
||||||
$server = $servers->firstWhere('uuid', $pre_selected_server_uuid);
|
|
||||||
if ($server) {
|
|
||||||
$server_id = $server->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('destination.all', [
|
|
||||||
'destinations' => $destinations,
|
|
||||||
'servers' => $servers,
|
|
||||||
'server_id' => $server_id ?? null,
|
|
||||||
]);
|
|
||||||
})->name('destination.all');
|
|
||||||
// Route::get('/destination/new', function () {
|
|
||||||
// $servers = Server::isUsable()->get();
|
|
||||||
// $pre_selected_server_uuid = data_get(request()->query(), 'server');
|
|
||||||
// if ($pre_selected_server_uuid) {
|
|
||||||
// $server = $servers->firstWhere('uuid', $pre_selected_server_uuid);
|
|
||||||
// if ($server) {
|
|
||||||
// $server_id = $server->id;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return view('destination.new', [
|
|
||||||
// "servers" => $servers,
|
|
||||||
// "server_id" => $server_id ?? null,
|
|
||||||
// ]);
|
|
||||||
// })->name('destination.new');
|
|
||||||
Route::get('/destination/{destination_uuid}', function () {
|
|
||||||
$standalone_dockers = StandaloneDocker::where('uuid', request()->destination_uuid)->first();
|
|
||||||
$swarm_dockers = SwarmDocker::where('uuid', request()->destination_uuid)->first();
|
|
||||||
if (! $standalone_dockers && ! $swarm_dockers) {
|
|
||||||
abort(404);
|
|
||||||
}
|
|
||||||
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
|
||||||
|
|
||||||
return view('destination.show', [
|
|
||||||
'destination' => $destination->load(['server']),
|
|
||||||
]);
|
|
||||||
})->name('destination.show');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::any('/{any}', function () {
|
Route::any('/{any}', function () {
|
||||||
|
Reference in New Issue
Block a user