From 4925bdebd1ccfaf1c047671257c45388f8ae5bd6 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 1 Jan 2024 20:18:31 +0100 Subject: [PATCH] wip --- README.md | 62 ++++++++++++------- config/ohdear-pulse.php | 6 -- .../OhDearBrokenLinksCardComponent.php | 8 ++- src/OhDearPulseServiceProvider.php | 1 - 4 files changed, 43 insertions(+), 34 deletions(-) delete mode 100644 config/ohdear-pulse.php diff --git a/README.md b/README.md index 3b56533..69b8c8c 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,21 @@ [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/ohdearapp/ohdear-pulse/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/ohdearapp/ohdear-pulse/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/ohdearapp/ohdear-pulse.svg?style=flat-square)](https://packagist.org/packages/ohdearapp/ohdear-pulse) -This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. +This package contains Pulse cards that show results from [Oh Dear](https://ohdear.app) in your [Laravel Pulse](https://pulse.laravel.com) dashboard. -## Support us +Currently, there are three cards available: -[](https://spatie.be/github-ad-click/ohdear-pulse) +- [Uptime and Performance](https://ohdear.app/docs/features/uptime-monitoring) -We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). +TODO: add screenshot -We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). +- [Cron Job Monitoring](https://ohdear.app/docs/features/cron-job-monitoring) + +TODO: add screenshot + +- [Broken links](https://ohdear.app/docs/features/broken-links-detection) +- +TODO: add screenshot ## Installation @@ -23,37 +29,45 @@ You can install the package via composer: composer require ohdearapp/ohdear-pulse ``` -You can publish and run the migrations with: +In your `config/services.php` file, add the following lines: -```bash -php artisan vendor:publish --tag="ohdear-pulse-migrations" -php artisan migrate +```php +'oh_dear' => [ + 'pulse' => [ + 'api_key' => env('OH_DEAR_API_TOKEN'), + 'site_id' => env('OH_DEAR_SITE_ID'), + ], +], ``` -You can publish the config file with: +You can create an API token on the "API Tokens" page at Oh Dear. You'll find the site ID on the "Settings" page of a site on Oh Dear. -```bash -php artisan vendor:publish --tag="ohdear-pulse-config" -``` +## Usage -This is the contents of the published config file: +There are currently three cards available: -```php -return [ -]; -``` +- `ohdear.pulse.uptime`: displays the uptime and performance of a site +- `ohdear.pulse.cron`: displays the results of the cron job monitoring +- `ohdear.pulse.brokenLinks`: displays any broken links that were detected -Optionally, you can publish the views using +You can add the cards to your Pulse dashboard, by first publishing the Pulse's dashboard view: ```bash -php artisan vendor:publish --tag="ohdear-pulse-views" +php artisan vendor:publish --tag=pulse-dashboard ``` -## Usage +Next, add the cards to the `resources/views/vendor/pulse/dashboard.blade.php` file: -```php -$ohDearPulse = new OhDear\OhDearPulse(); -echo $ohDearPulse->echoPhrase('Hello, OhDear!'); +```html + + + + + + + + {{-- Add more cards here --}} + ``` ## Testing diff --git a/config/ohdear-pulse.php b/config/ohdear-pulse.php deleted file mode 100644 index fa2208b..0000000 --- a/config/ohdear-pulse.php +++ /dev/null @@ -1,6 +0,0 @@ -isConfigured()) { + if (!$this->isConfigured()) { return null; } return $this->remember( - fn () => $this->ohDear()?->brokenLinks($this->siteId), - 'site:'.$this->siteId, + fn() => $this->ohDear()?->brokenLinks($this->siteId), + 'site:' . $this->siteId, + CarbonInterval::minutes(15) ); } } diff --git a/src/OhDearPulseServiceProvider.php b/src/OhDearPulseServiceProvider.php index 5de8417..331ade8 100644 --- a/src/OhDearPulseServiceProvider.php +++ b/src/OhDearPulseServiceProvider.php @@ -16,7 +16,6 @@ public function configurePackage(Package $package): void { $package ->name('ohdear-pulse') - ->hasConfigFile() ->hasViews(); }