Skip to content

Commit

Permalink
Refactor code and update UI components
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Mar 22, 2024
1 parent ca9a2cb commit 8b7e1e4
Show file tree
Hide file tree
Showing 51 changed files with 589 additions and 606 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Special thanks to our biggest sponsors, [CCCareers](https://cccareers.org/) and
<a href="https://cryptojobslist.com/?utm_source=coolify.io"><img src="https://github.com/cryptojobslist.png" width="60px" alt="CryptoJobsList" /></a>
<a href="https://typebot.io/?utm_source=coolify.io"><img src="https://pbs.twimg.com/profile_images/1509194008366657543/9I-C7uWT_400x400.jpg" width="60px" alt="typebot"/></a>
<a href="https://bc.direct"><img width="60px" alt="BC Direct" src="https://github.com/coollabsio/coolify/assets/5845193/a4063c41-95ed-4a32-8814-cd1475572e37"/></a>
<a href="https://www.uxwizz.com/?utm_source=coolify.io"><img width="60px" alt="UXWizz" src="https://github.com/UXWizz.png"/></a>
<a href="https://github.com/automazeio"><img src="https://github.com/automazeio.png" width="60px" alt="Corentin Clichy" /></a>
<a href="https://github.com/corentinclichy"><img src="https://github.com/corentinclichy.png" width="60px" alt="Corentin Clichy" /></a>
<a href="https://github.com/Niki2k1"><img src="https://github.com/Niki2k1.png" width="60px" alt="Niklas Lausch" /></a>
Expand Down
1 change: 1 addition & 0 deletions app/Livewire/ActivityMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
7 changes: 5 additions & 2 deletions app/Livewire/Destination/New/Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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 {
Expand Down
38 changes: 38 additions & 0 deletions app/Livewire/Destination/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()) {
Expand All @@ -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.');
}
}
8 changes: 0 additions & 8 deletions app/Livewire/LayoutPopups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 3 additions & 0 deletions app/Livewire/Project/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Livewire\Project;

use App\Models\PrivateKey;
use App\Models\Project;
use App\Models\Server;
use Livewire\Component;
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Project/Service/Navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getListeners()
];
}
public function serviceStarted() {
$this->dispatch('success', 'Service started.');
$this->dispatch('success', 'Service status changed.');
}
public function serviceStatusChanged()
{
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Project/Service/ServiceApplicationView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Server/New/ByIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Settings/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
3 changes: 0 additions & 3 deletions app/Models/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion app/View/Components/Forms/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->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);
});
}
};
4 changes: 2 additions & 2 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -100,7 +100,7 @@ option {
}

.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 {
Expand Down
6 changes: 3 additions & 3 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Coolify
</a>
<div
class="w-full bg-white rounded shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-base dark:border-coolgray-200">
class="w-full bg-white shadow md:mt-0 sm:max-w-md xl:p-0 dark:bg-base ">
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
<form action="/login" method="POST" class="flex flex-col gap-2">
@csrf
Expand All @@ -15,6 +15,7 @@ class="w-full bg-white rounded shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dar

<x-forms.input value="password" type="password" name="password" required
label="{{ __('input.password') }}" />

<a href="/forgot-password" class="text-xs">
{{ __('auth.forgot_password') }}?
</a>
Expand All @@ -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
<x-forms.button class="mt-10" type="submit">{{ __('auth.login') }}</x-forms.button>
@if ($is_registration_enabled)
<a href="/register"
class="button bg-coollabs-gradient">
<a href="/register" class="button bg-coollabs-gradient">
{{ __('auth.register_now') }}
</a>
@endif
Expand Down
8 changes: 4 additions & 4 deletions resources/views/components/applications/links.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
}" class="relative" @click.outside="dropdownOpen = false">

<button @click="dropdownOpen=true"
class="inline-flex items-center justify-center py-1 pr-12 text-sm font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:pointer-events-none">
<span class="flex flex-col items-start flex-shrink-0 h-full ml-2 leading-none translate-y-px">
Open Application
class="inline-flex items-center justify-start py-1 pr-10 text-sm font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:pointer-events-none">
<span class="flex flex-col items-start flex-shrink-0 h-full leading-none translate-y-px">
Links
</span>
<svg class="absolute right-0 w-5 h-5 mr-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
</svg>
</svg>
</button>

<div x-show="dropdownOpen" @click.away="dropdownOpen=false" x-transition:enter="ease-out duration-200"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/banner.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x-transition:enter-start="-translate-y-10" x-transition:enter-end="translate-y-0"
x-transition:leave="transition ease-in duration-100" x-transition:leave-start="translate-y-0"
x-transition:leave-end="-translate-y-10" x-init="setTimeout(() => { bannerVisible = true }, bannerVisibleAfter);"
class="relative z-50 w-full py-2 mx-auto duration-100 ease-out shadow-sm bg-coolgray-100 sm:py-0 sm:h-14" x-cloak>
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>
<div class="flex items-center justify-between h-full px-3">
{{ $slot }}
@if ($closable)
Expand Down
10 changes: 3 additions & 7 deletions resources/views/components/forms/button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
<x-loading wire:target="submit" wire:loading.delay />
@else
@if ($attributes->whereStartsWith('wire:click')->first())
<x-loading wire:target="{{ $attributes->whereStartsWith('wire:click')->first() }}" wire:loading.delay />
@endif
@if ($attributes->whereStartsWith('wire:click')->first() && $attributes->get('type') === 'submit')
<x-loading wire:target="{{ $attributes->whereStartsWith('wire:click')->first() }}" wire:loading.delay />
@endif
</button>
15 changes: 8 additions & 7 deletions resources/views/components/forms/input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ class="absolute inset-y-0 right-0 flex items-center pr-2 cursor-pointer hover:te
</svg>
</div>
@endif
<input x-cloak x-show="type" value="{{ $value }}"
{{ $attributes->merge(['class' => $defaultClass]) }} @required($required)
<input value="{{ $value }}" {{ $attributes->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') }}">

</div>
@else
<input @if ($value) value="{{ $value }}" @endif
{{ $attributes->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
Expand Down
37 changes: 28 additions & 9 deletions resources/views/components/modal-confirmation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'title' => 'Are you sure?',
'buttonTitle' => 'Open Modal',
'isErrorButton' => false,
'buttonFullWidth' => false,
'disabled' => false,
'action' => 'delete',
'content' => null,
Expand All @@ -14,17 +15,35 @@ class="relative w-auto h-auto">
</div>
@else
@if ($disabled)
<x-forms.button isError disabled>
{{ $buttonTitle }}
</x-forms.button>
@if ($buttonFullWidth)
<x-forms.button class="w-full" isError disabled>
{{ $buttonTitle }}
</x-forms.button>
@else
<x-forms.button isError disabled>
{{ $buttonTitle }}
</x-forms.button>
@endif
@elseif ($isErrorButton)
<x-forms.button isError @click="modalOpen=true">
{{ $buttonTitle }}
</x-forms.button>
@if ($buttonFullWidth)
<x-forms.button class="w-full" isError @click="modalOpen=true">
{{ $buttonTitle }}
</x-forms.button>
@else
<x-forms.button isError @click="modalOpen=true">
{{ $buttonTitle }}
</x-forms.button>
@endif
@else
<x-forms.button @click="modalOpen=true" class="flex gap-2">
{{ $buttonTitle }}
</x-forms.button>
@if ($buttonFullWidth)
<x-forms.button @click="modalOpen=true" class="flex w-full gap-2">
{{ $buttonTitle }}
</x-forms.button>
@else
<x-forms.button @click="modalOpen=true" class="flex gap-2">
{{ $buttonTitle }}
</x-forms.button>
@endif
@endif
@endif
<template x-teleport="body">
Expand Down
Loading

0 comments on commit 8b7e1e4

Please sign in to comment.