mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
init
This commit is contained in:
31
app/Http/Livewire/SshKeys/AddKey.php
Normal file
31
app/Http/Livewire/SshKeys/AddKey.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SshKeys;
|
||||
|
||||
use App\Actions\SshKey\CreateSshKey;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddKey extends Component
|
||||
{
|
||||
public string $name;
|
||||
|
||||
public string $public_key;
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
app(CreateSshKey::class)->create(
|
||||
auth()->user(),
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->emitTo(KeysList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.ssh-keys.add-key');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/SshKeys/KeysList.php
Normal file
37
app/Http/Livewire/SshKeys/KeysList.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SshKeys;
|
||||
|
||||
use App\Models\SshKey;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class KeysList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$key = SshKey::query()->findOrFail($this->deleteId);
|
||||
|
||||
$key->delete();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.ssh-keys.keys-list', [
|
||||
'keys' => SshKey::query()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user