flow to add new destinations
This commit is contained in:
parent
c295a3e90b
commit
4eb1c0412b
@ -43,17 +43,13 @@ public function mount()
|
||||
$this->port = 3000;
|
||||
}
|
||||
$this->parameters = Route::current()->parameters();
|
||||
$this->servers = session('currentTeam')->load(['servers'])->servers->reject(function ($server) {
|
||||
if ($server->standaloneDockers->count() === 0 && $server->swarmDockers->count() === 0) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
$this->servers = session('currentTeam')->load(['servers'])->servers;
|
||||
}
|
||||
public function chooseServer($server_id)
|
||||
public function chooseServer($server)
|
||||
{
|
||||
$this->chosenServer = $server_id;
|
||||
$this->standalone_docker = StandaloneDocker::where('server_id', $server_id)->get();
|
||||
$this->swarm_docker = SwarmDocker::where('server_id', $server_id)->get();
|
||||
$this->chosenServer = $server;
|
||||
$this->standalone_docker = StandaloneDocker::where('server_id', $server['id'])->get();
|
||||
$this->swarm_docker = SwarmDocker::where('server_id', $server['id'])->get();
|
||||
}
|
||||
public function setDestination($destination_uuid, $destination_type)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
<x-layout>
|
||||
<h1>New Destination</h1>
|
||||
<livewire:destination.new.standalone-docker />
|
||||
<livewire:destination.new.standalone-docker :server_id="$server_id" />
|
||||
</x-layout>
|
||||
|
@ -4,24 +4,37 @@
|
||||
@endif
|
||||
@forelse ($servers as $server)
|
||||
<button @if ($chosenServer == $server->id) class="bg-blue-500" @endif
|
||||
wire:click="chooseServer({{ $server->id }})">{{ $server->name }}</button>
|
||||
wire:click="chooseServer({{ $server }})">{{ $server->name }}</button>
|
||||
@empty
|
||||
No servers found.
|
||||
<p>Did you forget to add a destination on the server?</p>
|
||||
@endforelse
|
||||
|
||||
@isset($chosenServer)
|
||||
<h1>Choose a destination</h1>
|
||||
<div>
|
||||
@foreach ($standalone_docker as $standalone)
|
||||
<button @if ($chosenDestination?->uuid == $standalone->uuid) class="bg-blue-500" @endif
|
||||
wire:click="setDestination('{{ $standalone->uuid }}','StandaloneDocker')">{{ $standalone->network }}</button>
|
||||
@endforeach
|
||||
@foreach ($swarm_docker as $standalone)
|
||||
<button @if ($chosenDestination?->uuid == $standalone->uuid) class="bg-blue-500" @endif
|
||||
wire:click="setDestination('{{ $standalone->uuid }}','SwarmDocker')">{{ $standalone->uuid }}</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@if ($standalone_docker->count() > 0 || $swarm_docker->count() > 0)
|
||||
<h1>Choose a destination</h1>
|
||||
<div>
|
||||
@foreach ($standalone_docker as $standalone)
|
||||
<button @if ($chosenDestination?->uuid == $standalone->uuid) class="bg-blue-500" @endif
|
||||
wire:click="setDestination('{{ $standalone->uuid }}','StandaloneDocker')">{{ $standalone->network }}</button>
|
||||
@endforeach
|
||||
@foreach ($swarm_docker as $standalone)
|
||||
<button @if ($chosenDestination?->uuid == $standalone->uuid) class="bg-blue-500" @endif
|
||||
wire:click="setDestination('{{ $standalone->uuid }}','SwarmDocker')">{{ $standalone->uuid }}</button>
|
||||
@endforeach
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ route('destination.new', ['server_id' => $chosenServer['id']]) }}">Add
|
||||
a new
|
||||
destination</a>
|
||||
</div>
|
||||
@else
|
||||
<h1>No destinations found on this server.</h1>
|
||||
<a href="{{ route('destination.new', ['server_id' => $chosenServer['id']]) }}">Add
|
||||
a
|
||||
destination</a>
|
||||
@endif
|
||||
|
||||
@endisset
|
||||
|
||||
@isset($chosenDestination)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<x-layout>
|
||||
<h1>Server</h1>
|
||||
<livewire:server.form :server_id="$server->id" />
|
||||
<h2>Destinations</h2>
|
||||
<h2>Destinations <a href="{{ route('destination.new') }}"><button>New</button></h2>
|
||||
@if ($server->standaloneDockers)
|
||||
@foreach ($server->standaloneDockers as $docker)
|
||||
<p>Network: {{ data_get($docker, 'network') }}</p>
|
||||
|
@ -74,7 +74,16 @@
|
||||
});
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/destination/new', fn () => view('destination.new'))->name('destination.new');
|
||||
Route::get('/destination/new', function () {
|
||||
$query_params = request()->query();
|
||||
$server_id = null;
|
||||
if (isset($query_params['server_id'])) {
|
||||
$server_id = $query_params['server_id'];
|
||||
}
|
||||
return view('destination.new', [
|
||||
'server_id' => $server_id,
|
||||
]);
|
||||
})->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();
|
||||
|
Loading…
Reference in New Issue
Block a user