From d5180f691c6a32f9f6b35291e1e350b2d9160023 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 13:43:58 +0200 Subject: [PATCH 01/34] add spatie health --- app/Console/Kernel.php | 5 + app/Filament/Pages/HealthCheckResults.php | 13 + app/Providers/AppServiceProvider.php | 16 + app/Providers/Filament/AdminPanelProvider.php | 7 +- composer.json | 2 + composer.lock | 310 +++++++++++++++++- config/health.php | 123 +++++++ .../filament-spatie-health-styles.css | 1 + 8 files changed, 475 insertions(+), 2 deletions(-) create mode 100644 app/Filament/Pages/HealthCheckResults.php create mode 100644 config/health.php create mode 100644 public/css/filament-spatie-health/filament-spatie-health-styles.css diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 1dd9986467..0586db3782 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -9,6 +9,8 @@ use App\Console\Commands\Schedule\ProcessRunnableCommand; use App\Console\Commands\Maintenance\PruneOrphanedBackupsCommand; use App\Console\Commands\Maintenance\CleanServiceBackupFilesCommand; +use Spatie\Health\Commands\RunHealthChecksCommand; +use Spatie\Health\Commands\ScheduleCheckHeartbeatCommand; class Kernel extends ConsoleKernel { @@ -40,5 +42,8 @@ protected function schedule(Schedule $schedule): void if (config('activity.prune_days')) { $schedule->command(PruneCommand::class, ['--model' => [ActivityLog::class]])->daily(); } + + $schedule->command(ScheduleCheckHeartbeatCommand::class)->everyMinute(); + $schedule->command(RunHealthChecksCommand::class)->everyFiveMinutes(); } } diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/HealthCheckResults.php new file mode 100644 index 0000000000..a6811ea1c8 --- /dev/null +++ b/app/Filament/Pages/HealthCheckResults.php @@ -0,0 +1,13 @@ +extendSocialite('discord', \SocialiteProviders\Discord\Provider::class); }); + + Health::checks([ + DebugModeCheck::new(), + EnvironmentCheck::new(), + CacheCheck::new(), + DatabaseCheck::new(), + ScheduleCheck::new(), + UsedDiskSpaceCheck::new(), + ]); } /** diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 60339c7440..102882f80e 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -2,6 +2,7 @@ namespace App\Providers\Filament; +use App\Filament\Pages\HealthCheckResults; use App\Filament\Resources\UserResource\Pages\EditProfile; use App\Http\Middleware\LanguageMiddleware; use Filament\Http\Middleware\Authenticate; @@ -19,6 +20,7 @@ use Illuminate\Session\Middleware\AuthenticateSession; use Illuminate\Session\Middleware\StartSession; use Illuminate\View\Middleware\ShareErrorsFromSession; +use ShuvroRoy\FilamentSpatieLaravelHealth\FilamentSpatieLaravelHealthPlugin; class AdminPanelProvider extends PanelProvider { @@ -77,6 +79,9 @@ public function panel(Panel $panel): Panel ]) ->authMiddleware([ Authenticate::class, - ]); + ]) + ->plugin( + FilamentSpatieLaravelHealthPlugin::make()->usingPage(HealthCheckResults::class) + ); } } diff --git a/composer.json b/composer.json index aaa3e9bc51..208603779e 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,10 @@ "prologue/alerts": "^1.2", "ryangjchandler/blade-tabler-icons": "^2.3", "s1lentium/iptools": "~1.2.0", + "shuvroroy/filament-spatie-laravel-health": "^2.0", "socialiteproviders/discord": "^4.2", "spatie/laravel-fractal": "^6.2", + "spatie/laravel-health": "^1.29", "spatie/laravel-query-builder": "^5.8.1", "spatie/temporary-directory": "^2.2", "symfony/http-client": "^7.1", diff --git a/composer.lock b/composer.lock index 22543ba079..508c5495c4 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": "443ec1d95b892b261af5481f27b31083", + "content-hash": "26d3dbd9c2936d550ce9de55dad32d91", "packages": [ { "name": "abdelhamiderrahmouni/filament-monaco-editor", @@ -6790,6 +6790,81 @@ }, "time": "2022-08-17T14:28:59+00:00" }, + { + "name": "shuvroroy/filament-spatie-laravel-health", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/shuvroroy/filament-spatie-laravel-health.git", + "reference": "d78d07cdaa4c40741f0a8186929086b3017f682a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/shuvroroy/filament-spatie-laravel-health/zipball/d78d07cdaa4c40741f0a8186929086b3017f682a", + "reference": "d78d07cdaa4c40741f0a8186929086b3017f682a", + "shasum": "" + }, + "require": { + "filament/filament": "^3.0", + "php": "^8.1", + "spatie/laravel-health": "^1.23", + "spatie/laravel-package-tools": "^1.15" + }, + "require-dev": { + "laravel/pint": "^1.0", + "nunomaduro/collision": "^7.9", + "nunomaduro/larastan": "^2.0.1", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-arch": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "ShuvroRoy\\FilamentSpatieLaravelHealth\\FilamentSpatieLaravelHealthServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "ShuvroRoy\\FilamentSpatieLaravelHealth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Shuvro Roy", + "email": "shuvro.nsu.cse@gmail.com", + "role": "Developer" + } + ], + "description": "This plugin is built on top of Spatie's Laravel-health package", + "homepage": "https://github.com/shuvroroy/filament-spatie-laravel-health", + "keywords": [ + "filament", + "filament-spatie-laravel-health", + "laravel-health" + ], + "support": { + "issues": "https://github.com/shuvroroy/filament-spatie-laravel-health/issues", + "source": "https://github.com/shuvroroy/filament-spatie-laravel-health/tree/v2.0.1" + }, + "funding": [ + { + "url": "https://github.com/shuvroroy", + "type": "github" + } + ], + "time": "2023-10-30T15:48:46+00:00" + }, { "name": "socialiteproviders/discord", "version": "4.2.0", @@ -6973,6 +7048,82 @@ ], "time": "2022-12-18T12:58:32+00:00" }, + { + "name": "spatie/enum", + "version": "3.13.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/enum.git", + "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/enum/zipball/f1a0f464ba909491a53e60a955ce84ad7cd93a2c", + "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^8.0" + }, + "require-dev": { + "fakerphp/faker": "^1.9.1", + "larapack/dd": "^1.1", + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "^4.3" + }, + "suggest": { + "fakerphp/faker": "To use the enum faker provider", + "phpunit/phpunit": "To use the enum assertions" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Enum\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brent Roose", + "email": "brent@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + }, + { + "name": "Tom Witkowski", + "email": "dev@gummibeer.de", + "homepage": "https://gummibeer.de", + "role": "Developer" + } + ], + "description": "PHP Enums", + "homepage": "https://github.com/spatie/enum", + "keywords": [ + "enum", + "enumerable", + "spatie" + ], + "support": { + "docs": "https://docs.spatie.be/enum", + "issues": "https://github.com/spatie/enum/issues", + "source": "https://github.com/spatie/enum" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-04-22T08:51:55+00:00" + }, { "name": "spatie/fractalistic", "version": "2.9.5", @@ -7174,6 +7325,100 @@ ], "time": "2024-06-04T09:33:08+00:00" }, + { + "name": "spatie/laravel-health", + "version": "1.29.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-health.git", + "reference": "1ea1950776038c94e225902fe71b063593e6539d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-health/zipball/1ea1950776038c94e225902fe71b063593e6539d", + "reference": "1ea1950776038c94e225902fe71b063593e6539d", + "shasum": "" + }, + "require": { + "dragonmantank/cron-expression": "^3.3.1", + "guzzlehttp/guzzle": "^6.5|^7.4.5|^7.2", + "illuminate/console": "^8.75|^9.0|^10.0|^11.0", + "illuminate/contracts": "^8.75|^9.0|^10.0|^11.0", + "illuminate/database": "^8.75|^9.0|^10.0|^11.0", + "illuminate/notifications": "^8.75|^9.0|^10.0|^11.0", + "illuminate/support": "^8.75|^9.0|^10.0|^11.0", + "laravel/serializable-closure": "^1.3", + "nunomaduro/termwind": "^1.0|^2.0", + "php": "^8.0", + "spatie/enum": "^3.13", + "spatie/laravel-package-tools": "^1.12.1", + "spatie/regex": "^3.1.1|^3.1", + "spatie/temporary-directory": "^2.2", + "symfony/process": "^5.4|^6.0|^7.0" + }, + "require-dev": { + "larastan/larastan": "^1.0.3|^2.4", + "laravel/horizon": "^5.9.10", + "laravel/slack-notification-channel": "^2.4|^3.2", + "nunomaduro/collision": "^5.10|^6.2.1|^6.1|^8.0", + "orchestra/testbench": "^6.23|^7.6|^8.0|^9.0", + "pestphp/pest": "^1.21.3|^2.34", + "pestphp/pest-plugin-laravel": "^1.2|^2.3", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.1.1", + "phpunit/phpunit": "^9.5.21|^9.5.10|^10.5", + "spatie/laravel-ray": "^1.30", + "spatie/pest-plugin-snapshots": "^1.1|^2.1", + "spatie/pest-plugin-test-time": "^1.1.1|^1.1|^2.0", + "spatie/test-time": "^1.3" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Health\\HealthServiceProvider" + ], + "aliases": { + "Health": "Spatie\\Health\\Facades\\Health" + } + } + }, + "autoload": { + "psr-4": { + "Spatie\\Health\\": "src", + "Spatie\\Health\\Database\\Factories\\": "database/factories" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Monitor the health of a Laravel application", + "homepage": "https://github.com/spatie/laravel-health", + "keywords": [ + "laravel", + "laravel-health", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/laravel-health/tree/1.29.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-06-27T07:11:39+00:00" + }, { "name": "spatie/laravel-package-tools", "version": "1.16.4", @@ -7307,6 +7552,69 @@ ], "time": "2024-05-10T08:19:35+00:00" }, + { + "name": "spatie/regex", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/regex.git", + "reference": "d543de2019a0068e7b80da0ba24f1c51c7469303" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/regex/zipball/d543de2019a0068e7b80da0ba24f1c51c7469303", + "reference": "d543de2019a0068e7b80da0ba24f1c51c7469303", + "shasum": "" + }, + "require": { + "php": "^8.0|^8.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Regex\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian De Deyne", + "email": "sebastian@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "A sane interface for php's built in preg_* functions", + "homepage": "https://github.com/spatie/regex", + "keywords": [ + "expression", + "expressions", + "regex", + "regular", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/regex/issues", + "source": "https://github.com/spatie/regex/tree/3.1.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2021-11-30T21:13:59+00:00" + }, { "name": "spatie/temporary-directory", "version": "2.2.1", diff --git a/config/health.php b/config/health.php new file mode 100644 index 0000000000..b31da1cae5 --- /dev/null +++ b/config/health.php @@ -0,0 +1,123 @@ + [ + /* + Spatie\Health\ResultStores\EloquentHealthResultStore::class => [ + 'connection' => env('HEALTH_DB_CONNECTION', env('DB_CONNECTION')), + 'model' => Spatie\Health\Models\HealthCheckResultHistoryItem::class, + 'keep_history_for_days' => 5, + ], + */ + + Spatie\Health\ResultStores\CacheHealthResultStore::class => [ + 'store' => 'file', + ], + + /* + Spatie\Health\ResultStores\JsonFileHealthResultStore::class => [ + 'disk' => 's3', + 'path' => 'health.json', + ], + + Spatie\Health\ResultStores\InMemoryHealthResultStore::class, + */ + ], + + /* + * You can get notified when specific events occur. Out of the box you can use 'mail' and 'slack'. + * For Slack you need to install laravel/slack-notification-channel. + */ + 'notifications' => [ + /* + * Notifications will only get sent if this option is set to `true`. + */ + 'enabled' => false, + + 'notifications' => [ + Spatie\Health\Notifications\CheckFailedNotification::class => ['mail'], + ], + + /* + * Here you can specify the notifiable to which the notifications should be sent. The default + * notifiable will use the variables specified in this config file. + */ + 'notifiable' => Spatie\Health\Notifications\Notifiable::class, + + /* + * When checks start failing, you could potentially end up getting + * a notification every minute. + * + * With this setting, notifications are throttled. By default, you'll + * only get one notification per hour. + */ + 'throttle_notifications_for_minutes' => 60, + 'throttle_notifications_key' => 'health:latestNotificationSentAt:', + + 'mail' => [ + 'to' => 'your@example.com', + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), + ], + ], + + 'slack' => [ + 'webhook_url' => env('HEALTH_SLACK_WEBHOOK_URL', ''), + + /* + * If this is set to null the default channel of the webhook will be used. + */ + 'channel' => null, + + 'username' => null, + + 'icon' => null, + ], + ], + + /* + * You can let Oh Dear monitor the results of all health checks. This way, you'll + * get notified of any problems even if your application goes totally down. Via + * Oh Dear, you can also have access to more advanced notification options. + */ + 'oh_dear_endpoint' => [ + 'enabled' => false, + + /* + * When this option is enabled, the checks will run before sending a response. + * Otherwise, we'll send the results from the last time the checks have run. + */ + 'always_send_fresh_results' => true, + + /* + * The secret that is displayed at the Application Health settings at Oh Dear. + */ + 'secret' => env('OH_DEAR_HEALTH_CHECK_SECRET'), + + /* + * The URL that should be configured in the Application health settings at Oh Dear. + */ + 'url' => '/oh-dear-health-check-results', + ], + + /* + * You can set a theme for the local results page + * + * - light: light mode + * - dark: dark mode + */ + 'theme' => 'light', + + /* + * When enabled, completed `HealthQueueJob`s will be displayed + * in Horizon's silenced jobs screen. + */ + 'silence_health_queue_job' => true, +]; diff --git a/public/css/filament-spatie-health/filament-spatie-health-styles.css b/public/css/filament-spatie-health/filament-spatie-health-styles.css new file mode 100644 index 0000000000..7e86638391 --- /dev/null +++ b/public/css/filament-spatie-health/filament-spatie-health-styles.css @@ -0,0 +1 @@ +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.filament-spatie-health :is(.-mt-1){margin-top:-.25rem}.filament-spatie-health :is(.mb-5){margin-bottom:1.25rem}.filament-spatie-health :is(.mt-0){margin-top:0}.filament-spatie-health :is(.flex){display:flex}.filament-spatie-health :is(.grid){display:grid}.filament-spatie-health :is(.h-6){height:1.5rem}.filament-spatie-health :is(.w-6){width:1.5rem}.filament-spatie-health :is(.transform){transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.filament-spatie-health :is(.grid-cols-1){grid-template-columns:repeat(1,minmax(0,1fr))}.filament-spatie-health :is(.items-start){align-items:flex-start}.filament-spatie-health :is(.items-center){align-items:center}.filament-spatie-health :is(.justify-center){justify-content:center}.filament-spatie-health :is(.gap-6){gap:1.5rem}.filament-spatie-health :is(.space-x-2>:not([hidden])~:not([hidden])){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.filament-spatie-health :is(.overflow-hidden){overflow:hidden}.filament-spatie-health :is(.rounded-full){border-radius:9999px}.filament-spatie-health :is(.rounded-xl){border-radius:.75rem}.filament-spatie-health :is(.bg-blue-100){--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-emerald-100){--tw-bg-opacity:1;background-color:rgb(209 250 229/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-gray-100){--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-red-100){--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-white){--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-yellow-100){--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.filament-spatie-health :is(.p-2){padding:.5rem}.filament-spatie-health :is(.px-4){padding-left:1rem;padding-right:1rem}.filament-spatie-health :is(.py-5){padding-bottom:1.25rem;padding-top:1.25rem}.filament-spatie-health :is(.text-center){text-align:center}.filament-spatie-health :is(.text-sm){font-size:.875rem;line-height:1.25rem}.filament-spatie-health :is(.font-bold){font-weight:700}.filament-spatie-health :is(.font-medium){font-weight:500}.filament-spatie-health :is(.text-blue-500){--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.filament-spatie-health :is(.text-emerald-500){--tw-text-opacity:1;color:rgb(16 185 129/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-400){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-500){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-600){--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-900){--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.filament-spatie-health :is(.text-red-500){--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.filament-spatie-health :is(.text-yellow-500){--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity))}.filament-spatie-health :is(.text-opacity-0){--tw-text-opacity:0}.filament-spatie-health :is(.shadow-sm){--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filament-spatie-health :is(.shadow-gray-200){--tw-shadow-color:#e5e7eb;--tw-shadow:var(--tw-shadow-colored)}.filament-spatie-health :is(.transition){transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.filament-spatie-health :is(.dark .dark\:border-t){border-top-width:1px}.filament-spatie-health :is(.dark .dark\:border-gray-700){--tw-border-opacity:1;border-color:rgb(55 65 81/var(--tw-border-opacity))}.filament-spatie-health :is(.dark .dark\:bg-gray-900){--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity))}.filament-spatie-health :is(.dark .dark\:text-gray-200){--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.filament-spatie-health :is(.dark .dark\:text-gray-400){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.filament-spatie-health :is(.dark .dark\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.filament-spatie-health :is(.dark .dark\:shadow-md){--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filament-spatie-health :is(.dark .dark\:shadow-black\/25){--tw-shadow-color:rgba(0,0,0,.25);--tw-shadow:var(--tw-shadow-colored)}@media (min-width:640px){.filament-spatie-health :is(.sm\:grid-cols-2){grid-template-columns:repeat(2,minmax(0,1fr))}.filament-spatie-health :is(.sm\:p-6){padding:1.5rem}}@media (min-width:768px){.filament-spatie-health :is(.md\:mt-1){margin-top:.25rem}.filament-spatie-health :is(.md\:min-h-\[130px\]){min-height:130px}.filament-spatie-health :is(.md\:space-x-3>:not([hidden])~:not([hidden])){--tw-space-x-reverse:0;margin-left:calc(.75rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.75rem*var(--tw-space-x-reverse))}.filament-spatie-health :is(.md\:text-xl){font-size:1.25rem;line-height:1.75rem}}@media (min-width:1024px){.filament-spatie-health :is(.lg\:grid-cols-3){grid-template-columns:repeat(3,minmax(0,1fr))}} From c5897ca856e6e21fe55207a1752fbb0102571cd9 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 13:52:15 +0200 Subject: [PATCH 02/34] change slug for health page --- app/Filament/Pages/HealthCheckResults.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/HealthCheckResults.php index a6811ea1c8..182ffcff38 100644 --- a/app/Filament/Pages/HealthCheckResults.php +++ b/app/Filament/Pages/HealthCheckResults.php @@ -6,6 +6,8 @@ class HealthCheckResults extends BaseHealthCheckResults { + protected static ?string $slug = 'health'; + public static function getNavigationGroup(): ?string { return 'Advanced'; From 0745ec43f5fdbeaca4be613f59dd8cf8f4d3aab3 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:04:40 +0200 Subject: [PATCH 03/34] add check for panel version --- app/Checks/PanelVersionCheck.php | 32 ++++++++++++++++++++++++++++ app/Providers/AppServiceProvider.php | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 app/Checks/PanelVersionCheck.php diff --git a/app/Checks/PanelVersionCheck.php b/app/Checks/PanelVersionCheck.php new file mode 100644 index 0000000000..591e088dcf --- /dev/null +++ b/app/Checks/PanelVersionCheck.php @@ -0,0 +1,32 @@ +isLatestPanel(); + $currentVersion = $versionService->versionData()['version']; + $latestVersion = $versionService->getPanel(); + + $result = Result::make() + ->meta([ + 'isLatest' => $isLatest, + 'currentVersion' => $currentVersion, + 'latestVersion' => $latestVersion, + ]) + ->shortSummary($isLatest); + + return $isLatest + ? $result->ok('Panel is up-to-date') + : $result->failed("Installed version is `{$currentVersion}` but latest is `{$latestVersion}`"); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 3f78e63428..0bb0506185 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Checks\PanelVersionCheck; use App\Extensions\Themes\Theme; use App\Models; use App\Models\ApiKey; @@ -95,6 +96,7 @@ public function boot(): void DatabaseCheck::new(), ScheduleCheck::new(), UsedDiskSpaceCheck::new(), + PanelVersionCheck::new(), ]); } From 2ae1fe3123282e60040839cebbf11a34f505af9b Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:06:05 +0200 Subject: [PATCH 04/34] only check for debug mode if env isn't local --- app/Providers/AppServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 0bb0506185..6db0101fad 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -90,7 +90,7 @@ public function boot(): void }); Health::checks([ - DebugModeCheck::new(), + DebugModeCheck::new()->unless(app()->environment('local')), EnvironmentCheck::new(), CacheCheck::new(), DatabaseCheck::new(), From 236a7b6a45c547f6e891b1db721d2bacbd76061d Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:15:30 +0200 Subject: [PATCH 05/34] add check for node versions --- app/Checks/NodeVersionsCheck.php | 37 ++++++++++++++++++++++++++++ app/Checks/PanelVersionCheck.php | 2 +- app/Providers/AppServiceProvider.php | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 app/Checks/NodeVersionsCheck.php diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php new file mode 100644 index 0000000000..c0dca6ecf7 --- /dev/null +++ b/app/Checks/NodeVersionsCheck.php @@ -0,0 +1,37 @@ +count(); + $outdated = 0; + + $latestVersion = app(SoftwareVersionService::class)->getDaemon(); + + $nodes = Node::query()->get(); + foreach ($nodes as $node) { + if ($node->systemInformation()['version'] === $latestVersion) { + $outdated++; + } + } + + $result = Result::make() + ->meta([ + 'all' => $all, + 'outdated' => $outdated, + ]) + ->shortSummary($outdated === 0); + + return $outdated === 0 + ? $result->ok('All Nodes are up-to-date') + : $result->failed("`{$outdated}`/`{$all}` Nodes are outdated"); + } +} diff --git a/app/Checks/PanelVersionCheck.php b/app/Checks/PanelVersionCheck.php index 591e088dcf..420039375a 100644 --- a/app/Checks/PanelVersionCheck.php +++ b/app/Checks/PanelVersionCheck.php @@ -23,7 +23,7 @@ public function run(): Result 'currentVersion' => $currentVersion, 'latestVersion' => $latestVersion, ]) - ->shortSummary($isLatest); + ->shortSummary($isLatest ? 'up-to-date' : 'outdated'); return $isLatest ? $result->ok('Panel is up-to-date') diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6db0101fad..273be7dfd0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Checks\NodeVersionsCheck; use App\Checks\PanelVersionCheck; use App\Extensions\Themes\Theme; use App\Models; @@ -97,6 +98,7 @@ public function boot(): void ScheduleCheck::new(), UsedDiskSpaceCheck::new(), PanelVersionCheck::new(), + NodeVersionsCheck::new()->unless(Node::query()->count() === 0), ]); } From 2edc95424c7f7ba78fea262f8dd541961a11b9c7 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:16:57 +0200 Subject: [PATCH 06/34] improve short summary --- app/Checks/NodeVersionsCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index c0dca6ecf7..a7b9c1ce96 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -28,7 +28,7 @@ public function run(): Result 'all' => $all, 'outdated' => $outdated, ]) - ->shortSummary($outdated === 0); + ->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated} outdated"); return $outdated === 0 ? $result->ok('All Nodes are up-to-date') From 5fd9698f7a838302dfdc2f1ced093ae91d4df261 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:17:14 +0200 Subject: [PATCH 07/34] fix outdated check --- app/Checks/NodeVersionsCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index a7b9c1ce96..6efb140cfc 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -18,7 +18,7 @@ public function run(): Result $nodes = Node::query()->get(); foreach ($nodes as $node) { - if ($node->systemInformation()['version'] === $latestVersion) { + if ($node->systemInformation()['version'] !== $latestVersion) { $outdated++; } } From 8b1e7027548232c3ef2c3c785729675d667d8e33 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:17:37 +0200 Subject: [PATCH 08/34] run pint --- app/Filament/Pages/HealthCheckResults.php | 8 ++++---- config/health.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/HealthCheckResults.php index 182ffcff38..1eb12ebb6b 100644 --- a/app/Filament/Pages/HealthCheckResults.php +++ b/app/Filament/Pages/HealthCheckResults.php @@ -1,9 +1,9 @@ 5, ], */ - + Spatie\Health\ResultStores\CacheHealthResultStore::class => [ 'store' => 'file', ], From 635bd23e232c123f7baa5c474e2515b8e82711bb Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:21:54 +0200 Subject: [PATCH 09/34] fix health checks during tests --- app/Providers/AppServiceProvider.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 273be7dfd0..1996e4d3f9 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -90,16 +90,19 @@ public function boot(): void $event->extendSocialite('discord', \SocialiteProviders\Discord\Provider::class); }); - Health::checks([ - DebugModeCheck::new()->unless(app()->environment('local')), - EnvironmentCheck::new(), - CacheCheck::new(), - DatabaseCheck::new(), - ScheduleCheck::new(), - UsedDiskSpaceCheck::new(), - PanelVersionCheck::new(), - NodeVersionsCheck::new()->unless(Node::query()->count() === 0), - ]); + // Don't run any health checks during tests + if (config('app.env') !== 'testing') { + Health::checks([ + DebugModeCheck::new()->unless(app()->environment('local')), + EnvironmentCheck::new(), + CacheCheck::new(), + DatabaseCheck::new(), + ScheduleCheck::new(), + UsedDiskSpaceCheck::new(), + PanelVersionCheck::new(), + NodeVersionsCheck::new()->unless(Node::query()->count() === 0), + ]); + } } /** From 96911667e4fea5d3f2a1f22bc71cc85324d71ebb Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:40:09 +0200 Subject: [PATCH 10/34] add count to ok message --- app/Checks/NodeVersionsCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index 6efb140cfc..ccdba40538 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -31,7 +31,7 @@ public function run(): Result ->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated} outdated"); return $outdated === 0 - ? $result->ok('All Nodes are up-to-date') + ? $result->ok("All `{$all}` Nodes are up-to-date") : $result->failed("`{$outdated}`/`{$all}` Nodes are outdated"); } } From d5bcb8df640d07ef8eb783c7d6415f1002a1f103 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:45:53 +0200 Subject: [PATCH 11/34] fix typo --- app/Checks/PanelVersionCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Checks/PanelVersionCheck.php b/app/Checks/PanelVersionCheck.php index 420039375a..ee65dc7c88 100644 --- a/app/Checks/PanelVersionCheck.php +++ b/app/Checks/PanelVersionCheck.php @@ -10,7 +10,7 @@ class PanelVersionCheck extends Check { public function run(): Result { - /** @var SoftwareVersionServivce $versionService */ + /** @var SoftwareVersionService $versionService */ $versionService = app(SoftwareVersionService::class); $isLatest = $versionService->isLatestPanel(); From e7f5cf3380de97dedf802c2af8f425305231f91a Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:47:44 +0200 Subject: [PATCH 12/34] temp fix for phpstan job --- app/Providers/AppServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1996e4d3f9..c061b47046 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -100,7 +100,7 @@ public function boot(): void ScheduleCheck::new(), UsedDiskSpaceCheck::new(), PanelVersionCheck::new(), - NodeVersionsCheck::new()->unless(Node::query()->count() === 0), + NodeVersionsCheck::new(),//->unless(Node::query()->count() === 0), ]); } } From 2530d7a0bc36e99e09452399643206b8b0245939 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 14:50:19 +0200 Subject: [PATCH 13/34] fix pint... --- app/Providers/AppServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index c061b47046..52598f1174 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -100,7 +100,7 @@ public function boot(): void ScheduleCheck::new(), UsedDiskSpaceCheck::new(), PanelVersionCheck::new(), - NodeVersionsCheck::new(),//->unless(Node::query()->count() === 0), + NodeVersionsCheck::new(), //->unless(Node::query()->count() === 0), ]); } } From 7a947654b72ca0f5f437859423d8a91695a2f9d8 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 16:20:06 +0200 Subject: [PATCH 14/34] improve "outdated" count Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> --- app/Checks/NodeVersionsCheck.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index ccdba40538..1fda786d9c 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -12,16 +12,11 @@ class NodeVersionsCheck extends Check public function run(): Result { $all = Node::query()->count(); - $outdated = 0; - $latestVersion = app(SoftwareVersionService::class)->getDaemon(); - $nodes = Node::query()->get(); - foreach ($nodes as $node) { - if ($node->systemInformation()['version'] !== $latestVersion) { - $outdated++; - } - } + $outdated = Node::query()->get() + ->filter(fn (Node $node) => !isset($node->systemInformation()['exception']) && $node->systemInformation()['version'] !== $latestVersion) + ->count(); $result = Result::make() ->meta([ From f8f0b54b81da0399d53c0ee6a55c854fe23e9b0e Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 8 Jul 2024 18:06:25 +0200 Subject: [PATCH 15/34] run pint --- app/Checks/NodeVersionsCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index 1fda786d9c..a4ef3a3133 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -14,7 +14,7 @@ public function run(): Result $all = Node::query()->count(); $latestVersion = app(SoftwareVersionService::class)->getDaemon(); - $outdated = Node::query()->get() + $outdated = Node::query()->get() ->filter(fn (Node $node) => !isset($node->systemInformation()['exception']) && $node->systemInformation()['version'] !== $latestVersion) ->count(); From 1f07e13756bfbfad4568af977620ed140c410450 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 9 Jul 2024 10:42:06 +0200 Subject: [PATCH 16/34] skip node versions check if no nodes are created --- app/Checks/NodeVersionsCheck.php | 13 +++++++++++-- app/Providers/AppServiceProvider.php | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index a4ef3a3133..503d6f6c9c 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -6,12 +6,21 @@ use App\Services\Helpers\SoftwareVersionService; use Spatie\Health\Checks\Check; use Spatie\Health\Checks\Result; +use Spatie\Health\Enums\Status; class NodeVersionsCheck extends Check { public function run(): Result { $all = Node::query()->count(); + + if ($all === 0) { + $result = Result::make()->notificationMessage('No Nodes created')->shortSummary('No Nodes'); + $result->status = Status::skipped(); + + return $result; + } + $latestVersion = app(SoftwareVersionService::class)->getDaemon(); $outdated = Node::query()->get() @@ -23,10 +32,10 @@ public function run(): Result 'all' => $all, 'outdated' => $outdated, ]) - ->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated} outdated"); + ->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated}/{$all} outdated"); return $outdated === 0 - ? $result->ok("All `{$all}` Nodes are up-to-date") + ? $result->ok('All Nodes are up-to-date') : $result->failed("`{$outdated}`/`{$all}` Nodes are outdated"); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 52598f1174..ba0c26dee0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -100,7 +100,7 @@ public function boot(): void ScheduleCheck::new(), UsedDiskSpaceCheck::new(), PanelVersionCheck::new(), - NodeVersionsCheck::new(), //->unless(Node::query()->count() === 0), + NodeVersionsCheck::new(), ]); } } From b92a81ec86e69c2b18dff8f1eee6568cde6e4d56 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 9 Jul 2024 10:51:40 +0200 Subject: [PATCH 17/34] auto run health checks if they didn't run before --- app/Filament/Pages/HealthCheckResults.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/HealthCheckResults.php index 1eb12ebb6b..10c2a9d3a2 100644 --- a/app/Filament/Pages/HealthCheckResults.php +++ b/app/Filament/Pages/HealthCheckResults.php @@ -2,7 +2,11 @@ namespace App\Filament\Pages; +use Carbon\Carbon; +use Illuminate\Support\Facades\Artisan; use ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults as BaseHealthCheckResults; +use Spatie\Health\Commands\RunHealthChecksCommand; +use Spatie\Health\ResultStores\ResultStore; class HealthCheckResults extends BaseHealthCheckResults { @@ -12,4 +16,20 @@ public static function getNavigationGroup(): ?string { return 'Advanced'; } + + protected function getViewData(): array + { + $checkResults = app(ResultStore::class)->latestResults(); + + if ($checkResults === null) { + Artisan::call(RunHealthChecksCommand::class); + + $this->dispatch('refresh-component'); + } + + return [ + 'lastRanAt' => new Carbon($checkResults?->finishedAt), + 'checkResults' => $checkResults, + ]; + } } From 8039627f8b9917efdfe15bf49b4a36bf1a78331b Mon Sep 17 00:00:00 2001 From: Boy132 Date: Wed, 10 Jul 2024 09:26:34 +0200 Subject: [PATCH 18/34] small refactor --- app/Providers/AppServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ba0c26dee0..48052e7539 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -91,9 +91,9 @@ public function boot(): void }); // Don't run any health checks during tests - if (config('app.env') !== 'testing') { + if (!app()->runningUnitTests()) { Health::checks([ - DebugModeCheck::new()->unless(app()->environment('local')), + DebugModeCheck::new()->if(app()->isProduction()), EnvironmentCheck::new(), CacheCheck::new(), DatabaseCheck::new(), From 21af2c65146565a8635010ea45347e752b41eda4 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Sat, 13 Jul 2024 00:36:35 +0200 Subject: [PATCH 19/34] update navigation Co-authored-by: Charles --- app/Filament/Pages/HealthCheckResults.php | 57 +++++++++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/HealthCheckResults.php index 10c2a9d3a2..a15c9535b0 100644 --- a/app/Filament/Pages/HealthCheckResults.php +++ b/app/Filament/Pages/HealthCheckResults.php @@ -11,11 +11,7 @@ class HealthCheckResults extends BaseHealthCheckResults { protected static ?string $slug = 'health'; - - public static function getNavigationGroup(): ?string - { - return 'Advanced'; - } + protected static ?int $navigationSort = 4; protected function getViewData(): array { @@ -32,4 +28,55 @@ protected function getViewData(): array 'checkResults' => $checkResults, ]; } + + public static function getNavigationGroup(): ?string + { + return 'Advanced'; + } + + public static function getNavigationLabel(): string + { + return 'Panel Health'; + } + + public static function getNavigationBadge(): ?string + { + $results = json_decode(app(ResultStore::class)->latestResults()->toJson(), true); + + $failed = array_reduce($results['checkResults'], function ($numFailed, $result) { + return $numFailed + ($result['status'] === 'failed' ? 1 : 0); + }, 0); + + return $failed === 0 ? null : (string) $failed; + } + + public static function getNavigationBadgeColor(): string + { + return self::getNavigationBadge() > null ? 'danger' : ''; + } + + public static function getNavigationBadgeTooltip(): ?string + { + $results = json_decode(app(ResultStore::class)->latestResults()->toJson(), true); + + $failedNames = array_reduce($results['checkResults'], function ($carry, $result) { + if ($result['status'] === 'failed') { + $carry[] = $result['name']; + } + + return $carry; + }, []); + + return 'Failed: ' . implode(', ', $failedNames); + } + + public static function getNavigationIcon(): string + { + return app(ResultStore::class)->latestResults()->containsFailingCheck() ? 'tabler-heart-exclamation' : 'tabler-heart-check'; + } + + public static function getSlug(): string + { + return 'health'; + } } From 135d1ed326813a1709f5b45e4b283253cf4e8a69 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Sat, 13 Jul 2024 00:44:28 +0200 Subject: [PATCH 20/34] fix errors if tests didn't run yet --- app/Filament/Pages/HealthCheckResults.php | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/HealthCheckResults.php index a15c9535b0..1cbc31495e 100644 --- a/app/Filament/Pages/HealthCheckResults.php +++ b/app/Filament/Pages/HealthCheckResults.php @@ -41,7 +41,13 @@ public static function getNavigationLabel(): string public static function getNavigationBadge(): ?string { - $results = json_decode(app(ResultStore::class)->latestResults()->toJson(), true); + $results = app(ResultStore::class)->latestResults(); + + if ($results === null) { + return null; + } + + $results = json_decode($results->toJson(), true); $failed = array_reduce($results['checkResults'], function ($numFailed, $result) { return $numFailed + ($result['status'] === 'failed' ? 1 : 0); @@ -57,7 +63,13 @@ public static function getNavigationBadgeColor(): string public static function getNavigationBadgeTooltip(): ?string { - $results = json_decode(app(ResultStore::class)->latestResults()->toJson(), true); + $results = app(ResultStore::class)->latestResults(); + + if ($results === null) { + return null; + } + + $results = json_decode($results->toJson(), true); $failedNames = array_reduce($results['checkResults'], function ($carry, $result) { if ($result['status'] === 'failed') { @@ -72,7 +84,13 @@ public static function getNavigationBadgeTooltip(): ?string public static function getNavigationIcon(): string { - return app(ResultStore::class)->latestResults()->containsFailingCheck() ? 'tabler-heart-exclamation' : 'tabler-heart-check'; + $results = app(ResultStore::class)->latestResults(); + + if ($results === null) { + return 'tabler-heart-question'; + } + + return $results->containsFailingCheck() ? 'tabler-heart-exclamation' : 'tabler-heart-check'; } public static function getSlug(): string From 59b3cd52e8356037c6bdc91112c2793aaae514b6 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Sat, 13 Jul 2024 00:44:33 +0200 Subject: [PATCH 21/34] fix disk usage check --- app/Checks/UsedDiskSpaceCheck.php | 16 ++++++++++++++++ app/Providers/AppServiceProvider.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/Checks/UsedDiskSpaceCheck.php diff --git a/app/Checks/UsedDiskSpaceCheck.php b/app/Checks/UsedDiskSpaceCheck.php new file mode 100644 index 0000000000..26879d11de --- /dev/null +++ b/app/Checks/UsedDiskSpaceCheck.php @@ -0,0 +1,16 @@ +filesystemName ?? '/'); + $totalSpace = disk_total_space($this->filesystemName ?? '/'); + + return 100 - ($freeSpace * 100 / $totalSpace); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 48052e7539..01e911d94a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,6 +4,7 @@ use App\Checks\NodeVersionsCheck; use App\Checks\PanelVersionCheck; +use App\Checks\UsedDiskSpaceCheck; use App\Extensions\Themes\Theme; use App\Models; use App\Models\ApiKey; @@ -28,7 +29,6 @@ use Spatie\Health\Checks\Checks\DebugModeCheck; use Spatie\Health\Checks\Checks\EnvironmentCheck; use Spatie\Health\Checks\Checks\ScheduleCheck; -use Spatie\Health\Checks\Checks\UsedDiskSpaceCheck; use Spatie\Health\Facades\Health; class AppServiceProvider extends ServiceProvider From 87a87cc9bc3aa63e49d6f70dbd66fc4f53d97b36 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Thu, 18 Jul 2024 15:06:59 +0200 Subject: [PATCH 22/34] remove plugin and use own page --- .../{HealthCheckResults.php => Health.php} | 44 +++++++---- app/Providers/Filament/AdminPanelProvider.php | 7 +- composer.json | 3 +- composer.lock | 77 +------------------ .../filament-spatie-health-styles.css | 1 - .../views/filament/pages/health.blade.php | 43 +++++++++++ 6 files changed, 75 insertions(+), 100 deletions(-) rename app/Filament/Pages/{HealthCheckResults.php => Health.php} (72%) delete mode 100644 public/css/filament-spatie-health/filament-spatie-health-styles.css create mode 100644 resources/views/filament/pages/health.blade.php diff --git a/app/Filament/Pages/HealthCheckResults.php b/app/Filament/Pages/Health.php similarity index 72% rename from app/Filament/Pages/HealthCheckResults.php rename to app/Filament/Pages/Health.php index 1cbc31495e..02a4813003 100644 --- a/app/Filament/Pages/HealthCheckResults.php +++ b/app/Filament/Pages/Health.php @@ -3,15 +3,32 @@ namespace App\Filament\Pages; use Carbon\Carbon; +use Filament\Actions\Action; +use Filament\Notifications\Notification; +use Filament\Pages\Page; use Illuminate\Support\Facades\Artisan; -use ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults as BaseHealthCheckResults; use Spatie\Health\Commands\RunHealthChecksCommand; use Spatie\Health\ResultStores\ResultStore; -class HealthCheckResults extends BaseHealthCheckResults +class Health extends Page { - protected static ?string $slug = 'health'; - protected static ?int $navigationSort = 4; + protected static ?string $navigationIcon = 'tabler-heart'; + protected static ?string $navigationGroup = 'Advanced'; + + protected static string $view = 'filament.pages.health'; + + protected $listeners = [ + 'refresh-component' => '$refresh', + ]; + + protected function getActions(): array + { + return [ + Action::make('refresh') + ->button() + ->action('refresh'), + ]; + } protected function getViewData(): array { @@ -29,14 +46,16 @@ protected function getViewData(): array ]; } - public static function getNavigationGroup(): ?string + public function refresh(): void { - return 'Advanced'; - } + Artisan::call(RunHealthChecksCommand::class); - public static function getNavigationLabel(): string - { - return 'Panel Health'; + $this->dispatch('refresh-component'); + + Notification::make() + ->title('Health check results refreshed') + ->success() + ->send(); } public static function getNavigationBadge(): ?string @@ -92,9 +111,4 @@ public static function getNavigationIcon(): string return $results->containsFailingCheck() ? 'tabler-heart-exclamation' : 'tabler-heart-check'; } - - public static function getSlug(): string - { - return 'health'; - } } diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 102882f80e..60339c7440 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -2,7 +2,6 @@ namespace App\Providers\Filament; -use App\Filament\Pages\HealthCheckResults; use App\Filament\Resources\UserResource\Pages\EditProfile; use App\Http\Middleware\LanguageMiddleware; use Filament\Http\Middleware\Authenticate; @@ -20,7 +19,6 @@ use Illuminate\Session\Middleware\AuthenticateSession; use Illuminate\Session\Middleware\StartSession; use Illuminate\View\Middleware\ShareErrorsFromSession; -use ShuvroRoy\FilamentSpatieLaravelHealth\FilamentSpatieLaravelHealthPlugin; class AdminPanelProvider extends PanelProvider { @@ -79,9 +77,6 @@ public function panel(Panel $panel): Panel ]) ->authMiddleware([ Authenticate::class, - ]) - ->plugin( - FilamentSpatieLaravelHealthPlugin::make()->usingPage(HealthCheckResults::class) - ); + ]); } } diff --git a/composer.json b/composer.json index 208603779e..37a0bea637 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,6 @@ "prologue/alerts": "^1.2", "ryangjchandler/blade-tabler-icons": "^2.3", "s1lentium/iptools": "~1.2.0", - "shuvroroy/filament-spatie-laravel-health": "^2.0", "socialiteproviders/discord": "^4.2", "spatie/laravel-fractal": "^6.2", "spatie/laravel-health": "^1.29", @@ -92,4 +91,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 508c5495c4..6669119719 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": "26d3dbd9c2936d550ce9de55dad32d91", + "content-hash": "667c1be15f7830c72fe1e1b12d506a33", "packages": [ { "name": "abdelhamiderrahmouni/filament-monaco-editor", @@ -6790,81 +6790,6 @@ }, "time": "2022-08-17T14:28:59+00:00" }, - { - "name": "shuvroroy/filament-spatie-laravel-health", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/shuvroroy/filament-spatie-laravel-health.git", - "reference": "d78d07cdaa4c40741f0a8186929086b3017f682a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/shuvroroy/filament-spatie-laravel-health/zipball/d78d07cdaa4c40741f0a8186929086b3017f682a", - "reference": "d78d07cdaa4c40741f0a8186929086b3017f682a", - "shasum": "" - }, - "require": { - "filament/filament": "^3.0", - "php": "^8.1", - "spatie/laravel-health": "^1.23", - "spatie/laravel-package-tools": "^1.15" - }, - "require-dev": { - "laravel/pint": "^1.0", - "nunomaduro/collision": "^7.9", - "nunomaduro/larastan": "^2.0.1", - "orchestra/testbench": "^8.0", - "pestphp/pest": "^2.0", - "pestphp/pest-plugin-arch": "^2.0", - "pestphp/pest-plugin-laravel": "^2.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "ShuvroRoy\\FilamentSpatieLaravelHealth\\FilamentSpatieLaravelHealthServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "ShuvroRoy\\FilamentSpatieLaravelHealth\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Shuvro Roy", - "email": "shuvro.nsu.cse@gmail.com", - "role": "Developer" - } - ], - "description": "This plugin is built on top of Spatie's Laravel-health package", - "homepage": "https://github.com/shuvroroy/filament-spatie-laravel-health", - "keywords": [ - "filament", - "filament-spatie-laravel-health", - "laravel-health" - ], - "support": { - "issues": "https://github.com/shuvroroy/filament-spatie-laravel-health/issues", - "source": "https://github.com/shuvroroy/filament-spatie-laravel-health/tree/v2.0.1" - }, - "funding": [ - { - "url": "https://github.com/shuvroroy", - "type": "github" - } - ], - "time": "2023-10-30T15:48:46+00:00" - }, { "name": "socialiteproviders/discord", "version": "4.2.0", diff --git a/public/css/filament-spatie-health/filament-spatie-health-styles.css b/public/css/filament-spatie-health/filament-spatie-health-styles.css deleted file mode 100644 index 7e86638391..0000000000 --- a/public/css/filament-spatie-health/filament-spatie-health-styles.css +++ /dev/null @@ -1 +0,0 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.filament-spatie-health :is(.-mt-1){margin-top:-.25rem}.filament-spatie-health :is(.mb-5){margin-bottom:1.25rem}.filament-spatie-health :is(.mt-0){margin-top:0}.filament-spatie-health :is(.flex){display:flex}.filament-spatie-health :is(.grid){display:grid}.filament-spatie-health :is(.h-6){height:1.5rem}.filament-spatie-health :is(.w-6){width:1.5rem}.filament-spatie-health :is(.transform){transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.filament-spatie-health :is(.grid-cols-1){grid-template-columns:repeat(1,minmax(0,1fr))}.filament-spatie-health :is(.items-start){align-items:flex-start}.filament-spatie-health :is(.items-center){align-items:center}.filament-spatie-health :is(.justify-center){justify-content:center}.filament-spatie-health :is(.gap-6){gap:1.5rem}.filament-spatie-health :is(.space-x-2>:not([hidden])~:not([hidden])){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.filament-spatie-health :is(.overflow-hidden){overflow:hidden}.filament-spatie-health :is(.rounded-full){border-radius:9999px}.filament-spatie-health :is(.rounded-xl){border-radius:.75rem}.filament-spatie-health :is(.bg-blue-100){--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-emerald-100){--tw-bg-opacity:1;background-color:rgb(209 250 229/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-gray-100){--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-red-100){--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-white){--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.filament-spatie-health :is(.bg-yellow-100){--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.filament-spatie-health :is(.p-2){padding:.5rem}.filament-spatie-health :is(.px-4){padding-left:1rem;padding-right:1rem}.filament-spatie-health :is(.py-5){padding-bottom:1.25rem;padding-top:1.25rem}.filament-spatie-health :is(.text-center){text-align:center}.filament-spatie-health :is(.text-sm){font-size:.875rem;line-height:1.25rem}.filament-spatie-health :is(.font-bold){font-weight:700}.filament-spatie-health :is(.font-medium){font-weight:500}.filament-spatie-health :is(.text-blue-500){--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.filament-spatie-health :is(.text-emerald-500){--tw-text-opacity:1;color:rgb(16 185 129/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-400){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-500){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-600){--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.filament-spatie-health :is(.text-gray-900){--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.filament-spatie-health :is(.text-red-500){--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.filament-spatie-health :is(.text-yellow-500){--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity))}.filament-spatie-health :is(.text-opacity-0){--tw-text-opacity:0}.filament-spatie-health :is(.shadow-sm){--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filament-spatie-health :is(.shadow-gray-200){--tw-shadow-color:#e5e7eb;--tw-shadow:var(--tw-shadow-colored)}.filament-spatie-health :is(.transition){transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.filament-spatie-health :is(.dark .dark\:border-t){border-top-width:1px}.filament-spatie-health :is(.dark .dark\:border-gray-700){--tw-border-opacity:1;border-color:rgb(55 65 81/var(--tw-border-opacity))}.filament-spatie-health :is(.dark .dark\:bg-gray-900){--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity))}.filament-spatie-health :is(.dark .dark\:text-gray-200){--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.filament-spatie-health :is(.dark .dark\:text-gray-400){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.filament-spatie-health :is(.dark .dark\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.filament-spatie-health :is(.dark .dark\:shadow-md){--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filament-spatie-health :is(.dark .dark\:shadow-black\/25){--tw-shadow-color:rgba(0,0,0,.25);--tw-shadow:var(--tw-shadow-colored)}@media (min-width:640px){.filament-spatie-health :is(.sm\:grid-cols-2){grid-template-columns:repeat(2,minmax(0,1fr))}.filament-spatie-health :is(.sm\:p-6){padding:1.5rem}}@media (min-width:768px){.filament-spatie-health :is(.md\:mt-1){margin-top:.25rem}.filament-spatie-health :is(.md\:min-h-\[130px\]){min-height:130px}.filament-spatie-health :is(.md\:space-x-3>:not([hidden])~:not([hidden])){--tw-space-x-reverse:0;margin-left:calc(.75rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.75rem*var(--tw-space-x-reverse))}.filament-spatie-health :is(.md\:text-xl){font-size:1.25rem;line-height:1.75rem}}@media (min-width:1024px){.filament-spatie-health :is(.lg\:grid-cols-3){grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/resources/views/filament/pages/health.blade.php b/resources/views/filament/pages/health.blade.php new file mode 100644 index 0000000000..6d40330152 --- /dev/null +++ b/resources/views/filament/pages/health.blade.php @@ -0,0 +1,43 @@ + + @if (count($checkResults?->storedCheckResults ?? [])) + + @foreach ($checkResults->storedCheckResults as $result) + + {{ $result->label }} + +

+ @if (!empty($result->notificationMessage)) + {{ $result->notificationMessage }} + @else + {{ $result->shortSummary }} + @endif +

+ +
+ @endforeach +
+ @endif + + @if ($lastRanAt) +
+ Check results from {{ $lastRanAt->diffForHumans() }} +
+ @endif +
From 76039c843e430d8eb4b04d1d9db22b2c6573d270 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Thu, 18 Jul 2024 15:35:22 +0200 Subject: [PATCH 23/34] use health status indicator from spatie --- .../views/filament/pages/health.blade.php | 44 +++++++------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/resources/views/filament/pages/health.blade.php b/resources/views/filament/pages/health.blade.php index 6d40330152..6e942fc5b2 100644 --- a/resources/views/filament/pages/health.blade.php +++ b/resources/views/filament/pages/health.blade.php @@ -2,35 +2,21 @@ @if (count($checkResults?->storedCheckResults ?? [])) @foreach ($checkResults->storedCheckResults as $result) - - {{ $result->label }} - -

- @if (!empty($result->notificationMessage)) - {{ $result->notificationMessage }} - @else - {{ $result->shortSummary }} - @endif -

- -
+
+ +
+
+ {{ $result->label }} +
+
+ @if (!empty($result->notificationMessage)) + {{ $result->notificationMessage }} + @else + {{ $result->shortSummary }} + @endif +
+
+
@endforeach
@endif From 934554ab41d2c4a08535a5cd1429e6f3281277c1 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 28 Oct 2024 11:37:29 +0100 Subject: [PATCH 24/34] fix after merge --- app/Checks/NodeVersionsCheck.php | 1 + app/Checks/PanelVersionCheck.php | 2 +- app/Filament/Pages/Health.php | 6 +++ app/Providers/AppServiceProvider.php | 4 +- composer.lock | 76 ---------------------------- 5 files changed, 10 insertions(+), 79 deletions(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index 503d6f6c9c..72b0fbfb17 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -21,6 +21,7 @@ public function run(): Result return $result; } + // @phpstan-ignore-next-line $latestVersion = app(SoftwareVersionService::class)->getDaemon(); $outdated = Node::query()->get() diff --git a/app/Checks/PanelVersionCheck.php b/app/Checks/PanelVersionCheck.php index ee65dc7c88..b48782a373 100644 --- a/app/Checks/PanelVersionCheck.php +++ b/app/Checks/PanelVersionCheck.php @@ -11,7 +11,7 @@ class PanelVersionCheck extends Check public function run(): Result { /** @var SoftwareVersionService $versionService */ - $versionService = app(SoftwareVersionService::class); + $versionService = app(SoftwareVersionService::class); // @phpstan-ignore-line $isLatest = $versionService->isLatestPanel(); $currentVersion = $versionService->versionData()['version']; diff --git a/app/Filament/Pages/Health.php b/app/Filament/Pages/Health.php index 02a4813003..d9ab7508f0 100644 --- a/app/Filament/Pages/Health.php +++ b/app/Filament/Pages/Health.php @@ -13,10 +13,12 @@ class Health extends Page { protected static ?string $navigationIcon = 'tabler-heart'; + protected static ?string $navigationGroup = 'Advanced'; protected static string $view = 'filament.pages.health'; + // @phpstan-ignore-next-line protected $listeners = [ 'refresh-component' => '$refresh', ]; @@ -32,6 +34,7 @@ protected function getActions(): array protected function getViewData(): array { + // @phpstan-ignore-next-line $checkResults = app(ResultStore::class)->latestResults(); if ($checkResults === null) { @@ -60,6 +63,7 @@ public function refresh(): void public static function getNavigationBadge(): ?string { + // @phpstan-ignore-next-line $results = app(ResultStore::class)->latestResults(); if ($results === null) { @@ -82,6 +86,7 @@ public static function getNavigationBadgeColor(): string public static function getNavigationBadgeTooltip(): ?string { + // @phpstan-ignore-next-line $results = app(ResultStore::class)->latestResults(); if ($results === null) { @@ -103,6 +108,7 @@ public static function getNavigationBadgeTooltip(): ?string public static function getNavigationIcon(): string { + // @phpstan-ignore-next-line $results = app(ResultStore::class)->latestResults(); if ($results === null) { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5b40b957cf..daa55c5c1a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -103,9 +103,9 @@ public function boot(Application $app): void ]); // Don't run any health checks during tests - if (!app()->runningUnitTests()) { + if (!$app->runningUnitTests()) { Health::checks([ - DebugModeCheck::new()->if(app()->isProduction()), + DebugModeCheck::new()->if($app->isProduction()), EnvironmentCheck::new(), CacheCheck::new(), DatabaseCheck::new(), diff --git a/composer.lock b/composer.lock index c380826ded..ab382f7231 100644 --- a/composer.lock +++ b/composer.lock @@ -7049,82 +7049,6 @@ ], "time": "2022-04-22T08:51:55+00:00" }, - { - "name": "spatie/enum", - "version": "3.13.0", - "source": { - "type": "git", - "url": "https://github.com/spatie/enum.git", - "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/enum/zipball/f1a0f464ba909491a53e60a955ce84ad7cd93a2c", - "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": "^8.0" - }, - "require-dev": { - "fakerphp/faker": "^1.9.1", - "larapack/dd": "^1.1", - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "^4.3" - }, - "suggest": { - "fakerphp/faker": "To use the enum faker provider", - "phpunit/phpunit": "To use the enum assertions" - }, - "type": "library", - "autoload": { - "psr-4": { - "Spatie\\Enum\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Brent Roose", - "email": "brent@spatie.be", - "homepage": "https://spatie.be", - "role": "Developer" - }, - { - "name": "Tom Witkowski", - "email": "dev@gummibeer.de", - "homepage": "https://gummibeer.de", - "role": "Developer" - } - ], - "description": "PHP Enums", - "homepage": "https://github.com/spatie/enum", - "keywords": [ - "enum", - "enumerable", - "spatie" - ], - "support": { - "docs": "https://docs.spatie.be/enum", - "issues": "https://github.com/spatie/enum/issues", - "source": "https://github.com/spatie/enum" - }, - "funding": [ - { - "url": "https://spatie.be/open-source/support-us", - "type": "custom" - }, - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2022-04-22T08:51:55+00:00" - }, { "name": "spatie/fractalistic", "version": "2.9.5", From 9f266977dcffe9f6c391af4a54a7ceb9fb832923 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 8 Nov 2024 11:46:41 +0100 Subject: [PATCH 25/34] update icon --- .../views/filament/pages/health.blade.php | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/resources/views/filament/pages/health.blade.php b/resources/views/filament/pages/health.blade.php index 6e942fc5b2..e7fe57fb6d 100644 --- a/resources/views/filament/pages/health.blade.php +++ b/resources/views/filament/pages/health.blade.php @@ -1,9 +1,51 @@ +@php + if(! function_exists('backgroundColor')) { + function backgroundColor($status) { + return match ($status) { + Spatie\Health\Enums\Status::ok()->value => 'bg-emerald-100', + Spatie\Health\Enums\Status::warning()->value => 'bg-yellow-100', + Spatie\Health\Enums\Status::skipped()->value => 'bg-blue-100', + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'bg-red-100', + default => 'bg-gray-100' + }; + } + } + + if(! function_exists('iconColor')) { + function iconColor($status) + { + return match ($status) { + Spatie\Health\Enums\Status::ok()->value => 'text-emerald-500', + Spatie\Health\Enums\Status::warning()->value => 'text-yellow-500', + Spatie\Health\Enums\Status::skipped()->value => 'text-blue-500', + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'text-red-500', + default => 'text-gray-500' + }; + } + } + + if(! function_exists('icon')) { + function icon($status) + { + return match ($status) { + Spatie\Health\Enums\Status::ok()->value => 'tabler-circle-check', + Spatie\Health\Enums\Status::warning()->value => 'tabler-exclamation-circle', + Spatie\Health\Enums\Status::skipped()->value => 'tabler-circle-chevron-right', + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'tabler-circle-x', + default => '' + }; + } + } +@endphp + @if (count($checkResults?->storedCheckResults ?? [])) - + @foreach ($checkResults->storedCheckResults as $result)
- +
+ @svg(icon($result->status), "h-6 w-6 {{ iconColor($result->status) }}") +
{{ $result->label }} From 99ac970c9411a9baaac3ebf4fdf18af4737ee2af Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 8 Nov 2024 13:25:12 +0100 Subject: [PATCH 26/34] update color classes --- .../views/filament/pages/health.blade.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/views/filament/pages/health.blade.php b/resources/views/filament/pages/health.blade.php index e7fe57fb6d..bd983cbd6b 100644 --- a/resources/views/filament/pages/health.blade.php +++ b/resources/views/filament/pages/health.blade.php @@ -2,11 +2,11 @@ if(! function_exists('backgroundColor')) { function backgroundColor($status) { return match ($status) { - Spatie\Health\Enums\Status::ok()->value => 'bg-emerald-100', - Spatie\Health\Enums\Status::warning()->value => 'bg-yellow-100', - Spatie\Health\Enums\Status::skipped()->value => 'bg-blue-100', - Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'bg-red-100', - default => 'bg-gray-100' + Spatie\Health\Enums\Status::ok()->value => 'text-success-100', + Spatie\Health\Enums\Status::warning()->value => 'text-warning-100', + Spatie\Health\Enums\Status::skipped()->value => 'text-primary-100', + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'text-danger-100', + default => 'text-gray-100' }; } } @@ -15,10 +15,10 @@ function backgroundColor($status) { function iconColor($status) { return match ($status) { - Spatie\Health\Enums\Status::ok()->value => 'text-emerald-500', - Spatie\Health\Enums\Status::warning()->value => 'text-yellow-500', - Spatie\Health\Enums\Status::skipped()->value => 'text-blue-500', - Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'text-red-500', + Spatie\Health\Enums\Status::ok()->value => 'text-success-500', + Spatie\Health\Enums\Status::warning()->value => 'text-warning-500', + Spatie\Health\Enums\Status::skipped()->value => 'text-primary-500', + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'text-danger-500', default => 'text-gray-500' }; } @@ -32,7 +32,7 @@ function icon($status) Spatie\Health\Enums\Status::warning()->value => 'tabler-exclamation-circle', Spatie\Health\Enums\Status::skipped()->value => 'tabler-circle-chevron-right', Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'tabler-circle-x', - default => '' + default => 'tabler-help-circle' }; } } @@ -64,7 +64,7 @@ function icon($status) @endif @if ($lastRanAt) -
+
Check results from {{ $lastRanAt->diffForHumans() }}
@endif From a5aa4d83464e2f54f0b5cf5fbaa6fd85c7ffe5b0 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 18 Nov 2024 11:57:12 +0100 Subject: [PATCH 27/34] fix after merge --- app/Checks/PanelVersionCheck.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Checks/PanelVersionCheck.php b/app/Checks/PanelVersionCheck.php index b48782a373..a5bc3347ab 100644 --- a/app/Checks/PanelVersionCheck.php +++ b/app/Checks/PanelVersionCheck.php @@ -14,8 +14,8 @@ public function run(): Result $versionService = app(SoftwareVersionService::class); // @phpstan-ignore-line $isLatest = $versionService->isLatestPanel(); - $currentVersion = $versionService->versionData()['version']; - $latestVersion = $versionService->getPanel(); + $currentVersion = $versionService->currentPanelVersion(); + $latestVersion = $versionService->latestPanelVersion(); $result = Result::make() ->meta([ From d2422204b9c831509e9e63053dc5764a400a6435 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 9 Dec 2024 09:38:07 +0100 Subject: [PATCH 28/34] add back imports oops... --- app/Providers/AppServiceProvider.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index cad035c12a..728b0d7094 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,11 @@ namespace App\Providers; +use App\Checks\NodeVersionsCheck; +use App\Checks\PanelVersionCheck; +use App\Checks\UsedDiskSpaceCheck; +use App\Filament\Pages\Health; +use App\Filament\Server\Pages\Console; use App\Models; use App\Models\ApiKey; use App\Models\Node; @@ -11,6 +16,8 @@ use Dedoc\Scramble\Support\Generator\SecurityScheme; use Filament\Support\Colors\Color; use Filament\Support\Facades\FilamentColor; +use Filament\Support\Facades\FilamentView; +use Filament\View\PanelsRenderHook; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Foundation\Application; use Illuminate\Support\Facades\Event; @@ -21,6 +28,11 @@ use Illuminate\Support\Str; use Laravel\Sanctum\Sanctum; use SocialiteProviders\Manager\SocialiteWasCalled; +use Spatie\Health\Checks\Checks\CacheCheck; +use Spatie\Health\Checks\Checks\DatabaseCheck; +use Spatie\Health\Checks\Checks\DebugModeCheck; +use Spatie\Health\Checks\Checks\EnvironmentCheck; +use Spatie\Health\Checks\Checks\ScheduleCheck; class AppServiceProvider extends ServiceProvider { From 75feef130323a5a7a3534f330717ab3949e7953e Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 9 Dec 2024 09:42:24 +0100 Subject: [PATCH 29/34] wrong import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit oops²... --- app/Providers/AppServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 728b0d7094..6da2815d9c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,7 +5,6 @@ use App\Checks\NodeVersionsCheck; use App\Checks\PanelVersionCheck; use App\Checks\UsedDiskSpaceCheck; -use App\Filament\Pages\Health; use App\Filament\Server\Pages\Console; use App\Models; use App\Models\ApiKey; @@ -33,6 +32,7 @@ use Spatie\Health\Checks\Checks\DebugModeCheck; use Spatie\Health\Checks\Checks\EnvironmentCheck; use Spatie\Health\Checks\Checks\ScheduleCheck; +use Spatie\Health\Facades\Health; class AppServiceProvider extends ServiceProvider { From 5cec84fb4e3ff2162c5499e9a9a0221a7e95cc0e Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 9 Dec 2024 09:44:12 +0100 Subject: [PATCH 30/34] update spatie/laravel-health to latest --- composer.json | 4 ++-- composer.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index b8d3da48ab..231904fdce 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "socialiteproviders/discord": "^4.2", "socialiteproviders/steam": "^4.2", "spatie/laravel-fractal": "^6.2", - "spatie/laravel-health": "^1.29", + "spatie/laravel-health": "^1.30", "spatie/laravel-permission": "^6.9", "spatie/laravel-query-builder": "^5.8.1", "spatie/temporary-directory": "^2.2", @@ -93,4 +93,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 68253e11c8..8bbfc82f52 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": "d3b70b68927bf912d19adea9705d70ff", + "content-hash": "2fddfe7f5db269cdf9e906b83c815756", "packages": [ { "name": "abdelhamiderrahmouni/filament-monaco-editor", @@ -7441,16 +7441,16 @@ }, { "name": "spatie/laravel-health", - "version": "1.29.1", + "version": "1.30.1", "source": { "type": "git", "url": "https://github.com/spatie/laravel-health.git", - "reference": "1ea1950776038c94e225902fe71b063593e6539d" + "reference": "98e91b8a4b5ffc9086cf5d9cd2e7fa9cf1be0661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-health/zipball/1ea1950776038c94e225902fe71b063593e6539d", - "reference": "1ea1950776038c94e225902fe71b063593e6539d", + "url": "https://api.github.com/repos/spatie/laravel-health/zipball/98e91b8a4b5ffc9086cf5d9cd2e7fa9cf1be0661", + "reference": "98e91b8a4b5ffc9086cf5d9cd2e7fa9cf1be0661", "shasum": "" }, "require": { @@ -7523,7 +7523,7 @@ "spatie" ], "support": { - "source": "https://github.com/spatie/laravel-health/tree/1.29.1" + "source": "https://github.com/spatie/laravel-health/tree/1.30.1" }, "funding": [ { @@ -7531,7 +7531,7 @@ "type": "github" } ], - "time": "2024-06-27T07:11:39+00:00" + "time": "2024-08-02T14:01:48+00:00" }, { "name": "spatie/laravel-package-tools", @@ -13989,5 +13989,5 @@ "ext-zip": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From f7f0b123fb7ac6022501bd87c067c8dbe014abd8 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 9 Dec 2024 10:19:41 +0100 Subject: [PATCH 31/34] move Health page to correct namespace --- app/Filament/{ => Admin}/Pages/Health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename app/Filament/{ => Admin}/Pages/Health.php (98%) diff --git a/app/Filament/Pages/Health.php b/app/Filament/Admin/Pages/Health.php similarity index 98% rename from app/Filament/Pages/Health.php rename to app/Filament/Admin/Pages/Health.php index d9ab7508f0..b58c5211ba 100644 --- a/app/Filament/Pages/Health.php +++ b/app/Filament/Admin/Pages/Health.php @@ -1,6 +1,6 @@ Date: Mon, 9 Dec 2024 10:22:06 +0100 Subject: [PATCH 32/34] update NodeVersionsCheck --- app/Checks/NodeVersionsCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index 72b0fbfb17..5dc8f571c6 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -22,7 +22,7 @@ public function run(): Result } // @phpstan-ignore-next-line - $latestVersion = app(SoftwareVersionService::class)->getDaemon(); + $latestVersion = app(SoftwareVersionService::class)->latestWingsVersion(); $outdated = Node::query()->get() ->filter(fn (Node $node) => !isset($node->systemInformation()['exception']) && $node->systemInformation()['version'] !== $latestVersion) From 6e15de3a2877500820c3c7bc7da1bee8b946f46f Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 9 Dec 2024 10:33:23 +0100 Subject: [PATCH 33/34] use style instead of tailwind classes workaround until we have vite --- .../views/filament/pages/health.blade.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/resources/views/filament/pages/health.blade.php b/resources/views/filament/pages/health.blade.php index bd983cbd6b..13cf00aec7 100644 --- a/resources/views/filament/pages/health.blade.php +++ b/resources/views/filament/pages/health.blade.php @@ -2,11 +2,11 @@ if(! function_exists('backgroundColor')) { function backgroundColor($status) { return match ($status) { - Spatie\Health\Enums\Status::ok()->value => 'text-success-100', - Spatie\Health\Enums\Status::warning()->value => 'text-warning-100', - Spatie\Health\Enums\Status::skipped()->value => 'text-primary-100', - Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'text-danger-100', - default => 'text-gray-100' + Spatie\Health\Enums\Status::ok()->value => 'background-color: rgb(209 250 229);', // bg-emerald-100 + Spatie\Health\Enums\Status::warning()->value => 'background-color: rgb(254 249 195);', // bg-yellow-100 + Spatie\Health\Enums\Status::skipped()->value => 'background-color: rgb(219 234 254);', // bg-blue-100 + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'background-color: rgb(254 226 226);', // bg-red-100 + default => 'background-color: rgb(243 244 246);' // bg-gray-100 }; } } @@ -15,11 +15,11 @@ function backgroundColor($status) { function iconColor($status) { return match ($status) { - Spatie\Health\Enums\Status::ok()->value => 'text-success-500', - Spatie\Health\Enums\Status::warning()->value => 'text-warning-500', - Spatie\Health\Enums\Status::skipped()->value => 'text-primary-500', - Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'text-danger-500', - default => 'text-gray-500' + Spatie\Health\Enums\Status::ok()->value => 'color: rgb(16 185 129);', // text-emerald-500 + Spatie\Health\Enums\Status::warning()->value => 'color: rgb(234 179 8);', // text-yellow-500 + Spatie\Health\Enums\Status::skipped()->value => 'color: rgb(59 130 246);', // text-blue-500 + Spatie\Health\Enums\Status::failed()->value, Spatie\Health\Enums\Status::crashed()->value => 'color: rgb(239 68 68);', // text-red-500 + default => 'color: rgb(107 114 128);' // text-gray-500 }; } } @@ -43,14 +43,14 @@ function icon($status) @foreach ($checkResults->storedCheckResults as $result)
-
- @svg(icon($result->status), "h-6 w-6 {{ iconColor($result->status) }}") +
+
-
+
{{ $result->label }}
-
+
@if (!empty($result->notificationMessage)) {{ $result->notificationMessage }} @else @@ -64,7 +64,7 @@ function icon($status) @endif @if ($lastRanAt) -
+
Check results from {{ $lastRanAt->diffForHumans() }}
@endif From aebfc48b4dca58916b6c1e6c1c427a5850171535 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 13 Dec 2024 09:49:31 +0100 Subject: [PATCH 34/34] cleanup custom checks --- app/Checks/NodeVersionsCheck.php | 9 +++++---- app/Checks/PanelVersionCheck.php | 15 +++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Checks/NodeVersionsCheck.php b/app/Checks/NodeVersionsCheck.php index 5dc8f571c6..d3eeb63708 100644 --- a/app/Checks/NodeVersionsCheck.php +++ b/app/Checks/NodeVersionsCheck.php @@ -10,6 +10,8 @@ class NodeVersionsCheck extends Check { + public function __construct(private SoftwareVersionService $versionService) {} + public function run(): Result { $all = Node::query()->count(); @@ -21,8 +23,7 @@ public function run(): Result return $result; } - // @phpstan-ignore-next-line - $latestVersion = app(SoftwareVersionService::class)->latestWingsVersion(); + $latestVersion = $this->versionService->latestWingsVersion(); $outdated = Node::query()->get() ->filter(fn (Node $node) => !isset($node->systemInformation()['exception']) && $node->systemInformation()['version'] !== $latestVersion) @@ -36,7 +37,7 @@ public function run(): Result ->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated}/{$all} outdated"); return $outdated === 0 - ? $result->ok('All Nodes are up-to-date') - : $result->failed("`{$outdated}`/`{$all}` Nodes are outdated"); + ? $result->ok('All Nodes are up-to-date.') + : $result->failed(':outdated/:all Nodes are outdated.'); } } diff --git a/app/Checks/PanelVersionCheck.php b/app/Checks/PanelVersionCheck.php index a5bc3347ab..433bd7790a 100644 --- a/app/Checks/PanelVersionCheck.php +++ b/app/Checks/PanelVersionCheck.php @@ -8,14 +8,13 @@ class PanelVersionCheck extends Check { + public function __construct(private SoftwareVersionService $versionService) {} + public function run(): Result { - /** @var SoftwareVersionService $versionService */ - $versionService = app(SoftwareVersionService::class); // @phpstan-ignore-line - - $isLatest = $versionService->isLatestPanel(); - $currentVersion = $versionService->currentPanelVersion(); - $latestVersion = $versionService->latestPanelVersion(); + $isLatest = $this->versionService->isLatestPanel(); + $currentVersion = $this->versionService->currentPanelVersion(); + $latestVersion = $this->versionService->latestPanelVersion(); $result = Result::make() ->meta([ @@ -26,7 +25,7 @@ public function run(): Result ->shortSummary($isLatest ? 'up-to-date' : 'outdated'); return $isLatest - ? $result->ok('Panel is up-to-date') - : $result->failed("Installed version is `{$currentVersion}` but latest is `{$latestVersion}`"); + ? $result->ok('Panel is up-to-date.') + : $result->failed('Installed version is `:currentVersion` but latest is `:latestVersion`.'); } }