-
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.
Showing
19 changed files
with
413 additions
and
1 deletion.
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,10 @@ | ||
/.idea | ||
/vendor | ||
/node_modules | ||
package-lock.json | ||
composer.phar | ||
composer.lock | ||
phpunit.xml | ||
.phpunit.result.cache | ||
.DS_Store | ||
Thumbs.db |
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 |
---|---|---|
@@ -1 +1,47 @@ | ||
# nova-version-card | ||
# Nova Version Card (Laravel Nova 4.0+) | ||
|
||
Get the versions of the basic system services of the server running your web application right from your Nova dashboard. This is based on the work of [Chris Bautista](https://github.com/CoreProc/nova-system-info-card) | ||
|
||
![version card screenshot](https://github.com/Kussie/nova-version-card/blob/main/screenshot.png?raw=true) | ||
|
||
## Installation | ||
|
||
You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer: | ||
|
||
```bash | ||
composer require kussie/nova-version-card | ||
``` | ||
|
||
## Usage | ||
|
||
Register the card within your Dashboard in Nova. This is typically done in the `cards` method of your Dashboard file for example `Dashboard/Main.php`. | ||
|
||
```php | ||
// ... | ||
public function cards() | ||
{ | ||
return [ | ||
// ... | ||
new \Kussie\VersionCard\VersionCard(), | ||
]; | ||
} | ||
``` | ||
|
||
### Testing | ||
|
||
``` bash | ||
composer test | ||
``` | ||
|
||
### Security | ||
|
||
If you discover any security related issues, please email ben@kussie.com.au instead of using the issue tracker. | ||
|
||
## Credits | ||
|
||
- [Chris Bautista](https://github.com/chrisbjr) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
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,46 @@ | ||
{ | ||
"name": "kussie/nova-version-card", | ||
"description": "A Laravel Nova card to show some system versions.", | ||
"keywords": [ | ||
"laravel", | ||
"nova" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Ben Kuskopf", | ||
"email": "ben@kussie.com.au", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.3|^8.0", | ||
"laravel/nova": "^4.0" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "^3.6", | ||
"phpunit/phpunit": "7.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Kussie\\VersionCard\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Kussie\\VersionCard\\Tests\\": "tests/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Kussie\\VersionCard\\CardServiceProvider" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev", | ||
"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 @@ | ||
|
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,4 @@ | ||
{ | ||
"/js/card.js": "/js/card.js", | ||
"/css/card.css": "/css/card.css" | ||
} |
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,33 @@ | ||
const mix = require('laravel-mix') | ||
const webpack = require('webpack') | ||
const path = require('path') | ||
|
||
class NovaExtension { | ||
name() { | ||
return 'nova-extension' | ||
} | ||
|
||
register(name) { | ||
this.name = name | ||
} | ||
|
||
webpackConfig(webpackConfig) { | ||
webpackConfig.externals = { | ||
vue: 'Vue', | ||
} | ||
|
||
webpackConfig.resolve.alias = { | ||
...(webpackConfig.resolve.alias || {}), | ||
'laravel-nova': path.join( | ||
__dirname, | ||
'../../vendor/laravel/nova/resources/js/mixins/packages.js' | ||
), | ||
} | ||
|
||
webpackConfig.output = { | ||
uniqueName: this.name, | ||
} | ||
} | ||
} | ||
|
||
mix.extend('nova', new NovaExtension()) |
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,19 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "npm run development", | ||
"development": "mix", | ||
"watch": "mix watch", | ||
"watch-poll": "mix watch -- --watch-options-poll=1000", | ||
"hot": "mix watch --hot", | ||
"prod": "npm run production", | ||
"production": "mix --production" | ||
}, | ||
"devDependencies": { | ||
"@vue/compiler-sfc": "^3.2.22", | ||
"laravel-mix": "^6.0.41", | ||
"postcss": "^8.3.11", | ||
"vue-loader": "^16.8.3" | ||
}, | ||
"dependencies": {} | ||
} |
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 @@ | ||
/* Nova Card CSS */ |
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,5 @@ | ||
import Card from './components/Card' | ||
|
||
Nova.booting((app, store) => { | ||
app.component('version-card', Card) | ||
}) |
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,63 @@ | ||
<template> | ||
<Card class="flex flex-col"> | ||
<div class="p-6"> | ||
<Heading :level="3">System Versions</Heading> | ||
<table class="w-full text-left table-collapse"> | ||
<tbody class="align-baseline"> | ||
<tr> | ||
<td class="p-2 font-bold">OS</td> | ||
<td class="p-2">{{ os }}</td> | ||
</tr> | ||
<tr> | ||
<td class="p-2 font-bold">PHP Version</td> | ||
<td class="p-2">{{ php }}</td> | ||
</tr> | ||
<tr> | ||
<td class="p-2 font-bold">Database</td> | ||
<td class="p-2">{{ database }}</td> | ||
</tr> | ||
<tr> | ||
<td class="p-2 font-bold">Laravel Version</td> | ||
<td class="p-2">{{ laravel }}</td> | ||
</tr> | ||
<tr> | ||
<td class="p-2 font-bold">Nova Version</td> | ||
<td class="p-2">{{ nova }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</Card> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: [ | ||
'card', | ||
// The following props are only available on resource detail cards... | ||
// 'resource', | ||
// 'resourceId', | ||
// 'resourceName', | ||
], | ||
data () { | ||
return { | ||
os: null, | ||
php: null, | ||
database: null, | ||
} | ||
}, | ||
mounted() { | ||
Nova.request().get('/nova-vendor/kussie/version-card/versions') | ||
.then(({data}) => { | ||
this.os = data.os | ||
this.php = data.php | ||
this.database = data.database | ||
this.laravel = data.laravel | ||
this.nova = data.nova | ||
}) | ||
}, | ||
} | ||
</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,17 @@ | ||
<?php | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Card API Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here is where you may register API routes for your card. These routes | ||
| are loaded by the ServiceProvider of your card. You're free to add | ||
| as many additional routes to this file as your card may require. | ||
| | ||
*/ | ||
|
||
Route::get('versions', \Kussie\VersionCard\Http\Controllers\VersionController::class.'@versions'); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 Kussie\VersionCard; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Support\ServiceProvider; | ||
use Laravel\Nova\Events\ServingNova; | ||
use Laravel\Nova\Nova; | ||
|
||
class CardServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->app->booted(function () { | ||
$this->routes(); | ||
}); | ||
|
||
Nova::serving(function (ServingNova $event) { | ||
Nova::script('version-card', __DIR__.'/../dist/js/card.js'); | ||
Nova::style('version-card', __DIR__.'/../dist/css/card.css'); | ||
}); | ||
} | ||
|
||
/** | ||
* Register the card's routes. | ||
* | ||
* @return void | ||
*/ | ||
protected function routes() | ||
{ | ||
if ($this->app->routesAreCached()) { | ||
return; | ||
} | ||
|
||
Route::middleware(['nova']) | ||
->prefix('nova-vendor/kussie/version-card') | ||
->group(__DIR__.'/../routes/api.php'); | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Kussie\VersionCard\Http\Controllers; | ||
|
||
use DB; | ||
use Laravel\Nova\Nova; | ||
|
||
class VersionController | ||
{ | ||
public function versions() | ||
{ | ||
return [ | ||
'os' => php_uname('s') . ' (' . php_uname('r') . ' - ' . php_uname('v') . ')', | ||
'php' => phpversion(), | ||
'database' => $this->getDatabase(), | ||
'laravel' => app()->version(), | ||
'nova' => Nova::version(), | ||
]; | ||
} | ||
|
||
private function getDatabase() | ||
{ | ||
$knownDatabases = [ | ||
'sqlite', | ||
'mysql', | ||
'pgsql', | ||
'sqlsrv', | ||
]; | ||
|
||
if (! in_array(config('database.default'), $knownDatabases)) { | ||
return 'Unkown'; | ||
} | ||
|
||
$results = DB::select(DB::raw("select version()")); | ||
|
||
return $results[0]->{'version()'}; | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace Kussie\VersionCard; | ||
|
||
use Laravel\Nova\Card; | ||
|
||
class VersionCard extends Card | ||
{ | ||
/** | ||
* The width of the card (1/3, 1/2, or full). | ||
* | ||
* @var string | ||
*/ | ||
public $width = '1/2'; | ||
|
||
/** | ||
* Get the component name for the element. | ||
* | ||
* @return string | ||
*/ | ||
public function component() | ||
{ | ||
return 'version-card'; | ||
} | ||
} |
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 Kussie\VersionCard\Tests; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Orchestra\Testbench\TestCase as Orchestra; | ||
use Kussie\VersionCard\CardServiceProvider; | ||
|
||
abstract class TestCase extends Orchestra | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
Route::middlewareGroup('nova', []); | ||
} | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
CardServiceProvider::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,17 @@ | ||
<?php | ||
|
||
namespace Kussie\VersionCard\Tests; | ||
|
||
class VersionControllerTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_returns_system_information() | ||
{ | ||
$content = $this->get('nova-vendor/kussie/nova-version-card/versions') | ||
->getContent(); | ||
|
||
$systemInfo = json_decode($content, true); | ||
|
||
$this->assertSame(app()->version(), $systemInfo['laravel']); | ||
} | ||
} |
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,10 @@ | ||
let mix = require('laravel-mix') | ||
|
||
require('./mix') | ||
|
||
mix | ||
.setPublicPath('dist') | ||
.js('resources/js/card.js', 'js') | ||
.vue({ version: 3 }) | ||
.css('resources/css/card.css', 'css') | ||
.nova('kussie/nova-version-card') |