-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7009463
Showing
15 changed files
with
5,802 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# Mac OS X | ||
.DS_Store | ||
._.* | ||
._* | ||
|
||
# Ignore local editor | ||
.project | ||
.settings | ||
/.idea | ||
/.vscode | ||
*.swp | ||
tags | ||
nbproject/* | ||
|
||
# Windows | ||
Thumbs.db | ||
|
||
auth.json | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
.env | ||
.env.backup | ||
phpunit.xml | ||
.phpunit.result.cache | ||
docker-compose.override.yml | ||
Homestead.json | ||
Homestead.yaml | ||
|
||
config/version.yml | ||
|
||
_ide_helper.php | ||
_ide_helper_models.php | ||
.phpstorm.meta.php | ||
lighthouse-audit* | ||
.nova | ||
|
||
/node_modules | ||
/vendor | ||
|
||
package-lock.json | ||
composer.phar | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Artem Stepanenko | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Laravel Nova tool for checking healthy of your Laravel app | ||
|
||
## Credits | ||
|
||
- [Artem Stepanenko(Author & Maintainer)](https://github.com/stepanenko3) | ||
|
||
## Contributing | ||
|
||
Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing. | ||
|
||
## License | ||
|
||
This package is open-sourced software licensed under the [MIT license](LICENSE.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "stepanenko3/nova-health", | ||
"description": "Laravel Nova tool for checking healthy of your Laravel app", | ||
"keywords": ["laravel", "nova", "health"], | ||
"license": "MIT", | ||
"require": { | ||
"php": ">=8.0", | ||
"laravel/nova": "^4.0", | ||
"spatie/laravel-health": "^1.9", | ||
"spatie/cpu-load-health-check": "^1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Stepanenko3\\NovaHealth\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Stepanenko3\\NovaHealth\\ToolServiceProvider" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "stable", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
'path' => 'health', | ||
|
||
'navigation_label' => 'Nova Health', | ||
]; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"/js/entry.js": "/js/entry.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "mix", | ||
"watch": "mix watch", | ||
"hot": "mix watch --hot", | ||
"prod": "mix --production", | ||
"format": "prettier --write 'resources/**/*.{css,js,vue}'" | ||
}, | ||
"devDependencies": { | ||
"@inertiajs/inertia": "^0.11.0", | ||
"@vue/babel-plugin-jsx": "^1.1.1", | ||
"axios": "^0.26.1", | ||
"cross-env": "^7.0.3", | ||
"form-backend-validation": "^2.4.0", | ||
"laravel-mix": "^6.0.43", | ||
"postcss": "^8.4.12", | ||
"prettier": "^2.6.2", | ||
"resolve-url-loader": "^5.0.0", | ||
"sass": "^1.50.0", | ||
"sass-loader": "^12.6.0", | ||
"terser-webpack-plugin": "^5.3.1", | ||
"vue-loader": "^17.0.0", | ||
"vue-template-compiler": "^2.6.14", | ||
"vuex": "^4.0.2" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.2.31" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Nova.booting((Vue, router, store) => { | ||
Nova.inertia('NovaHealth', require('./views/Health').default); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<template> | ||
<Heading :level="1" class="flex items-center justify-between mb-6"> | ||
<span> | ||
{{ __('Health') }} | ||
</span> | ||
|
||
<span | ||
v-if="finishedAt" | ||
class="text-base ml-4" | ||
> | ||
{{ finishedAt }} | ||
</span> | ||
|
||
<LoadingButton | ||
class="relative ml-auto" | ||
size="xs" | ||
component="LinkButton" | ||
:disabled="loading" | ||
:loading="loading" | ||
@click="load" | ||
> | ||
<Icon type="refresh" /> | ||
</LoadingButton> | ||
</Heading> | ||
|
||
<Loader v-if="loading" /> | ||
|
||
<div | ||
class="grid md:grid-cols-12 gap-6" | ||
v-if="!loading && checks.length" | ||
> | ||
<Card | ||
class="md:col-span-4 h-full p-6 flex items-start" | ||
v-for="check in checks" | ||
> | ||
<Icon | ||
width="30" | ||
height="30" | ||
class="mr-4 flex-shrink-0" | ||
:class="getByStatus(check.status, { | ||
ok: 'text-green-500', | ||
warning: 'text-yellow-500', | ||
skipped: 'text-blue-500', | ||
failed: 'text-red-500', | ||
crashed: 'text-red-500', | ||
default: 'text-gray-500', | ||
})" | ||
:type="getByStatus(check.status, { | ||
ok: 'check-circle', | ||
warning: 'exclamation-circle', | ||
skipped: 'arrow-circle-right', | ||
failed: 'x-circle', | ||
crashed: 'x-circle', | ||
default: 'dots-circle-horizontal', | ||
})" | ||
/> | ||
|
||
<div> | ||
<Heading | ||
level="3" | ||
v-text="check.label" | ||
/> | ||
<div class="text-sm mt-2"> | ||
{{ check.notificationMessage || check.shortSummary }} | ||
</div> | ||
</div> | ||
</Card> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data: () => ({ | ||
loading: true, | ||
checks: [], | ||
finishedAt: null, | ||
}), | ||
mounted() { | ||
this.load(); | ||
}, | ||
methods: { | ||
load() { | ||
this.loading = true; | ||
Nova.request().get('/nova-vendor/stepanenko3/nova-health') | ||
.then(response => { | ||
if (response.status && response.data) { | ||
this.loading = false; | ||
this.checks = response.data.checkResults; | ||
const d = new Date(response.data.finishedAt * 1000); | ||
const dateString = | ||
("0" + d.getDate()).slice(-2) | ||
+ "/" + ("0" + (d.getMonth() + 1)).slice(-2) | ||
+ "/" + d.getFullYear() | ||
+ " " | ||
+ ("0" + d.getHours()).slice(-2) | ||
+ ":" + ("0" + d.getMinutes()).slice(-2); | ||
this.finishedAt = dateString; | ||
} else { | ||
Nova.error('Error'); | ||
} | ||
}); | ||
}, | ||
getByStatus(status, data) { | ||
if (data.hasOwnProperty(status)) { | ||
return data[status]; | ||
} | ||
return data.default; | ||
} | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Spatie\Health\Http\Controllers\HealthCheckJsonResultsController; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Tool API Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here is where you may register API routes for your tool. These routes | ||
| are loaded by the ServiceProvider of your tool. They are protected | ||
| by your tool's "Authorize" middleware by default. Now, go build! | ||
| | ||
*/ | ||
|
||
Route::get('/', HealthCheckJsonResultsController::class); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Stepanenko3\NovaHealth; | ||
|
||
use Laravel\Nova\Nova; | ||
use Laravel\Nova\Tool; | ||
use Illuminate\Http\Request; | ||
use Laravel\Nova\Menu\MenuSection; | ||
|
||
class HealthTool extends Tool | ||
{ | ||
public function boot() | ||
{ | ||
Nova::script('nova-health', __DIR__ . '/../dist/js/entry.js'); | ||
} | ||
|
||
public function menu(Request $request) | ||
{ | ||
return MenuSection::make(__(config('nova-health.navigation_label', 'Health'))) | ||
->path('/health'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Stepanenko3\NovaHealth; | ||
|
||
use Laravel\Nova\Nova; | ||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class ToolServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
// Publish config | ||
$this->publishes([ | ||
__DIR__ . '/../config/' => config_path(), | ||
], 'config'); | ||
} | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->registerRoutes(); | ||
|
||
$this->mergeConfigFrom( | ||
__DIR__ . '/../config/nova-health.php', | ||
'nova-health' | ||
); | ||
} | ||
|
||
protected function registerRoutes() | ||
{ | ||
// Register nova routes | ||
Nova::router()->group(function ($router) { | ||
$path = config('nova-health.path', 'health'); | ||
$router->get($path, fn () => inertia('NovaHealth', ['basePath' => $path])); | ||
}); | ||
|
||
if ($this->app->routesAreCached()) return; | ||
|
||
Route::prefix('nova-vendor/stepanenko3/nova-health') | ||
->group(__DIR__.'/../routes/api.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
let mix = require('laravel-mix'); | ||
let path = require('path'); | ||
|
||
mix | ||
.setPublicPath('dist') | ||
.js('resources/js/entry.js', 'js') | ||
.vue({ version: 3 }) | ||
.webpackConfig({ | ||
externals: { | ||
vue: 'Vue', | ||
}, | ||
output: { | ||
uniqueName: 'stepanenko3/nova-health', | ||
}, | ||
}) | ||
.alias({ | ||
'laravel-nova': path.join(__dirname, 'vendor/laravel/nova/resources/js/mixins/packages.js'), | ||
}); |
Oops, something went wrong.