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