Merge branch 'v4-next' into patricio-deploy-proxy
This commit is contained in:
41
app/Http/Livewire/PrivateKey/Change.php
Normal file
41
app/Http/Livewire/PrivateKey/Change.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\PrivateKey;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Livewire\Component;
|
||||
|
||||
class Change extends Component
|
||||
{
|
||||
public string $private_key_uuid;
|
||||
public PrivateKey $private_key;
|
||||
|
||||
protected $rules = [
|
||||
'private_key.name' => 'required|string',
|
||||
'private_key.description' => 'nullable|string',
|
||||
'private_key.private_key' => 'required|string'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first();
|
||||
}
|
||||
public function delete($private_key_uuid)
|
||||
{
|
||||
PrivateKey::where('uuid', $private_key_uuid)->delete();
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
redirect()->route('dashboard');
|
||||
}
|
||||
public function changePrivateKey()
|
||||
{
|
||||
try {
|
||||
$this->private_key->private_key = trim($this->private_key->private_key);
|
||||
if (!str_ends_with($this->private_key->private_key, "\n")) {
|
||||
$this->private_key->private_key .= "\n";
|
||||
}
|
||||
$this->private_key->save();
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
} catch (\Exception $e) {
|
||||
$this->addError('private_key_value', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
28
app/Http/Livewire/PrivateKey/Create.php
Normal file
28
app/Http/Livewire/PrivateKey/Create.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\PrivateKey;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Livewire\Component;
|
||||
|
||||
class Create extends Component
|
||||
{
|
||||
public $private_key_value;
|
||||
public $private_key_name;
|
||||
public $private_key_description;
|
||||
public function createPrivateKey()
|
||||
{
|
||||
$this->private_key_value = trim($this->private_key_value);
|
||||
if (!str_ends_with($this->private_key_value, "\n")) {
|
||||
$this->private_key_value .= "\n";
|
||||
}
|
||||
$new_private_key = PrivateKey::create([
|
||||
'name' => $this->private_key_name,
|
||||
'description' => $this->private_key_description,
|
||||
'private_key' => $this->private_key_value,
|
||||
'team_id' => session('currentTeam')->id
|
||||
]);
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
redirect()->route('private-key.show', $new_private_key->uuid);
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,11 @@ class PublicGitRepository extends Component
|
||||
$this->parameters = Route::current()->parameters();
|
||||
$this->servers = session('currentTeam')->load(['servers'])->servers;
|
||||
}
|
||||
public function chooseServer($server_id)
|
||||
public function chooseServer($server)
|
||||
{
|
||||
$this->chosenServer = $server_id;
|
||||
$this->standalone_docker = StandaloneDocker::where('server_id', $server_id)->get();
|
||||
$this->swarm_docker = SwarmDocker::where('server_id', $server_id)->get();
|
||||
$this->chosenServer = $server;
|
||||
$this->standalone_docker = StandaloneDocker::where('server_id', $server['id'])->get();
|
||||
$this->swarm_docker = SwarmDocker::where('server_id', $server['id'])->get();
|
||||
}
|
||||
public function setDestination($destination_uuid, $destination_type)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class ByIp extends Component
|
||||
public $new_private_key_value;
|
||||
|
||||
public string $name;
|
||||
public string $description;
|
||||
public string|null $description = null;
|
||||
public string $ip;
|
||||
public string $user = 'root';
|
||||
public int $port = 22;
|
||||
@@ -29,20 +29,6 @@ class ByIp extends Component
|
||||
{
|
||||
$this->private_key_id = $private_key_id;
|
||||
}
|
||||
public function addPrivateKey()
|
||||
{
|
||||
$this->new_private_key_value = trim($this->new_private_key_value);
|
||||
if (!str_ends_with($this->new_private_key_value, "\n")) {
|
||||
$this->new_private_key_value .= "\n";
|
||||
}
|
||||
PrivateKey::create([
|
||||
'name' => $this->new_private_key_name,
|
||||
'description' => $this->new_private_key_description,
|
||||
'private_key' => $this->new_private_key_value,
|
||||
'team_id' => session('currentTeam')->id
|
||||
]);
|
||||
session('currentTeam')->privateKeys = $this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
if (!$this->private_key_id) {
|
||||
|
||||
26
app/Http/Livewire/Server/PrivateKey.php
Normal file
26
app/Http/Livewire/Server/PrivateKey.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Server;
|
||||
|
||||
use App\Models\PrivateKey as ModelsPrivateKey;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
class PrivateKey extends Component
|
||||
{
|
||||
public $private_keys;
|
||||
public $parameters;
|
||||
public function setPrivateKey($private_key_id)
|
||||
{
|
||||
Server::where('uuid', $this->parameters['server_uuid'])->update([
|
||||
'private_key_id' => $private_key_id
|
||||
]);
|
||||
return redirect()->route('server.show', $this->parameters['server_uuid']);
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = Route::current()->parameters();
|
||||
$this->private_keys = ModelsPrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user