musa11971/nova-status-card

Display a status card on your Laravel Nova dashboard.

1.0 2021-04-29 16:57 UTC

This package is auto-updated.

Last update: 2021-05-29 17:13:32 UTC


README

package.png

Latest version on packagist Total downloads

Display useful status information

This Laravel Nova package allows you to easily display useful status information on your Nova dashboard.

Installation

You can install the package via composer:

composer require musa11971/nova-status-card

Usage

Add the card to your dashboard using NovaServiceProvider.

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Get the cards that should be displayed on the default Nova dashboard.
     *
     * @return array
     */
    protected function cards()
    {
        return [
            NovaStatusCard::make()
                ->title('Server Status')
                ->items([
                    NovaStatusItem::make('Database Usage')
                        ->percentage()
                        ->value(function() {
                            // Calculate value...
                            return 55.43;
                        }),
                        
                    NovaStatusItem::make('Redis Server')
                        ->statusIndicator()
                        ->value(function($value) {
                            // Perform check...
                            return $value->ok();
                        })
                ])
        ];
    }
}

Which produces the following:
example_1.png

Types

There are currently 3 types of status items.

String

NovaStatusItem::make('Department Condition')
    ->string()
    ->value(Department::first()->condition)

example_2.png

Percentage

NovaStatusItem::make('Database Usage')
    ->percentage()
    ->value(function() {
        // Calculate value...
        return 55.43;
    })

example_3.png

Status indicator

NovaStatusItem::make('MySQL Server Status')
    ->statusIndicator()
    ->value(function($value) {
        return $value->ok();
        // or:
        // $value->danger();
        // $value->risky();
        // $value->unknown();
    })

example_4.png

Status indicators also support passing a hint, which will be display as the HTML 'title' attribute. Useful for displaying additional information.

NovaStatusItem::make('MySQL Server Status')
    ->statusIndicator()
    ->value(function($value) {
        return $value->risky()->hint('Server responded slowly.');
    })

example_5.png

Contributing

Pull requests are welcomed.

Security

If you discover any security related issues, please email mussesemou99@gmail.com instead of using the issue tracker.

Credits

Credits go to musa11971 for creating and maintaining the package.

Special thanks

Support me

I am a full-time software engineering student and work on this package in my free time. If you find the package useful, please consider making a donation! Every little bit helps. 💜

License

The MIT License (MIT). Please see License File for more information.