diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index 38cc106c5..abefe136b 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -59,7 +59,7 @@ public function instantSave() $this->application->settings->is_force_https_enabled = $this->is_force_https_enabled; $this->application->settings->save(); $this->application->refresh(); - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); $this->checkWildCardDomain(); } protected function checkWildCardDomain() diff --git a/app/Http/Livewire/Project/Application/Source.php b/app/Http/Livewire/Project/Application/Source.php index 4d7274cdb..0a39b03f6 100644 --- a/app/Http/Livewire/Project/Application/Source.php +++ b/app/Http/Livewire/Project/Application/Source.php @@ -40,6 +40,6 @@ public function submit() $this->application->git_commit_sha = 'HEAD'; } $this->application->save(); - $this->emit('saved', 'Application source updated!'); + $this->emit('success', 'Application source updated!'); } } diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepository.php b/app/Http/Livewire/Project/New/GithubPrivateRepository.php index 6159b8197..89dab6b72 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepository.php @@ -157,6 +157,6 @@ public function instantSave() $this->port = 3000; $this->publish_directory = null; } - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); } } diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 52e63bb70..6f97bc10f 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -56,7 +56,7 @@ public function instantSave() $this->port = 3000; $this->publish_directory = null; } - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); } public function load_branches() { diff --git a/app/Http/Livewire/Server/New/ByIp.php b/app/Http/Livewire/Server/New/ByIp.php index 23a76f5f9..c2cc1cd06 100644 --- a/app/Http/Livewire/Server/New/ByIp.php +++ b/app/Http/Livewire/Server/New/ByIp.php @@ -39,7 +39,7 @@ public function setPrivateKey(string $private_key_id) } public function instantSave() { - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); } public function submit() { diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.php index 04e12980b..57de5e165 100644 --- a/app/Http/Livewire/Settings/Configuration.php +++ b/app/Http/Livewire/Settings/Configuration.php @@ -37,7 +37,7 @@ public function instantSave() $this->settings->is_auto_update_enabled = $this->is_auto_update_enabled; $this->settings->is_registration_enabled = $this->is_registration_enabled; $this->settings->save(); - $this->emit('saved', 'Settings updated!'); + $this->emit('success', 'Settings updated!'); } private function setup_instance_fqdn() { diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php index 60fb30a0f..c57ed4b81 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -59,9 +59,9 @@ private function generate_invite_link(bool $isEmail = false) ]); if ($isEmail) { $user->first()->notify(new InvitationLinkEmail()); - $this->emit('message', 'Invitation sent via email successfully.'); + $this->emit('success', 'Invitation sent via email successfully.'); } else { - $this->emit('message', 'Invitation link generated.'); + $this->emit('success', 'Invitation link generated.'); } $this->emit('refreshInvitations'); } catch (\Throwable $e) { diff --git a/app/Http/Livewire/ForceUpgrade.php b/app/Http/Livewire/Upgrade.php similarity index 63% rename from app/Http/Livewire/ForceUpgrade.php rename to app/Http/Livewire/Upgrade.php index a41651bf0..0ac47576b 100644 --- a/app/Http/Livewire/ForceUpgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -2,17 +2,19 @@ namespace App\Http\Livewire; +use Masmerise\Toaster\Toaster; use App\Jobs\InstanceAutoUpdateJob; use Livewire\Component; -class ForceUpgrade extends Component +class Upgrade extends Component { - public bool $visible = false; + public bool $showProgress = false; public function upgrade() { try { - $this->visible = true; + $this->showProgress = true; dispatch(new InstanceAutoUpdateJob(force: true)); + Toaster::success('Update started.'); } catch (\Exception $e) { return general_error_handler(err: $e, that: $this); } diff --git a/app/Http/Livewire/Upgrading.php b/app/Http/Livewire/Upgrading.php deleted file mode 100644 index b9de9bb03..000000000 --- a/app/Http/Livewire/Upgrading.php +++ /dev/null @@ -1,15 +0,0 @@ -visible = true; - } -} diff --git a/app/Jobs/InstanceAutoUpdateJob.php b/app/Jobs/InstanceAutoUpdateJob.php index 607664739..a08caf23f 100644 --- a/app/Jobs/InstanceAutoUpdateJob.php +++ b/app/Jobs/InstanceAutoUpdateJob.php @@ -27,24 +27,6 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique public function __construct(private bool $force = false) { } - private function update() - { - if (config('app.env') === 'local') { - ray('Running update on local docker container'); - instant_remote_process([ - "sleep 10" - ], $this->server); - ray('Update done'); - return; - } else { - ray('Running update on production server'); - instant_remote_process([ - "curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh", - "bash /data/coolify/source/upgrade.sh $this->latest_version" - ], $this->server); - return; - } - } public function handle(): void { try { @@ -81,6 +63,25 @@ public function handle(): void return; } } + private function update() + { + if (config('app.env') === 'local') { + ray('Running update on local docker container'); + instant_remote_process([ + "sleep 10" + ], $this->server); + ray('Update done'); + return; + } else { + ray('Running update on production server'); + instant_remote_process([ + "curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh", + "bash /data/coolify/source/upgrade.sh $this->latest_version" + ], $this->server); + return; + } + } + public function failed(Exception $exception) { return; diff --git a/composer.json b/composer.json index 06470793d..8fe9ce5dc 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "laravel/ui": "^4.2", "lcobucci/jwt": "^5.0.0", "livewire/livewire": "^v2.12.3", + "masmerise/livewire-toaster": "^1.2", "nubs/random-name-generator": "^2.2", "sentry/sentry-laravel": "^3.4", "spatie/laravel-activitylog": "^4.7.3", @@ -91,4 +92,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 11410a490..f4d2b9c40 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "77b718b33a7ba99083fd327821f968a2", + "content-hash": "d9173515bca399807784102128591e1e", "packages": [ { "name": "bacon/bacon-qr-code", @@ -2738,6 +2738,74 @@ ], "time": "2023-03-03T20:12:38+00:00" }, + { + "name": "masmerise/livewire-toaster", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/masmerise/livewire-toaster.git", + "reference": "2706d3822e111af8272ebc117cb2c69228d14faf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/masmerise/livewire-toaster/zipball/2706d3822e111af8272ebc117cb2c69228d14faf", + "reference": "2706d3822e111af8272ebc117cb2c69228d14faf", + "shasum": "" + }, + "require": { + "laravel/framework": "^10.0", + "livewire/livewire": "^2.0", + "php": "~8.2" + }, + "require-dev": { + "dive-be/php-crowbar": "^1.1", + "laravel/pint": "^1.0", + "nunomaduro/larastan": "^2.0", + "orchestra/testbench": "^8.0", + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Toaster": "Masmerise\\Toaster\\Toaster" + }, + "providers": [ + "Masmerise\\Toaster\\ToasterServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Masmerise\\Toaster\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Muhammed Sari", + "email": "support@muhammedsari.me", + "role": "Developer" + } + ], + "description": "Beautiful toast notifications for Laravel / Livewire.", + "homepage": "https://github.com/masmerise/livewire-toaster", + "keywords": [ + "alert", + "laravel", + "livewire", + "toast", + "toaster" + ], + "support": { + "issues": "https://github.com/masmerise/livewire-toaster/issues", + "source": "https://github.com/masmerise/livewire-toaster/tree/1.2.0" + }, + "time": "2023-06-13T11:44:44+00:00" + }, { "name": "monolog/monolog", "version": "3.3.1", diff --git a/config/toaster.php b/config/toaster.php new file mode 100644 index 000000000..805927210 --- /dev/null +++ b/config/toaster.php @@ -0,0 +1,48 @@ + true, + + /** + * The vertical alignment of the toast container. + * + * Supported: "bottom", "middle" or "top" + */ + 'alignment' => 'top', + + /** + * Allow users to close toast messages prematurely. + * + * Supported: true | false + */ + 'closeable' => true, + + /** + * The on-screen duration of each toast. + * + * Minimum: 3000 (in milliseconds) + */ + 'duration' => 3000, + + /** + * The horizontal position of each toast. + * + * Supported: "center", "left" or "right" + */ + 'position' => 'right', + + /** + * Whether messages passed as translation keys should be translated automatically. + * + * Supported: true | false + */ + 'translate' => true, +]; diff --git a/resources/js/app.js b/resources/js/app.js index 2dc18bf8c..ccfeee5c2 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -2,6 +2,10 @@ import Alpine from "alpinejs"; import { createApp } from "vue"; import MagicBar from "./components/MagicBar.vue"; +import Toaster from "../../vendor/masmerise/livewire-toaster/resources/js"; + +Alpine.plugin(Toaster); + window.Alpine = Alpine; Alpine.start(); diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index 7a949b8c8..773c08a04 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -26,6 +26,7 @@ @livewireScripts + @auth @endauth @@ -54,17 +55,17 @@ function copyToClipboard(text) { Livewire.on('reloadWindow', () => { window.location.reload(); }) + Livewire.on('info', (message) => { + if (message) Toaster.info(message) + }) Livewire.on('error', (message) => { - console.log(message); - alert(message); + if (message) Toaster.error(message) }) - Livewire.on('message', (message) => { - console.log(message); - alert(message); + Livewire.on('warning', (message) => { + if (message) Toaster.warning(message) }) - Livewire.on('saved', (message) => { - if (message) console.log(message); - else console.log('saved'); + Livewire.on('success', (message) => { + if (message) Toaster.success(message) }) @else diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index c159d7cb7..07b4d9adb 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -67,6 +67,9 @@ class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}" viewBox= +
  • + +
  • @endif diff --git a/resources/views/livewire/force-upgrade.blade.php b/resources/views/livewire/force-upgrade.blade.php deleted file mode 100644 index dd9818a8c..000000000 --- a/resources/views/livewire/force-upgrade.blade.php +++ /dev/null @@ -1,63 +0,0 @@ -
    - - Force Upgrade Your Instance - - - - {{-- --}} -
    diff --git a/resources/views/livewire/upgrade.blade.php b/resources/views/livewire/upgrade.blade.php new file mode 100644 index 000000000..cda492bcd --- /dev/null +++ b/resources/views/livewire/upgrade.blade.php @@ -0,0 +1,67 @@ +
    !$showProgress, + 'hover:bg-transparent focus:bg-transparent' => $showProgress, +])> + + +
    diff --git a/resources/views/livewire/upgrading.blade.php b/resources/views/livewire/upgrading.blade.php deleted file mode 100644 index 48d8e2981..000000000 --- a/resources/views/livewire/upgrading.blade.php +++ /dev/null @@ -1,58 +0,0 @@ -
    - -
    diff --git a/resources/views/settings/configuration.blade.php b/resources/views/settings/configuration.blade.php index fe805d461..f4ca677a7 100644 --- a/resources/views/settings/configuration.blade.php +++ b/resources/views/settings/configuration.blade.php @@ -1,8 +1,4 @@ - - @if (auth()->user()->isInstanceAdmin()) - - @endif diff --git a/resources/views/vendor/toaster/hub.blade.php b/resources/views/vendor/toaster/hub.blade.php new file mode 100644 index 000000000..5c6dfa19d --- /dev/null +++ b/resources/views/vendor/toaster/hub.blade.php @@ -0,0 +1,90 @@ +
    $alignment->is('bottom'), + 'top-1/2 -translate-y-1/2' => $alignment->is('middle'), + 'top-0' => $alignment->is('top'), + 'items-start' => $position->is('left'), + 'items-center' => $position->is('center'), + 'items-end' => $position->is('right'), +])> + +
    diff --git a/tailwind.config.js b/tailwind.config.js index 1d29f994a..154269aec 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,55 +1,59 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: [ - "./resources/**/*.blade.php", - "./resources/**/*.js", - "./resources/**/*.vue", - ], - theme: { - extend: { - fontFamily: { - sans: ['Inter', 'sans-serif'], - }, - colors: { - "applications": "#16A34A", - "databases": "#9333EA", - "databases-100": "#9b46ea", - "destinations": "#0284C7", - "sources": "#EA580C", - "services": "#DB2777", - "settings": "#FEE440", - "iam": "#C026D3", - 'coollabs': '#6B16ED', - 'coollabs-100': '#7317FF', - 'coolblack': '#141414', - 'coolgray-100': '#181818', - 'coolgray-200': '#202020', - 'coolgray-300': '#242424', - 'coolgray-400': '#282828', - 'coolgray-500': '#323232' - } - }, - }, - variants: { - scrollbar: ['dark'], - extend: {} - }, - daisyui: { - themes: [ - { - "coollabs": { - "primary": "#6B16ED", - "secondary": "#4338ca", - "accent": "#4338ca", - "neutral": "#1B1D1D", - "base-100": "#212121", - "info": "#2563EB", - "success": "#16A34A", - "warning": "#FCD34D", - "error": "#DC2626", - } - } + content: [ + "./resources/**/*.blade.php", + "./resources/**/*.js", + "./resources/**/*.vue", ], - }, - plugins: [require('tailwindcss-scrollbar'),require("@tailwindcss/typography"),require("daisyui")], -} + theme: { + extend: { + fontFamily: { + sans: ["Inter", "sans-serif"], + }, + colors: { + applications: "#16A34A", + databases: "#9333EA", + "databases-100": "#9b46ea", + destinations: "#0284C7", + sources: "#EA580C", + services: "#DB2777", + settings: "#FEE440", + iam: "#C026D3", + coollabs: "#6B16ED", + "coollabs-100": "#7317FF", + coolblack: "#141414", + "coolgray-100": "#181818", + "coolgray-200": "#202020", + "coolgray-300": "#242424", + "coolgray-400": "#282828", + "coolgray-500": "#323232", + }, + }, + }, + variants: { + scrollbar: ["dark"], + extend: {}, + }, + daisyui: { + themes: [ + { + coollabs: { + primary: "#6B16ED", + secondary: "#4338ca", + accent: "#4338ca", + neutral: "#1B1D1D", + "base-100": "#212121", + info: "#2563EB", + success: "#16A34A", + warning: "#FCD34D", + error: "#DC2626", + }, + }, + ], + }, + plugins: [ + require("tailwindcss-scrollbar"), + require("@tailwindcss/typography"), + require("daisyui"), + ], +};