destinations
This commit is contained in:
parent
b8b0d2243f
commit
32b7a1ffcd
39
app/Http/Livewire/Destination/Form.php
Normal file
39
app/Http/Livewire/Destination/Form.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Destination;
|
||||||
|
|
||||||
|
use App\Models\StandaloneDocker;
|
||||||
|
use App\Models\SwarmDocker;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Form extends Component
|
||||||
|
{
|
||||||
|
public $destination_uuid;
|
||||||
|
public $destination;
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'destination.name' => 'required',
|
||||||
|
'destination.network' => 'required',
|
||||||
|
'destination.server.ip' => 'required',
|
||||||
|
];
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$standalone = StandaloneDocker::where('uuid', $this->destination_uuid)->first();
|
||||||
|
$swarm = SwarmDocker::where('uuid', $this->destination_uuid)->first();
|
||||||
|
if (!$standalone && !$swarm) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
$this->destination = $standalone ? $standalone->load(['server']) : $swarm->load(['server']);
|
||||||
|
}
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
$this->destination->save();
|
||||||
|
}
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
instantRemoteProcess(['docker network rm -f ' . $this->destination->network], $this->destination->server);
|
||||||
|
$this->destination->delete();
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker as ModelsStandaloneDocker;
|
use App\Models\StandaloneDocker as ModelsStandaloneDocker;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
class StandaloneDocker extends Component
|
class StandaloneDocker extends Component
|
||||||
{
|
{
|
||||||
@ -12,7 +13,7 @@ class StandaloneDocker extends Component
|
|||||||
public string $network;
|
public string $network;
|
||||||
|
|
||||||
public $servers;
|
public $servers;
|
||||||
public int|null $server_id = null;
|
public int $server_id;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
@ -21,13 +22,11 @@ class StandaloneDocker extends Component
|
|||||||
];
|
];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->name = generateRandomName();
|
|
||||||
$this->servers = Server::where('team_id', session('currentTeam')->id)->get();
|
$this->servers = Server::where('team_id', session('currentTeam')->id)->get();
|
||||||
|
$this->network = new Cuid2(7);
|
||||||
|
$this->name = generateRandomName();
|
||||||
}
|
}
|
||||||
public function setServerId($server_id)
|
|
||||||
{
|
|
||||||
$this->server_id = $server_id;
|
|
||||||
}
|
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
@ -8,9 +8,13 @@ body {
|
|||||||
a, a:visited {
|
a, a:visited {
|
||||||
@apply text-neutral-300 hover:text-purple-500;
|
@apply text-neutral-300 hover:text-purple-500;
|
||||||
}
|
}
|
||||||
input, select, textarea {
|
input, textarea {
|
||||||
@apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600;
|
@apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none
|
||||||
}
|
}
|
||||||
|
select {
|
||||||
|
@apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600 read-only:select-none
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@apply border-none px-2 p-1 cursor-pointer;
|
@apply border-none px-2 p-1 cursor-pointer;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@props([
|
@props([
|
||||||
'isWarning' => null,
|
'isWarning' => null,
|
||||||
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600',
|
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 w-28',
|
||||||
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600',
|
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 w-28',
|
||||||
'loadingClass' => 'text-black bg-green-500',
|
'loadingClass' => 'text-black bg-green-500',
|
||||||
'confirm' => null,
|
'confirm' => null,
|
||||||
'confirmAction' => null,
|
'confirmAction' => null,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
'id' => null,
|
'id' => null,
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'readonly' => false,
|
|
||||||
'label' => null,
|
'label' => null,
|
||||||
'instantSave' => false,
|
'instantSave' => false,
|
||||||
'disabled' => false,
|
'disabled' => false,
|
||||||
|
25
resources/views/components/inputs/select.blade.php
Normal file
25
resources/views/components/inputs/select.blade.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@props([
|
||||||
|
'id' => null,
|
||||||
|
'label' => null,
|
||||||
|
'required' => false,
|
||||||
|
])
|
||||||
|
|
||||||
|
<span @class(['flex flex-col'])>
|
||||||
|
<label for={{ $id }}>
|
||||||
|
@if ($label)
|
||||||
|
{{ $label }}
|
||||||
|
@else
|
||||||
|
{{ $id }}
|
||||||
|
@endif
|
||||||
|
@if ($required)
|
||||||
|
*
|
||||||
|
@endif
|
||||||
|
</label>
|
||||||
|
<select {{ $attributes }} wire:model.defer={{ $id }}>
|
||||||
|
{{ $slot }}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
@error($id)
|
||||||
|
<div class="text-red-500">{{ $message }}</div>
|
||||||
|
@enderror
|
||||||
|
</span>
|
@ -1,11 +1,4 @@
|
|||||||
<x-layout>
|
<x-layout>
|
||||||
<h1>Destination</h1>
|
<h1>Destination</h1>
|
||||||
<p>Name: {{ data_get($destination, 'name') }}</p>
|
<livewire:destination.form :destination_uuid="$destination_uuid" />
|
||||||
<p>Server:{{ data_get($destination, 'server.ip') }}:{{ data_get($destination, 'server.port') }} </p>
|
|
||||||
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
|
||||||
<p>Network: {{ data_get($destination, 'network') }}</p>
|
|
||||||
@endif
|
|
||||||
@if ($destination->getMorphClass() === 'App\Models\SwarmDocker')
|
|
||||||
<p>Uuid: {{ data_get($destination, 'uuid') }}</p>
|
|
||||||
@endif
|
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<x-inputs.button wire:click='checkUpdate' type="submit">Check for updates</x-inputs.button>
|
<x-inputs.button class="w-32 text-white bg-neutral-800 hover:bg-violet-600" wire:click='checkUpdate' type="submit">
|
||||||
|
Check for updates</x-inputs.button>
|
||||||
@if ($updateAvailable)
|
@if ($updateAvailable)
|
||||||
Update available
|
Update available
|
||||||
@endif
|
@endif
|
||||||
|
18
resources/views/livewire/destination/form.blade.php
Normal file
18
resources/views/livewire/destination/form.blade.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<div>
|
||||||
|
<form class="flex flex-col gap-4" wire:submit.prevent='submit'>
|
||||||
|
<x-inputs.input id="destination.name" label="Name" />
|
||||||
|
<x-inputs.input id="destination.server.ip" label="Server IP" readonly />
|
||||||
|
@if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
|
||||||
|
<x-inputs.input id="destination.network" label="Docker Network" readonly />
|
||||||
|
@endif
|
||||||
|
<div>
|
||||||
|
<x-inputs.button>
|
||||||
|
Submit
|
||||||
|
</x-inputs.button>
|
||||||
|
<x-inputs.button confirm='Are you sure you would like to delete this private key?'
|
||||||
|
confirmAction="delete('{{ $destination->id }}')">
|
||||||
|
Delete
|
||||||
|
</x-inputs.button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
@ -1,21 +1,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<form class="flex flex-col" wire:submit.prevent='submit'>
|
<form class="flex items-end gap-4" wire:submit.prevent='submit'>
|
||||||
<x-inputs.input id="name" label="Name" required />
|
<x-inputs.input id="name" label="Name" required />
|
||||||
<x-inputs.input id="network" label="Network" required />
|
<x-inputs.input id="network" label="Network" required />
|
||||||
<x-inputs.input id="server_id" label="Server ID" required />
|
<x-inputs.select id="server_id" label="Select a server" required>
|
||||||
@foreach ($servers as $key)
|
@foreach ($servers as $server)
|
||||||
@if ($server_id == $key->id)
|
<option value="{{ $server->id }}">{{ $server->name }}</option>
|
||||||
<x-inputs.button class="bg-green-500" wire:click.prevent="setServerId('{{ $key->id }}')">
|
@endforeach
|
||||||
{{ $key->name }}
|
</x-inputs.select>
|
||||||
</x-inputs.button>
|
<x-inputs.button type="submit">
|
||||||
@else
|
|
||||||
<x-inputs.button wire:click.prevent="setServerId('{{ $key->id }}')">{{ $key->name }}
|
|
||||||
</x-inputs.button>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
<x-inputs.button class="mt-4" type="submit">
|
|
||||||
Submit
|
Submit
|
||||||
</x-inputs.button>
|
</x-inputs.button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<p>IP: {{ $destination->server->ip }}</p>
|
<p>Server Name: {{ data_get($destination, 'server.name') }}</p>
|
||||||
<p>Description: {{ $destination->server->description }}</p>
|
@if (data_get($destination, 'server.description'))
|
||||||
|
<p>Description: {{ data_get($destination, 'server.description') }}</p>
|
||||||
|
@endif
|
||||||
<p>Docker Network: {{ $destination->network }}</p>
|
<p>Docker Network: {{ $destination->network }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,18 +15,16 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col w-96">
|
<div class="flex flex-col w-96">
|
||||||
|
|
||||||
<x-inputs.input id="application.base_directory" label="Base Directory" />
|
<x-inputs.input id="application.base_directory" label="Base Directory" />
|
||||||
@if ($application->settings->is_static)
|
@if ($application->settings->is_static)
|
||||||
<x-inputs.input id="application.publish_directory" label="Publish Directory" required />
|
<x-inputs.input id="application.publish_directory" label="Publish Directory" required />
|
||||||
@else
|
@else
|
||||||
<x-inputs.input id="application.publish_directory" label="Publish Directory" />
|
<x-inputs.input id="application.publish_directory" label="Publish Directory" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col w-96">
|
<div class="flex flex-col w-96">
|
||||||
@if ($application->settings->is_static)
|
@if ($application->settings->is_static)
|
||||||
<x-inputs.input id="application.ports_exposes" label="Ports Exposes" disabled />
|
<x-inputs.input id="application.ports_exposes" label="Ports Exposes" readonly />
|
||||||
@else
|
@else
|
||||||
<x-inputs.input id="application.ports_exposes" label="Ports Exposes" required />
|
<x-inputs.input id="application.ports_exposes" label="Ports Exposes" required />
|
||||||
@endif
|
@endif
|
||||||
@ -34,7 +32,7 @@
|
|||||||
<x-inputs.input id="application.ports_mappings" label="Ports Mappings" />
|
<x-inputs.input id="application.ports_mappings" label="Ports Mappings" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<x-inputs.button class="flex mx-auto mt-4" type="submit">
|
<x-inputs.button class="mx-auto mt-4 text-white bg-neutral-800 hover:bg-violet-600" type="submit">
|
||||||
Submit
|
Submit
|
||||||
</x-inputs.button>
|
</x-inputs.button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
<p>HostPath:{{ data_get($storage, 'host_path') }}</p>
|
<p>HostPath:{{ data_get($storage, 'host_path') }}</p>
|
||||||
<p>ContainerId:{{ data_get($storage, 'container_id') }}</p>
|
<p>ContainerId:{{ data_get($storage, 'container_id') }}</p>
|
||||||
@empty
|
@empty
|
||||||
<p>No storage found.</p>
|
<p>There are no storages added for this application.</p>
|
||||||
@endforelse
|
@endforelse
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
@if ($is_static)
|
@if ($is_static)
|
||||||
<x-inputs.input id="publish_directory" label="Publish Directory" />
|
<x-inputs.input id="publish_directory" label="Publish Directory" />
|
||||||
@else
|
@else
|
||||||
<x-inputs.input type="number" id="port" label="Port" :disabled="$is_static" />
|
<x-inputs.input type="number" id="port" label="Port" :readonly="$is_static" />
|
||||||
@endif
|
@endif
|
||||||
<x-inputs.button type="submit">
|
<x-inputs.button type="submit">
|
||||||
Submit
|
Submit
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/destination/new', function () {
|
Route::get('/destination/new', function () {
|
||||||
$query_params = request()->query();
|
$query_params = request()->query();
|
||||||
$server_id = null;
|
$server_id = 1;
|
||||||
if (isset($query_params['server_id'])) {
|
if (isset($query_params['server_id'])) {
|
||||||
$server_id = $query_params['server_id'];
|
$server_id = $query_params['server_id'];
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@
|
|||||||
}
|
}
|
||||||
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
||||||
return view('destination.show', [
|
return view('destination.show', [
|
||||||
'destination' => $destination,
|
'destination_uuid' => $destination->uuid,
|
||||||
]);
|
]);
|
||||||
})->name('destination.show');
|
})->name('destination.show');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user