From d6dc540236f75ce7f6ba6e4163aac3947db94be4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 12 May 2023 15:39:07 +0200 Subject: [PATCH] sprinkle some css --- app/Http/Livewire/CheckUpdate.php | 2 - .../Destination/New/StandaloneDocker.php | 4 +- app/Http/Livewire/PrivateKey/Create.php | 19 ++-- app/Http/Livewire/RunCommand.php | 18 +-- app/Http/Livewire/Server/New/ByIp.php | 40 ++++--- bootstrap/helpers.php | 2 +- resources/css/app.css | 29 +++-- resources/views/command-center.blade.php | 2 +- .../views/components/inputs/button.blade.php | 8 +- .../views/components/inputs/input.blade.php | 7 +- resources/views/components/layout.blade.php | 4 +- .../views/components/magic-bar.blade.php | 104 +++++++++++------- resources/views/components/navbar.blade.php | 26 +++-- resources/views/dashboard.blade.php | 84 +++++++++----- .../views/livewire/activity-monitor.blade.php | 15 +-- .../livewire/private-key/create.blade.php | 12 +- .../views/livewire/run-command.blade.php | 8 +- .../views/livewire/server/new/by-ip.blade.php | 43 ++++---- resources/views/server/new.blade.php | 1 - routes/web.php | 8 +- tailwind.config.js | 24 +++- 21 files changed, 285 insertions(+), 175 deletions(-) diff --git a/app/Http/Livewire/CheckUpdate.php b/app/Http/Livewire/CheckUpdate.php index 1d947a2e3..6330852c0 100644 --- a/app/Http/Livewire/CheckUpdate.php +++ b/app/Http/Livewire/CheckUpdate.php @@ -2,8 +2,6 @@ namespace App\Http\Livewire; -use App\Models\Server; -use Illuminate\Support\Facades\Http; use Livewire\Component; class CheckUpdate extends Component diff --git a/app/Http/Livewire/Destination/New/StandaloneDocker.php b/app/Http/Livewire/Destination/New/StandaloneDocker.php index 29f775593..96625eba8 100644 --- a/app/Http/Livewire/Destination/New/StandaloneDocker.php +++ b/app/Http/Livewire/Destination/New/StandaloneDocker.php @@ -27,7 +27,9 @@ public function mount() 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); diff --git a/app/Http/Livewire/PrivateKey/Create.php b/app/Http/Livewire/PrivateKey/Create.php index b888a2122..5ae62c8f7 100644 --- a/app/Http/Livewire/PrivateKey/Create.php +++ b/app/Http/Livewire/PrivateKey/Create.php @@ -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 @@ public function mount() } 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(); diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index c83a83084..55be8fe23 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -8,7 +8,7 @@ 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); + } } } diff --git a/app/Http/Livewire/Server/New/ByIp.php b/app/Http/Livewire/Server/New/ByIp.php index baf638a2f..4f079c7ba 100644 --- a/app/Http/Livewire/Server/New/ByIp.php +++ b/app/Http/Livewire/Server/New/ByIp.php @@ -9,7 +9,7 @@ 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); } } diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index ce9e46753..546ef6604 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -40,7 +40,7 @@ function generalErrorHandler(\Throwable $e, $that = null, $isJson = false) 'error' => $error->getMessage(), ]); } else { - dump('Duplicate entry found.'); + dump($error); } } } diff --git a/resources/css/app.css b/resources/css/app.css index a67e25917..7781ba274 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,35 +1,33 @@ -/* @tailwind base; */ +@tailwind base; @tailwind components; @tailwind utilities; body { - @apply bg-neutral-900 text-white font-sans; -} -a, a:visited { - @apply text-neutral-300 hover:text-purple-500; + @apply bg-coolgray-100 text-white font-sans; } + input, textarea { - @apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none + @apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none outline-none ; } select { - @apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600 read-only:select-none + @apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:select-none outline-none; } button { @apply border-none px-2 p-1 cursor-pointer; } .main-menu { - @apply relative float-left ; + @apply relative float-left; } .main-menu:after { content: '/'; - @apply absolute right-0 top-0 text-neutral-400 px-2 pt-1; + @apply absolute right-0 top-0 text-neutral-400 px-2 pt-[0.3rem]; } .magic-input { - @apply w-96 rounded shadow outline-none focus:bg-neutral-700; + @apply w-[25rem] rounded shadow outline-none focus:bg-neutral-700 text-white; } .magic-items { - @apply text-xs absolute top-11 w-[25rem] bg-neutral-800; + @apply absolute top-14 w-[25rem] bg-coolgray-200 border-b-2 border-r-2 border-l-2 border-solid border-coolgray-100 rounded-b; } .magic-item { @apply m-2 py-2 pl-4 cursor-pointer hover:bg-neutral-700 text-neutral-300 hover:text-white; @@ -37,3 +35,12 @@ .magic-item { .magic-item-focused { @apply bg-neutral-700 text-white; } +h1 { + @apply text-3xl font-bold py-4; +} +h2 { + @apply text-xl font-bold py-4; +} +.box { + @apply flex items-center justify-center text-sm rounded cursor-pointer h-14 bg-coolgray-200 hover:bg-coollabs p-2; +} diff --git a/resources/views/command-center.blade.php b/resources/views/command-center.blade.php index 52b434ae9..d603589e9 100644 --- a/resources/views/command-center.blade.php +++ b/resources/views/command-center.blade.php @@ -1,3 +1,3 @@ - + diff --git a/resources/views/components/inputs/button.blade.php b/resources/views/components/inputs/button.blade.php index db2314256..f1b42b1e3 100644 --- a/resources/views/components/inputs/button.blade.php +++ b/resources/views/components/inputs/button.blade.php @@ -1,10 +1,10 @@ @props([ 'isWarning' => null, 'disabled' => null, - 'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 h-8', - 'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8', - 'disabledClass' => 'text-neutral-400 bg-neutral-900 h-8', - 'loadingClass' => 'text-black bg-green-500 h-8', + 'defaultClass' => 'text-white hover:bg-coollabs h-8 rounded transition-colors', + 'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8 rounded', + 'disabledClass' => 'text-coolgray-200 h-8 rounded', + 'loadingClass' => 'text-black bg-green-500 h-8 rounded', 'confirm' => null, 'confirmAction' => null, ]) diff --git a/resources/views/components/inputs/input.blade.php b/resources/views/components/inputs/input.blade.php index 049a7eaeb..64735c542 100644 --- a/resources/views/components/inputs/input.blade.php +++ b/resources/views/components/inputs/input.blade.php @@ -6,6 +6,7 @@ 'instantSave' => $attributes->has('instantSave'), 'noLabel' => $attributes->has('noLabel'), 'noDirty' => $attributes->has('noDirty'), + 'hidden' => $attributes->has('hidden'), ]) @if (!$noLabel) @endif @if ($type === 'textarea') @@ -32,7 +34,8 @@ + @if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif + @if ($hidden) class="hidden" @endif /> @endif @error($id)
{{ $message }}
diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index 08f2d2cc0..da3cf8b3d 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -4,6 +4,8 @@ + + @env('local') Coolify - localhost @endenv @@ -28,7 +30,7 @@ class="fixed text-xs cursor-pointer left-2 bottom-1 opacity-20 hover:opacity-100 @auth @endauth -
+
{{ $slot }}
diff --git a/resources/views/components/magic-bar.blade.php b/resources/views/components/magic-bar.blade.php index 08d1d1482..f657edb97 100644 --- a/resources/views/components/magic-bar.blade.php +++ b/resources/views/components/magic-bar.blade.php @@ -1,4 +1,4 @@ -
+
{{-- Main --}}