johnpaulmedina/nova-metric-polling 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

johnpaulmedina/nova-metric-polling

Composer 安装命令:

composer require johnpaulmedina/nova-metric-polling

包简介

An extension of Laraval Nova Metrics to allow for interval polling.

README 文档

README

Latest Version on Packagist Total Downloads

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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固