wip
This commit is contained in:
parent
32b7a1ffcd
commit
69811e26cd
@ -8,23 +8,13 @@ use Livewire\Component;
|
|||||||
|
|
||||||
class Form extends Component
|
class Form extends Component
|
||||||
{
|
{
|
||||||
public $destination_uuid;
|
public mixed $destination;
|
||||||
public $destination;
|
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'destination.name' => 'required',
|
'destination.name' => 'required',
|
||||||
'destination.network' => 'required',
|
'destination.network' => 'required',
|
||||||
'destination.server.ip' => '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()
|
public function submit()
|
||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Http\Livewire\Destination\New;
|
|||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker as ModelsStandaloneDocker;
|
use App\Models\StandaloneDocker as ModelsStandaloneDocker;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ class StandaloneDocker extends Component
|
|||||||
public string $name;
|
public string $name;
|
||||||
public string $network;
|
public string $network;
|
||||||
|
|
||||||
public $servers;
|
public Collection $servers;
|
||||||
public int $server_id;
|
public int $server_id;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
@ -22,7 +23,9 @@ class StandaloneDocker extends Component
|
|||||||
];
|
];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->servers = Server::where('team_id', session('currentTeam')->id)->get();
|
if (request()->query('server_id')) {
|
||||||
|
$this->server_id = request()->query('server_id');
|
||||||
|
}
|
||||||
$this->network = new Cuid2(7);
|
$this->network = new Cuid2(7);
|
||||||
$this->name = generateRandomName();
|
$this->name = generateRandomName();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<x-layout>
|
<x-layout>
|
||||||
<h1>New Destination</h1>
|
<h1>New Destination</h1>
|
||||||
<livewire:destination.new.standalone-docker :server_id="$server_id" />
|
<livewire:destination.new.standalone-docker :servers="$servers" />
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<x-layout>
|
<x-layout>
|
||||||
<h1>Destination</h1>
|
<h1>Destination</h1>
|
||||||
<livewire:destination.form :destination_uuid="$destination_uuid" />
|
<livewire:destination.form :destination="$destination" />
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
@ -8,6 +8,7 @@ use App\Models\PrivateKey;
|
|||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use App\Models\SwarmDocker;
|
use App\Models\SwarmDocker;
|
||||||
use App\Http\Controllers\ServerController;
|
use App\Http\Controllers\ServerController;
|
||||||
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,13 +93,9 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/destination/new', function () {
|
Route::get('/destination/new', function () {
|
||||||
$query_params = request()->query();
|
$servers = Server::where('team_id', session('currentTeam')->id)->get();
|
||||||
$server_id = 1;
|
|
||||||
if (isset($query_params['server_id'])) {
|
|
||||||
$server_id = $query_params['server_id'];
|
|
||||||
}
|
|
||||||
return view('destination.new', [
|
return view('destination.new', [
|
||||||
'server_id' => $server_id,
|
"servers" => $servers,
|
||||||
]);
|
]);
|
||||||
})->name('destination.new');
|
})->name('destination.new');
|
||||||
Route::get('/destination/{destination_uuid}', function () {
|
Route::get('/destination/{destination_uuid}', function () {
|
||||||
@ -109,7 +106,7 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
}
|
}
|
||||||
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
||||||
return view('destination.show', [
|
return view('destination.show', [
|
||||||
'destination_uuid' => $destination->uuid,
|
'destination' => $destination->load(['server']),
|
||||||
]);
|
]);
|
||||||
})->name('destination.show');
|
})->name('destination.show');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user