wip
This commit is contained in:
@@ -20,10 +20,11 @@ class Form extends Component
|
||||
'server.ip' => 'required',
|
||||
'server.user' => 'required',
|
||||
'server.port' => 'required',
|
||||
'server.settings.is_validated' => 'required'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->server = Server::find($this->server_id);
|
||||
$this->server = Server::find($this->server_id)->load(['settings']);
|
||||
}
|
||||
public function installDocker()
|
||||
{
|
||||
@@ -38,6 +39,11 @@ class Form extends Component
|
||||
if (!$this->uptime) {
|
||||
$this->uptime = 'Server not reachable.';
|
||||
throw new \Exception('Server not reachable.');
|
||||
} else {
|
||||
if (!$this->server->settings->is_validated) {
|
||||
$this->server->settings->is_validated = true;
|
||||
$this->server->settings->save();
|
||||
}
|
||||
}
|
||||
$this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false);
|
||||
if (!$this->dockerVersion) {
|
||||
@@ -48,6 +54,7 @@ class Form extends Component
|
||||
$this->dockerComposeVersion = 'Not installed.';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return generalErrorHandler($e, $this);
|
||||
}
|
||||
}
|
||||
public function delete()
|
||||
|
||||
@@ -9,7 +9,7 @@ use Livewire\Component;
|
||||
class ByIp extends Component
|
||||
{
|
||||
public $private_keys;
|
||||
public int $private_key_id;
|
||||
public int|null $private_key_id = null;
|
||||
public $new_private_key_name;
|
||||
public $new_private_key_description;
|
||||
public $new_private_key_value;
|
||||
@@ -20,30 +20,40 @@ class ByIp extends Component
|
||||
public string $user = 'root';
|
||||
public int $port = 22;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required',
|
||||
'ip' => 'required',
|
||||
'user' => 'required',
|
||||
'port' => 'required|integer',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->name = generateRandomName();
|
||||
$this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
public function setPrivateKey($private_key_id)
|
||||
public function setPrivateKey(string $private_key_id)
|
||||
{
|
||||
$this->private_key_id = $private_key_id;
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
if (!$this->private_key_id) {
|
||||
$this->addError('private_key_id', 'The private key field is required.');
|
||||
return;
|
||||
try {
|
||||
if (!$this->private_key_id) {
|
||||
return $this->emit('error', 'You must select a private key');
|
||||
}
|
||||
$this->validate();
|
||||
$server = Server::create([
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'ip' => $this->ip,
|
||||
'user' => $this->user,
|
||||
'port' => $this->port,
|
||||
'team_id' => session('currentTeam')->id,
|
||||
'private_key_id' => $this->private_key_id
|
||||
]);
|
||||
return redirect()->route('server.show', $server->uuid);
|
||||
} catch (\Exception $e) {
|
||||
return generalErrorHandler($e);
|
||||
}
|
||||
$server = Server::create([
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'ip' => $this->ip,
|
||||
'user' => $this->user,
|
||||
'port' => $this->port,
|
||||
'team_id' => session('currentTeam')->id,
|
||||
'private_key_id' => $this->private_key_id
|
||||
]);
|
||||
return redirect()->route('server.show', $server->uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class PrivateKey extends Component
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = Route::current()->parameters();
|
||||
$this->parameters = getParameters();
|
||||
$this->private_keys = ModelsPrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user