From 8b7e1e41694d69f0571366fdcfa870072c8eaeac Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 22 Mar 2024 11:34:15 +0100 Subject: [PATCH] Refactor code and update UI components --- README.md | 1 + app/Livewire/ActivityMonitor.php | 1 + app/Livewire/Destination/New/Docker.php | 7 +- app/Livewire/Destination/Show.php | 38 +++ app/Livewire/LayoutPopups.php | 8 - app/Livewire/Project/Index.php | 3 + app/Livewire/Project/Service/Navbar.php | 2 +- .../Service/ServiceApplicationView.php | 2 +- app/Livewire/Server/New/ByIp.php | 2 +- app/Livewire/Settings/License.php | 2 +- app/Models/Team.php | 3 - app/View/Components/Forms/Button.php | 1 - ...3_22_080914_remove_popup_notifications.php | 30 +++ resources/css/app.css | 4 +- resources/views/auth/login.blade.php | 6 +- .../components/applications/links.blade.php | 8 +- resources/views/components/banner.blade.php | 2 +- .../views/components/forms/button.blade.php | 10 +- .../views/components/forms/input.blade.php | 15 +- .../components/modal-confirmation.blade.php | 37 ++- .../views/components/navbar-old.blade.php | 216 ------------------ resources/views/components/navbar.blade.php | 15 +- resources/views/components/popup.blade.php | 11 +- .../views/components/services/links.blade.php | 6 +- resources/views/components/toast.blade.php | 5 +- resources/views/components/version.blade.php | 2 +- resources/views/destination/all.blade.php | 15 +- resources/views/destination/new.blade.php | 3 - resources/views/layouts/app.blade.php | 2 +- resources/views/layouts/base.blade.php | 9 +- .../views/livewire/activity-monitor.blade.php | 2 +- resources/views/livewire/dashboard.blade.php | 194 ++++++++-------- .../livewire/destination/new/docker.blade.php | 18 +- .../views/livewire/destination/show.blade.php | 29 +-- .../views/livewire/layout-popups.blade.php | 68 ++++-- .../project/application/heading.blade.php | 20 +- .../project/database/init-script.blade.php | 20 +- .../database/postgresql/general.blade.php | 16 +- .../views/livewire/project/index.blade.php | 76 +++--- .../livewire/project/new/select.blade.php | 40 +--- .../project/service/storage.blade.php | 1 - .../shared/environment-variable/add.blade.php | 7 +- .../shared/environment-variable/all.blade.php | 2 +- .../environment-variable/show.blade.php | 83 +++---- .../execute-container-command.blade.php | 4 +- .../livewire/subscription/index.blade.php | 44 ++-- resources/views/source/all.blade.php | 2 +- routes/web.php | 27 ++- templates/compose/shlink.yaml | 31 +++ templates/compose/slash.yaml | 17 ++ templates/service-templates.json | 34 +++ 51 files changed, 592 insertions(+), 609 deletions(-) create mode 100644 database/migrations/2024_03_22_080914_remove_popup_notifications.php delete mode 100644 resources/views/components/navbar-old.blade.php delete mode 100644 resources/views/destination/new.blade.php create mode 100644 templates/compose/shlink.yaml create mode 100644 templates/compose/slash.yaml diff --git a/README.md b/README.md index 6e6d80c59..3a211d4b1 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ ## Github Sponsors ($40+) CryptoJobsList typebot BC Direct +UXWizz Corentin Clichy Corentin Clichy Niklas Lausch diff --git a/app/Livewire/ActivityMonitor.php b/app/Livewire/ActivityMonitor.php index ad2a599a1..421992cb5 100644 --- a/app/Livewire/ActivityMonitor.php +++ b/app/Livewire/ActivityMonitor.php @@ -13,6 +13,7 @@ class ActivityMonitor extends Component public $activityId; public $eventToDispatch = 'activityFinished'; public $isPollingActive = false; + public bool $showWaiting = false; protected $activity; protected $listeners = ['activityMonitor' => 'newMonitorActivity']; diff --git a/app/Livewire/Destination/New/Docker.php b/app/Livewire/Destination/New/Docker.php index 66d0df82e..842a44683 100644 --- a/app/Livewire/Destination/New/Docker.php +++ b/app/Livewire/Destination/New/Docker.php @@ -5,7 +5,7 @@ use App\Models\Server; use App\Models\StandaloneDocker as ModelsStandaloneDocker; use App\Models\SwarmDocker; -use Illuminate\Database\Eloquent\Collection; +use Illuminate\Support\Collection; use Livewire\Component; use Visus\Cuid2\Cuid2; @@ -14,7 +14,7 @@ class Docker extends Component public string $name; public string $network; - public Collection $servers; + public ?Collection $servers = null; public Server $server; public ?int $server_id = null; public bool $is_swarm = false; @@ -34,6 +34,9 @@ class Docker extends Component public function mount() { + if (is_null($this->servers)) { + $this->servers = Server::ownedByCurrentTeam()->get(); + } if (request()->query('server_id')) { $this->server_id = request()->query('server_id'); } else { diff --git a/app/Livewire/Destination/Show.php b/app/Livewire/Destination/Show.php index b9cbcc147..4b763bae2 100644 --- a/app/Livewire/Destination/Show.php +++ b/app/Livewire/Destination/Show.php @@ -3,6 +3,8 @@ namespace App\Livewire\Destination; use App\Models\Server; +use App\Models\StandaloneDocker; +use App\Models\SwarmDocker; use Illuminate\Support\Collection; use Livewire\Component; @@ -11,6 +13,40 @@ class Show extends Component public Server $server; public Collection|array $networks = []; + private function createNetworkAndAttachToProxy() + { + $connectProxyToDockerNetworks = connectProxyToNetworks($this->server); + instant_remote_process($connectProxyToDockerNetworks, $this->server, false); + } + public function add($name) + { + if ($this->server->isSwarm()) { + $found = $this->server->swarmDockers()->where('network', $name)->first(); + if ($found) { + $this->dispatch('error', 'Network already added to this server.'); + return; + } else { + $docker = SwarmDocker::create([ + 'name' => $this->server->name . "-" . $name, + 'network' => $this->name, + 'server_id' => $this->server->id, + ]); + } + } else { + $found = $this->server->standaloneDockers()->where('network', $name)->first(); + if ($found) { + $this->dispatch('error', 'Network already added to this server.'); + return; + } else { + $docker = StandaloneDocker::create([ + 'name' => $this->server->name . "-" . $name, + 'network' => $name, + 'server_id' => $this->server->id, + ]); + } + $this->createNetworkAndAttachToProxy(); + } + } public function scan() { if ($this->server->isSwarm()) { @@ -26,6 +62,8 @@ public function scan() }); if ($this->networks->count() === 0) { $this->dispatch('success', 'No new networks found.'); + return; } + $this->dispatch('success', 'Scan done.'); } } diff --git a/app/Livewire/LayoutPopups.php b/app/Livewire/LayoutPopups.php index b6f06f808..136c94ca2 100644 --- a/app/Livewire/LayoutPopups.php +++ b/app/Livewire/LayoutPopups.php @@ -17,14 +17,6 @@ public function testEvent() { $this->dispatch('success', 'Realtime events configured!'); } - public function disableSponsorship() - { - auth()->user()->update(['is_notification_sponsorship_enabled' => false]); - } - public function disableNotifications() - { - auth()->user()->update(['is_notification_notifications_enabled' => false]); - } public function render() { return view('livewire.layout-popups'); diff --git a/app/Livewire/Project/Index.php b/app/Livewire/Project/Index.php index 1e6f79855..0537ad192 100644 --- a/app/Livewire/Project/Index.php +++ b/app/Livewire/Project/Index.php @@ -2,6 +2,7 @@ namespace App\Livewire\Project; +use App\Models\PrivateKey; use App\Models\Project; use App\Models\Server; use Livewire\Component; @@ -10,7 +11,9 @@ class Index extends Component { public $projects; public $servers; + public $private_keys; public function mount() { + $this->private_keys = PrivateKey::ownedByCurrentTeam()->get(); $this->projects = Project::ownedByCurrentTeam()->get(); $this->servers = Server::ownedByCurrentTeam()->count(); } diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 02211b20a..3462a96e1 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -26,7 +26,7 @@ public function getListeners() ]; } public function serviceStarted() { - $this->dispatch('success', 'Service started.'); + $this->dispatch('success', 'Service status changed.'); } public function serviceStatusChanged() { diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php index 29bd796fd..0b3a4cef6 100644 --- a/app/Livewire/Project/Service/ServiceApplicationView.php +++ b/app/Livewire/Project/Service/ServiceApplicationView.php @@ -59,7 +59,7 @@ public function submit() $this->validate(); $this->application->save(); updateCompose($this->application); - $this->dispatch('success', 'Application saved.'); + $this->dispatch('success', 'Service saved.'); } catch (\Throwable $e) { return handleError($e, $this); } finally { diff --git a/app/Livewire/Server/New/ByIp.php b/app/Livewire/Server/New/ByIp.php index df3fae20f..1ce3df273 100644 --- a/app/Livewire/Server/New/ByIp.php +++ b/app/Livewire/Server/New/ByIp.php @@ -53,7 +53,7 @@ class ByIp extends Component public function mount() { $this->name = generate_random_name(); - $this->private_key_id = $this->private_keys->first()->id; + $this->private_key_id = $this->private_keys->first()?->id; $this->swarm_managers = Server::isUsable()->get()->where('settings.is_swarm_manager', true); if ($this->swarm_managers->count() > 0) { $this->selected_swarm_cluster = $this->swarm_managers->first()->id; diff --git a/app/Livewire/Settings/License.php b/app/Livewire/Settings/License.php index 64ad0a6f7..e2ae5fcf7 100644 --- a/app/Livewire/Settings/License.php +++ b/app/Livewire/Settings/License.php @@ -30,7 +30,7 @@ public function mount () { } public function render() { - return view('livewire.settings.license')->layout('layouts.subscription'); + return view('livewire.settings.license'); } public function submit() { diff --git a/app/Models/Team.php b/app/Models/Team.php index 7cb1601de..a3dd4e473 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -177,9 +177,6 @@ public function isAnyNotificationEnabled() if (isCloud()) { return true; } - if (!data_get(auth()->user(), 'is_notification_notifications_enabled')) { - return true; - } if ($this->smtp_enabled || $this->resend_enabled || $this->discord_enabled || $this->telegram_enabled || $this->use_instance_email_settings) { return true; } diff --git a/app/View/Components/Forms/Button.php b/app/View/Components/Forms/Button.php index 350039fce..06681910e 100644 --- a/app/View/Components/Forms/Button.php +++ b/app/View/Components/Forms/Button.php @@ -13,7 +13,6 @@ class Button extends Component */ public function __construct( public bool $disabled = false, - public bool $isModal = false, public bool $noStyle = false, public ?string $modalId = null, public string $defaultClass = "button" diff --git a/database/migrations/2024_03_22_080914_remove_popup_notifications.php b/database/migrations/2024_03_22_080914_remove_popup_notifications.php new file mode 100644 index 000000000..ccb270093 --- /dev/null +++ b/database/migrations/2024_03_22_080914_remove_popup_notifications.php @@ -0,0 +1,30 @@ +dropColumn('is_notification_sponsorship_enabled'); + $table->dropColumn('is_notification_notifications_enabled'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->boolean('is_notification_sponsorship_enabled')->default(true); + $table->boolean('is_notification_notifications_enabled')->default(true); + }); + } +}; diff --git a/resources/css/app.css b/resources/css/app.css index a3fc32386..d3ac514e6 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -84,7 +84,7 @@ input { } .input { - @apply block w-full py-1.5 rounded border-0 text-sm ring-inset ring-1 dark:bg-coolgray-100 dark:text-white text-black focus:ring-2 dark:focus:ring-coolgray-300 dark:ring-coolgray-300 dark:read-only:text-neutral-500 dark:read-only:ring-0 dark:read-only:bg-coolgray-100/40 dark:placeholder:text-neutral-700; + @apply block w-full py-1.5 pr-[2.8rem] rounded border-0 text-sm ring-inset ring-1 dark:bg-coolgray-100 dark:text-white text-black focus:ring-2 dark:focus:ring-coolgray-300 dark:ring-coolgray-300 dark:read-only:text-neutral-500 dark:read-only:ring-0 dark:read-only:bg-coolgray-100/40 dark:placeholder:text-neutral-700; } option { @@ -100,7 +100,7 @@ .alert-error { } .dropdown-item { - @apply relative flex cursor-pointer select-none dark:hover:text-white dark:hover:bg-coollabs items-center pr-4 pl-2 py-1 text-xs justify-center outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 gap-2 w-full; + @apply relative flex cursor-pointer select-none dark:text-white dark:hover:bg-coollabs items-center pr-4 pl-2 py-1 text-xs justify-start outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 gap-2 w-full; } .badge { diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 919765f6c..82ea5062b 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -5,7 +5,7 @@ Coolify
+ class="w-full bg-white shadow md:mt-0 sm:max-w-md xl:p-0 dark:bg-base ">
@csrf @@ -15,6 +15,7 @@ class="w-full bg-white rounded shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dar + {{ __('auth.forgot_password') }}? @@ -28,8 +29,7 @@ class="w-full bg-white rounded shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dar @endenv {{ __('auth.login') }} @if ($is_registration_enabled) - + {{ __('auth.register_now') }} @endif diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php index dc067dfe6..bd82f75a1 100644 --- a/resources/views/components/applications/links.blade.php +++ b/resources/views/components/applications/links.blade.php @@ -3,15 +3,15 @@ }" class="relative" @click.outside="dropdownOpen = false">
+ class="relative z-[999] w-full py-2 mx-auto duration-100 ease-out shadow-sm bg-coolgray-100 sm:py-0 sm:h-14" x-cloak>
{{ $slot }} @if ($closable) diff --git a/resources/views/components/forms/button.blade.php b/resources/views/components/forms/button.blade.php index f1c869217..f91a53b77 100644 --- a/resources/views/components/forms/button.blade.php +++ b/resources/views/components/forms/button.blade.php @@ -6,14 +6,10 @@ @isset($confirmAction) x-on:{{ explode('(', $confirmAction)[0] }}.window="$wire.{{ explode('(', $confirmAction)[0] }}" @endisset - @if ($isModal) onclick="{{ $modalId }}.showModal()" @endif> + > {{ $slot }} - @if ($attributes->get('type') === 'submit') - - @else - @if ($attributes->whereStartsWith('wire:click')->first()) - - @endif + @if ($attributes->whereStartsWith('wire:click')->first() && $attributes->get('type') === 'submit') + @endif diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index 11d1cf0db..8f4c38edf 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -25,12 +25,12 @@ class="absolute inset-y-0 right-0 flex items-center pr-2 cursor-pointer hover:te
@endif - merge(['class' => $defaultClass]) }} @required($required) + merge(['class' => $defaultClass]) }} @required($required) @if ($id !== 'null') wire:model={{ $id }} @endif - wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' wire:dirty.class="dark:focus:ring-warning dark:ring-warning" - wire:loading.attr="disabled" type="{{ $type }}" @readonly($readonly) @disabled($disabled) - id="{{ $id }}" name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}" + wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' + wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" + type="{{ $type }}" @readonly($readonly) @disabled($disabled) id="{{ $id }}" + name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}" aria-placeholder="{{ $attributes->get('placeholder') }}">
@@ -38,8 +38,9 @@ class="absolute inset-y-0 right-0 flex items-center pr-2 cursor-pointer hover:te merge(['class' => $defaultClass]) }} @required($required) @readonly($readonly) @if ($id !== 'null') wire:model={{ $id }} @endif - wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' wire:dirty.class="dark:focus:ring-warning dark:ring-warning" - wire:loading.attr="disabled" type="{{ $type }}" @disabled($disabled) + wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' + wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" + type="{{ $type }}" @disabled($disabled) @if ($id !== 'null') id={{ $id }} @endif name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}"> @endif diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php index 9652edbc7..e4ac66c17 100644 --- a/resources/views/components/modal-confirmation.blade.php +++ b/resources/views/components/modal-confirmation.blade.php @@ -2,6 +2,7 @@ 'title' => 'Are you sure?', 'buttonTitle' => 'Open Modal', 'isErrorButton' => false, + 'buttonFullWidth' => false, 'disabled' => false, 'action' => 'delete', 'content' => null, @@ -14,17 +15,35 @@ class="relative w-auto h-auto">
@else @if ($disabled) - - {{ $buttonTitle }} - + @if ($buttonFullWidth) + + {{ $buttonTitle }} + + @else + + {{ $buttonTitle }} + + @endif @elseif ($isErrorButton) - - {{ $buttonTitle }} - + @if ($buttonFullWidth) + + {{ $buttonTitle }} + + @else + + {{ $buttonTitle }} + + @endif @else - - {{ $buttonTitle }} - + @if ($buttonFullWidth) + + {{ $buttonTitle }} + + @else + + {{ $buttonTitle }} + + @endif @endif @endif