add destinations
This commit is contained in:
51
app/Http/Livewire/Destination/New/StandaloneDocker.php
Normal file
51
app/Http/Livewire/Destination/New/StandaloneDocker.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Destination\New;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker as ModelsStandaloneDocker;
|
||||
use Livewire\Component;
|
||||
|
||||
class StandaloneDocker extends Component
|
||||
{
|
||||
public string $name;
|
||||
public string $network;
|
||||
|
||||
public $servers;
|
||||
public int|null $server_id = null;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|string',
|
||||
'network' => 'required|string',
|
||||
'server_id' => 'required|integer'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->name = generateRandomName();
|
||||
$this->servers = Server::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
public function setServerId($server_id)
|
||||
{
|
||||
$this->server_id = $server_id;
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
$found = ModelsStandaloneDocker::where('server_id', $this->server_id)->where('network', $this->network)->first();
|
||||
if ($found) {
|
||||
$this->addError('network', 'Network already added to this server.');
|
||||
return;
|
||||
}
|
||||
$docker = ModelsStandaloneDocker::create([
|
||||
'name' => $this->name,
|
||||
'network' => $this->network,
|
||||
'server_id' => $this->server_id,
|
||||
'team_id' => session('currentTeam')->id
|
||||
]);
|
||||
|
||||
$server = Server::find($this->server_id);
|
||||
|
||||
runRemoteCommandSync($server, ['docker network create --attachable ' . $this->network], throwError: false);
|
||||
return redirect()->route('destination.show', $docker->uuid);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class ByIp extends Component
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->name = generateRandomName();
|
||||
$this->name = generateRandomName();
|
||||
$this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
public function setPrivateKey($private_key_id)
|
||||
|
||||
Reference in New Issue
Block a user