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