sprinkle some css
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Component;
|
||||
|
||||
class CheckUpdate extends Component
|
||||
|
||||
@@ -27,7 +27,9 @@ class StandaloneDocker extends Component
|
||||
if (request()->query('server_id')) {
|
||||
$this->server_id = request()->query('server_id');
|
||||
} else {
|
||||
$this->server_id = Server::validated()->first()->id;
|
||||
if ($this->servers->count() > 0) {
|
||||
$this->server_id = $this->servers->first()->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->network = new Cuid2(7);
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
namespace App\Http\Livewire\PrivateKey;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Illuminate\Routing\Route as RoutingRoute;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
class Create extends Component
|
||||
{
|
||||
public $private_key_value;
|
||||
public $private_key_name;
|
||||
public $private_key_description;
|
||||
public string $name;
|
||||
public string|null $description;
|
||||
public string $value;
|
||||
public string $currentRoute;
|
||||
|
||||
public function mount()
|
||||
@@ -20,14 +19,14 @@ class Create extends Component
|
||||
}
|
||||
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";
|
||||
$this->value = trim($this->value);
|
||||
if (!str_ends_with($this->value, "\n")) {
|
||||
$this->value .= "\n";
|
||||
}
|
||||
$new_private_key = PrivateKey::create([
|
||||
'name' => $this->private_key_name,
|
||||
'description' => $this->private_key_description,
|
||||
'private_key' => $this->private_key_value,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'private_key' => $this->value,
|
||||
'team_id' => session('currentTeam')->id
|
||||
]);
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
|
||||
@@ -8,7 +8,7 @@ use Livewire\Component;
|
||||
|
||||
class RunCommand extends Component
|
||||
{
|
||||
public $command;
|
||||
public string $command;
|
||||
public $server;
|
||||
public $servers = [];
|
||||
|
||||
@@ -16,16 +16,20 @@ class RunCommand extends Component
|
||||
'server' => 'required',
|
||||
'command' => 'required',
|
||||
];
|
||||
public function mount()
|
||||
public function mount($servers)
|
||||
{
|
||||
$this->servers = Server::where('team_id', session('currentTeam')->id)->get();
|
||||
$this->server = $this->servers[0]->uuid;
|
||||
$this->servers = $servers;
|
||||
$this->server = $servers[0]->uuid;
|
||||
}
|
||||
|
||||
public function runCommand()
|
||||
{
|
||||
$this->validate();
|
||||
$activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value);
|
||||
$this->emit('newMonitorActivity', $activity->id);
|
||||
try {
|
||||
$this->validate();
|
||||
$activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value);
|
||||
$this->emit('newMonitorActivity', $activity->id);
|
||||
} catch (\Exception $e) {
|
||||
return generalErrorHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user