From a0b2868e95101bd7974e8c9e4d4ef75da691d96e Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Thu, 13 Jul 2023 13:16:24 +0200
Subject: [PATCH] UI stuffs
---
.../Livewire/Project/Application/Danger.php | 3 +
.../Application/EnvironmentVariable/Add.php | 2 +
.../Application/EnvironmentVariable/All.php | 12 +-
.../Application/EnvironmentVariable/Show.php | 4 +-
.../Project/Application/Storages/Show.php | 6 +
app/Http/Livewire/Server/Form.php | 5 +-
app/View/Components/Forms/Button.php | 30 +++
app/View/Components/Forms/Checkbox.php | 34 ++++
app/View/Components/Forms/Input.php | 4 +-
app/View/Components/Forms/Select.php | 38 ++++
app/View/Components/Forms/Textarea.php | 43 ++++
app/View/Components/Modal.php | 33 ++++
package-lock.json | 15 +-
package.json | 2 +-
resources/css/app.css | 21 +-
.../components/applications/actions.blade.php | 16 +-
.../components/applications/links.blade.php | 13 +-
.../views/components/forms/button.blade.php | 54 ++---
.../views/components/forms/checkbox.blade.php | 62 +++---
.../views/components/forms/input.blade.php | 88 ++++-----
.../views/components/forms/select.blade.php | 49 ++---
.../views/components/forms/textarea.blade.php | 19 +-
.../views/components/layout-simple.blade.php | 23 +--
resources/views/components/layout.blade.php | 187 +++++++++---------
resources/views/components/modal.blade.php | 53 +++++
.../views/components/naked-modal.blade.php | 2 +-
.../livewire/private-key/change.blade.php | 2 +-
.../project/application/danger.blade.php | 13 +-
.../environment-variable/add.blade.php | 22 ++-
.../environment-variable/all.blade.php | 36 ++--
.../environment-variable/show.blade.php | 20 +-
.../project/application/previews.blade.php | 2 +-
.../project/application/source.blade.php | 27 ++-
.../application/storages/add.blade.php | 22 ++-
.../application/storages/all.blade.php | 9 +-
.../application/storages/show.blade.php | 12 +-
.../views/livewire/run-command.blade.php | 2 +-
.../views/livewire/server/form.blade.php | 14 +-
.../views/livewire/server/proxy.blade.php | 4 +-
.../livewire/server/proxy/deploy.blade.php | 15 +-
.../livewire/source/github/change.blade.php | 4 +-
.../views/livewire/team/delete.blade.php | 2 +-
tailwind.config.js | 21 +-
43 files changed, 618 insertions(+), 427 deletions(-)
create mode 100644 app/View/Components/Forms/Button.php
create mode 100644 app/View/Components/Forms/Checkbox.php
create mode 100644 app/View/Components/Forms/Select.php
create mode 100644 app/View/Components/Forms/Textarea.php
create mode 100644 app/View/Components/Modal.php
create mode 100644 resources/views/components/modal.blade.php
diff --git a/app/Http/Livewire/Project/Application/Danger.php b/app/Http/Livewire/Project/Application/Danger.php
index 72873665e..4af90927e 100644
--- a/app/Http/Livewire/Project/Application/Danger.php
+++ b/app/Http/Livewire/Project/Application/Danger.php
@@ -4,14 +4,17 @@
use App\Models\Application;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class Danger extends Component
{
public Application $application;
public array $parameters;
+ public string|null $modalId = null;
public function mount()
{
+ $this->modalId = new Cuid2(7);
$this->parameters = getRouteParameters();
}
public function delete()
diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php b/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php
index 9b1b78a00..9b35de54f 100644
--- a/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php
+++ b/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php
@@ -29,6 +29,7 @@ public function mount()
}
public function submit()
{
+ ray('submitting');
$this->validate();
$this->emitUp('submit', [
'key' => $this->key,
@@ -36,6 +37,7 @@ public function submit()
'is_build_time' => $this->is_build_time,
'is_preview' => $this->is_preview,
]);
+ $this->clear();
}
public function clear()
{
diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php b/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php
index 1dcd605cd..f1ac75917 100644
--- a/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php
+++ b/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php
@@ -5,11 +5,17 @@
use App\Models\Application;
use App\Models\EnvironmentVariable;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class All extends Component
{
public Application $application;
+ public string|null $modalId = null;
protected $listeners = ['refreshEnvs', 'submit'];
+ public function mount()
+ {
+ $this->modalId = new Cuid2(7);
+ }
public function refreshEnvs()
{
$this->application->refresh();
@@ -17,6 +23,11 @@ public function refreshEnvs()
public function submit($data)
{
try {
+ $found = $this->application->environment_variables()->where('key', $data['key'])->first();
+ if ($found) {
+ $this->emit('error', 'Environment variable already exists.');
+ return;
+ }
EnvironmentVariable::create([
'key' => $data['key'],
'value' => $data['value'],
@@ -27,7 +38,6 @@ public function submit($data)
$this->application->refresh();
$this->emit('success', 'Environment variable added successfully.');
- $this->emit('clearAddEnv');
} catch (\Exception $e) {
return general_error_handler(err: $e, that: $this);
}
diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php b/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php
index 61ecaf3de..c5260e77c 100644
--- a/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php
+++ b/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php
@@ -4,12 +4,13 @@
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class Show extends Component
{
public $parameters;
public ModelsEnvironmentVariable $env;
-
+ public string|null $modalId = null;
protected $rules = [
'env.key' => 'required|string',
'env.value' => 'required|string',
@@ -22,6 +23,7 @@ class Show extends Component
];
public function mount()
{
+ $this->modalId = new Cuid2(7);
$this->parameters = getRouteParameters();
}
public function submit()
diff --git a/app/Http/Livewire/Project/Application/Storages/Show.php b/app/Http/Livewire/Project/Application/Storages/Show.php
index 41c3c1fb8..ef6042baf 100644
--- a/app/Http/Livewire/Project/Application/Storages/Show.php
+++ b/app/Http/Livewire/Project/Application/Storages/Show.php
@@ -3,10 +3,12 @@
namespace App\Http\Livewire\Project\Application\Storages;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class Show extends Component
{
public $storage;
+ public string|null $modalId = null;
protected $rules = [
'storage.name' => 'required|string',
'storage.mount_path' => 'required|string',
@@ -17,6 +19,10 @@ class Show extends Component
'mount_path' => 'mount',
'host_path' => 'host',
];
+ public function mount()
+ {
+ $this->modalId = new Cuid2(7);
+ }
public function submit()
{
$this->validate();
diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php
index fc98c05bf..c7c056665 100644
--- a/app/Http/Livewire/Server/Form.php
+++ b/app/Http/Livewire/Server/Form.php
@@ -5,6 +5,7 @@
use App\Actions\Server\InstallDocker;
use App\Models\Server;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class Form extends Component
{
@@ -13,6 +14,7 @@ class Form extends Component
public $dockerVersion;
public string|null $wildcard_domain = null;
public int $cleanup_after_percentage;
+ public string|null $modalId = null;
protected $rules = [
'server.name' => 'required|min:6',
@@ -35,6 +37,7 @@ class Form extends Component
];
public function mount()
{
+ $this->modalId = new Cuid2(7);
$this->wildcard_domain = $this->server->settings->wildcard_domain;
$this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
}
@@ -98,4 +101,4 @@ public function submit()
$this->server->save();
$this->emit('success', 'Server updated successfully.');
}
-}
\ No newline at end of file
+}
diff --git a/app/View/Components/Forms/Button.php b/app/View/Components/Forms/Button.php
new file mode 100644
index 000000000..8621db72a
--- /dev/null
+++ b/app/View/Components/Forms/Button.php
@@ -0,0 +1,30 @@
+id)) $this->id = new Cuid2(7);
+ if (is_null($this->name)) $this->name = $this->id;
+
+ $this->label = Str::title($this->label);
+ return view('components.forms.select');
+ }
+}
diff --git a/app/View/Components/Forms/Textarea.php b/app/View/Components/Forms/Textarea.php
new file mode 100644
index 000000000..f4d1f0bee
--- /dev/null
+++ b/app/View/Components/Forms/Textarea.php
@@ -0,0 +1,43 @@
+id)) $this->id = new Cuid2(7);
+ if (is_null($this->name)) $this->name = $this->id;
+
+ $this->label = Str::title($this->label);
+ return view('components.forms.textarea');
+ }
+}
diff --git a/app/View/Components/Modal.php b/app/View/Components/Modal.php
new file mode 100644
index 000000000..b317d3c44
--- /dev/null
+++ b/app/View/Components/Modal.php
@@ -0,0 +1,33 @@
+=16.9.0"
+ },
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/daisyui"
- },
- "peerDependencies": {
- "postcss": "^8"
}
},
"node_modules/delayed-stream": {
diff --git a/package.json b/package.json
index 2884c7466..ed81d6a26 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"dependencies": {
"@tailwindcss/typography": "0.5.9",
"alpinejs": "3.12.2",
- "daisyui": "3.0.3",
+ "daisyui": "3.2.1",
"tailwindcss-scrollbar": "0.1.0"
}
}
\ No newline at end of file
diff --git a/resources/css/app.css b/resources/css/app.css
index b788c6e6d..5bca7271f 100644
--- a/resources/css/app.css
+++ b/resources/css/app.css
@@ -2,19 +2,22 @@
@tailwind components;
@tailwind utilities;
-.scrollbar {
- @apply scrollbar-thumb-coollabs-100 scrollbar-track-coolgray-200 scrollbar-w-2;
-}
html {
@apply text-neutral-400;
}
body {
@apply text-sm antialiased scrollbar;
}
+button[isError] {
+ @apply bg-red-600 hover:bg-red-500;
+}
+.scrollbar {
+ @apply scrollbar-thumb-coollabs-100 scrollbar-track-coolgray-200 scrollbar-w-2;
+}
.main {
@apply max-w-screen-xl pt-4 pl-24 pr-10 mx-auto;
}
-input {
+/* input {
@apply w-full text-white rounded outline-none input input-sm h-7 placeholder:text-neutral-700 bg-coolgray-200 read-only:bg-coolgray-200/50 read-only:text-opacity-25;
}
input:not(input[type="checkbox"]) {
@@ -22,14 +25,14 @@ input:not(input[type="checkbox"]) {
}
input[type="checkbox"] {
@apply rounded toggle toggle-warning toggle-xs disabled:toggle-warning;
-}
+} */
-textarea {
+/* textarea {
@apply text-xs leading-5 text-white rounded textarea read-only:bg-coolgray-200/50 disabled:border-none read-only:text-opacity-25 placeholder:text-neutral-700 scrollbar bg-coolgray-200;
}
select {
@apply font-normal text-white border-none rounded h-7 select select-xs disabled:bg-coolgray-200 disabled:opacity-50 placeholder:text-neutral-700 bg-coolgray-200;
-}
+} */
.label-text,
label {
@apply text-neutral-400;
@@ -39,12 +42,12 @@ .loading {
@apply w-4 text-warning;
}
-button[isWarning] {
+/* button[isWarning] {
@apply bg-red-600 hover:bg-red-500;
}
button[isHighlighted] {
@apply text-white btn-primary;
-}
+} */
h1 {
@apply text-3xl font-bold text-white;
}
diff --git a/resources/views/components/applications/actions.blade.php b/resources/views/components/applications/actions.blade.php
index 141a9b151..fe5b235fc 100644
--- a/resources/views/components/applications/actions.blade.php
+++ b/resources/views/components/applications/actions.blade.php
@@ -8,7 +8,7 @@
class="relative text-xs text-white normal-case rounded -ml-44 min-w-max menu bg-coolgray-200">
@if ($application->status === 'running')
-
-
+
@@ -35,7 +35,7 @@ class="relative text-xs text-white normal-case rounded -ml-44 min-w-max menu bg-
-
@@ -49,7 +49,7 @@ class="relative text-xs text-white normal-case rounded -ml-44 min-w-max menu bg-
@else
-
@@ -60,7 +60,7 @@ class="relative text-xs text-white normal-case rounded -ml-44 min-w-max menu bg-
-
diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php
index 4a8e14672..b410cf0e1 100644
--- a/resources/views/components/applications/links.blade.php
+++ b/resources/views/components/applications/links.blade.php
@@ -6,7 +6,8 @@
@livewireScripts
@auth
-
-
-
-
-
-
- {{ $slot }}
-
-
-
+ function revive() {
+ if (checkHealthInterval) return true;
+ console.log('Checking server\'s health...')
+ checkHealthInterval = setInterval(() => {
+ fetch('/api/health')
+ .then(response => {
+ if (response.ok) {
+ Toaster.success('Coolify is back online. Reloading...')
+ if (checkHealthInterval) clearInterval(checkHealthInterval);
+ setTimeout(() => {
+ window.location.reload();
+ }, 5000)
+ } else {
+ console.log('Waiting for server to come back from dead...');
+ }
+ })
+ return;
+ }, 2000);
+ }
+
+ function upgrade() {
+ if (checkIfIamDeadInterval) return true;
+ console.log('Update initiated.')
+ checkIfIamDeadInterval = setInterval(() => {
+ fetch('/api/health')
+ .then(response => {
+ if (response.ok) {
+ console.log('It\'s alive. Waiting for server to be dead...');
+ } else {
+ Toaster.success('Update done, restarting Coolify!')
+ console.log('It\'s dead. Reviving... Standby... Bzz... Bzz...')
+ if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
+ revive();
+ }
+ })
+ return;
+ }, 2000);
+ }
+
+ function copyToClipboard(text) {
+ navigator.clipboard.writeText(text);
+ Livewire.emit('message', 'Copied to clipboard.');
+ }
+ Livewire.on('reloadWindow', () => {
+ window.location.reload();
+ })
+ Livewire.on('info', (message) => {
+ if (message) Toaster.info(message)
+ })
+ Livewire.on('error', (message) => {
+ if (message) Toaster.error(message)
+ })
+ Livewire.on('warning', (message) => {
+ if (message) Toaster.warning(message)
+ })
+ Livewire.on('success', (message) => {
+ if (message) Toaster.success(message)
+ })
+
@endauth
@guest
- {{ $slot }}
+ {{ $slot }}
@endguest