johnpaulmedina/nova-metric-polling
Composer 安装命令:
composer require johnpaulmedina/nova-metric-polling
包简介
An extension of Laraval Nova Metrics to allow for interval polling.
README 文档
README
Laravel Nova Metric Polling
An extension of Laravel Nova Metrics to allow for interval polling. Want your Nova dashboard metrics up to date without refreshing, or having to apply a filter? These metrics extend the existing builtin Laravel Nova 4 Metrics and will allow for an interval duration to be set that will trigger an automatic refresh of any number of metrics displayed.
Simple integration to existing Nova\Metrics
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require johnpaulmedina/nova-metric-polling
The package will be automatically registered via the MetricPollingServiceProvider
Usage
First, add the following trait use Johnpaulmedina\NoveMetricPolling\ValueInterval to any of your Nova Metrics
<?php namespace App\Nova\Metrics; use Johnpaulmedina\NoveMetricPolling\ValueInterval;
Next, let your Metric class inherit the ValueInterval trait through the use keyword like so
<?php namespace App\Nova\Metrics; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Metrics\Value; use Laravel\Nova\Nova; use Johnpaulmedina\NovaMetricPolling\ValueInterval; class ActiveUsers extends Value { use ValueInterval;
Finally, instantiate your Metric and call the refreshAtInterval(Int: n) method.
The method accepts an integer value which will be calculated in seconds.
/** * Get the cards available for the request. * * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function cards(NovaRequest $request) { return [ (new Metrics\ActiveUsers())->refreshAtInterval(300), // (IE: 300 seconds / 60 = 5 minutes) ]; }
Alternatively, you may also set and integer value on the public property $refreshAtInterval.
<?php namespace App\Nova\Metrics; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Metrics\Value; use Laravel\Nova\Nova; use Johnpaulmedina\NovaMetricPolling\ValueInterval; class ActiveUsers extends Value { use ValueInterval; public $refreshAtInterval = 300; // (IE: 300 seconds / 60 = 5 minutes)
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 16.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-08