Coder Social home page Coder Social logo

saintsystems / nova-linkable-metrics Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 13.0 2.78 MB

Add custom router-links to your Laravel Nova metrics.

License: MIT License

JavaScript 23.65% Vue 59.33% PHP 16.98% CSS 0.04%
laravel laravel-nova laravel-nova-components

nova-linkable-metrics's People

Contributors

anderly avatar dependabot[bot] avatar lorenzosapora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nova-linkable-metrics's Issues

Document 'import' example results in fatal error

In your example docs you state:

// in your Nova value metric card class:
import SaintSystems\Nova\LinkableMetrics\LinkableValue;

use LinkableValue;

I have added these lines to my metric card class and I get a fatal error:

ParseError
syntax error, unexpected 'SaintSystems' (T_STRING)

Should the actual example be:

use LinkableValue;

or perhaps:

use SaintSystems\Nova\LinkableMetrics\LinkableValue;

?

Thank you.

feature: trend metric with date

Hi there

Thank you for a really nice component. I would like to suggest a feature to add (or perhaps you can suggest a way to achieve this with existing component)

When clicking on a trend metric, it would be great to receive the date that was clicked so we can link to relevant detail and not just one location for the entire trend.

Metrics card disappears after a split second

Hello,

Thank you for this very useful package.

I am updating the app to use Nova 4 and got an issue with the metric display. The card flushes for a split sec and then disappears. The console shows a TypeError as on the attached screenshot.

PHP: 8.0.27
Laravel: 9.52.4
Nova: 4.22.1
saintsystems/nova-linkable-metrics: 4.1.0

Thank you for suggesting how to fix it.

Screenshot 2023-03-07 at 9 20 47 am

Is this still maintained?

Sometimes nova packages stop getting maintained because there's a native solution. Is that the case here? Is there any other way to solve for linkable metrics?

Compatibility

Hi,

Is it or could be by any chance compatible with nova version ~2.0?

allowZeroResult() doesn't work with LinkableValue trait.

For instance:

return $this->result($ticketCount)->allowZeroResult()->route('index', ['resourceName' => 'tickets'], ['tickets_filter' => $filters]);

Still loads the "No current data" text, whereas on a regular card adding allowZeroResult() would hide the no current data text.

Partition Metrics

I'm trying to understand what this package does in the context of Partition Metrics? If a partition metric has 5 different partitions, does it allow you to add a different link to each partition? Or is it just one link for the whole card?

For instance, let's say your Partition Metric shows the status for products - "For Sale", "Sold", "Reserved". And I want each partition to link to the products resource page and filter by the status. Can I do that with this package?

Thanks!

Value metrics will broken when suffix is used

  • Laravel Version: 10.28.0
  • Nova Version: 4.27.14
  • PHP Version: 8.1.22
  • Database Driver & Version: mysql 8.0.34
  • Operating System and Version: Ubuntu 20.04.6 LTS(base on macOS 14 and homestead)
  • Browser type and version: Firefox 118.0.2

Description:

Nova-doc:https://nova.laravel.com/docs/metrics/defining-metrics.html#formatting-the-value

Detailed steps to reproduce the issue on a fresh Nova installation:

work ok

public function calculate(NovaRequest $request)
{
    return $this->max($request, Order::class, 'total')
                ->prefix('$');
}

work wrong

public function calculate(NovaRequest $request)
{
    return $this->max($request, Order::class, 'total')
                ->prefix('$')
                ->suffix('per unit');
}

error

TypeError: _util__WEBPACK_IMPORTED_MODULE_0__.singularOrPlural is not a function
    formattedSuffix linkable-metric:485
    run reactivity.esm-bundler.js:178
    get value reactivity.esm-bundler.js:1147
    get runtime-core.esm-bundler.js:3407
    default linkable-metric:1179
    r runtime-core.esm-bundler.js:766
    na runtime-core.esm-bundler.js:6995
    Vo runtime-core.esm-bundler.js:6806
    Go runtime-core.esm-bundler.js:6883
    Io runtime-core.esm-bundler.js:6733
    default linkable-metric:1164
    r runtime-core.esm-bundler.js:766
    oi runtime-core.esm-bundler.js:2824
    default LoadingCard.vue:11
    r runtime-core.esm-bundler.js:766
    oi runtime-core.esm-bundler.js:2824
    i Card.vue:3
    Wn runtime-core.esm-bundler.js:816
    effect runtime-core.esm-bundler.js:5764
    run reactivity.esm-bundler.js:178
    update runtime-core.esm-bundler.js:5814
    j runtime-core.esm-bundler.js:5641
    B runtime-core.esm-bundler.js:5576
    y runtime-core.esm-bundler.js:5040
    effect runtime-core.esm-bundler.js:5773
    run reactivity.esm-bundler.js:178
    update runtime-core.esm-bundler.js:5814
    j runtime-core.esm-bundler.js:5641
    B runtime-core.esm-bundler.js:5576
    y runtime-core.esm-bundler.js:5040
    effect runtime-core.esm-bundler.js:5773
    run reactivity.esm-bundler.js:178
    update runtime-core.esm-bundler.js:5814
    j runtime-core.esm-bundler.js:5641
    B runtime-core.esm-bundler.js:5576
    y runtime-core.esm-bundler.js:5040
    effect runtime-core.esm-bundler.js:5773
    run reactivity.esm-bundler.js:178
    update runtime-core.esm-bundler.js:5814
    cn runtime-core.esm-bundler.js:158
    On runtime-core.esm-bundler.js:357
    promise callback*_n runtime-core.esm-bundler.js:270
    An runtime-core.esm-bundler.js:264
    effect runtime-core.esm-bundler.js:5810
    Ie reactivity.esm-bundler.js:373
    Fe reactivity.esm-bundler.js:363
    Re reactivity.esm-bundler.js:337
    Xe reactivity.esm-bundler.js:487
    set runtime-core.esm-bundler.js:2986
    fetch linkable-metric:836
    promise callback*fetch linkable-metric:822
    created linkable-metric:799
    cn runtime-core.esm-bundler.js:158
    un runtime-core.esm-bundler.js:166
    un runtime-core.esm-bundler.js:176
    Li runtime-core.esm-bundler.js:3510
    Mi runtime-core.esm-bundler.js:3427
    _a runtime-core.esm-bundler.js:7341
    o runtime-core.esm-bundler.js:7265
    ba runtime-core.esm-bundler.js:7197
    D runtime-core.esm-bundler.js:5599
    B runtime-core.esm-bundler.js:5565
    y runtime-core.esm-bundler.js:5040
    effect runtime-core.esm-bundler.js:5708
    run reactivity.esm-bundler.js:178
    update runtime-core.esm-bundler.js:5814
    R runtime-core.esm-bundler.js:5822
    D runtime-core.esm-bundler.js:5613
    B runtime-core.esm-bundler.js:5565
    y runtime-core.esm-bundler.js:5040
    S runtime-core.esm-bundler.js:5285
    L runtime-core.esm-bundler.js:5499
    y runtime-core.esm-bundler.js:5015
    S runtime-core.esm-bundler.js:5285
    C runtime-core.esm-bundler.js:5191
    _ runtime-core.esm-bundler.js:5156
    y runtime-core.esm-bundler.js:5028
    S runtime-core.esm-bundler.js:5285
    C runtime-core.esm-bundler.js:5191
    _ runtime-core.esm-bundler.js:5156
runtime-core.esm-bundler.js:226:12

`

Metric card is not respecting calls to allowZeroResult()

When you use return $this->result(0)->allowZeroResult() in your calculate method, it should not display the phrase No Current Data in your card.

Nova default metric card is working as expected, but not the one from this package.

Digging a bit into the source code I found out that ValueMetric.vue from this package has this logic:

                <span v-else>
                    <span v-if="previous == '0' && value != '0'">
                        {{ __('No Prior Data') }}
                    </span>

                    <span v-if="value == '0' && previous != '0'">
                        {{ __('No Current Data') }}
                    </span>

                    <span v-if="value == '0' && previous == '0'">
                        {{ __('No Data') }}
                    </span>
                </span>```

But the code from Nova reads:
    <span v-else>
      <span v-if="previous == '0' && value != '0'">
        {{ __('No Prior Data') }}
      </span>

      <span v-if="value == '0' && previous != '0' && !zeroResult">
        {{ __('No Current Data') }}
      </span>

      <span v-if="value == '0' && previous == '0' && !zeroResult">
        {{ __('No Data') }}
      </span>
    </span>```

It seems this package is missing the && !zeroResult bit, which is what is causing the unexpected behavior.

Metrics no longer appear when using this package, no error messages.

I have installed the addon and when I use it within any of my metrics they no longer render on the dashboard. I have no errors at all.

code below:

use SaintSystems\Nova\LinkableMetrics\LinkableValue;

class PendingOrders extends Value
{
    use LinkableValue;
   
    //my class code
}

In my Nova Service Provider:

protected function cards()
{
        return [
              (new PendingOrders)->route('index', ['resourceName' => 'orders']),
        ]
}

When I refresh there is just a blank gap where the metric should render.

LinkableTrend trait makes graph dissapear

Captura de Pantalla 2019-09-04 a la(s) 15 31 16

Package version: 0.6
Nova Version: 2
Laravel Version: 5.8

Code:

class ContactsPerDay extends Trend
{
    use LinkableTrend;

    /**
     * Calculate the value of the metric.
     *
     * @param \Illuminate\Http\Request $request
     * @return mixed
     */
    public function calculate(Request $request)
    {
        return $this->countByDays($request, Contact::class);
    }

    /**
     * Get the ranges available for the metric.
     *
     * @return array
     */
    public function ranges()
    {
        return [
            30 => '30 Days',
            60 => '60 Days',
            90 => '90 Days',
        ];
    }

    /**
     * Determine for how many minutes the metric should be cached.
     *
     * @return  \DateTimeInterface|\DateInterval|float|int
     */
    public function cacheFor()
    {
        // return now()->addMinutes(5);
    }

    /**
     * Get the URI key for the metric.
     *
     * @return string
     */
    public function uriKey()
    {
        return 'contacts-per-day';
    }
}

ReferenceError: Minimum is not defined

Thanks for your useful package.

Since version 0.1.0 I have an error:
ReferenceError: Minimum is not defined

installed versions:
laravel/nova: 3.22.0
saintsystems/nova-linkable-metrics: 0.1.0

Any thoughts on this?

How do I link to a specific resource?

I am building a queuing system - when the user clicks on the linkable value I want to take them to a specific resource.

I am calling:

->route('index', ['resourceName' => 'members'])

Can I add an additional argument that will allow me to generate a URL like the following?

/resources/members/3838383

Thank you.

LinkablePartition function result unable to handle PartitionResult

The result() function in LinkablePartition input type (array) is incompatible with the output of the query (PartitionResult). Found on Laravel Nova 2.0.5.

For example when the following is used in the calculate() function of a Partition metric:

return $this->result(
	$this->count( $request, $data_query, 'status' )
)->route( 'index', $route_params, $route_query );

This fails with error:

Argument 1 passed to App\Nova\Metrics\GamesPerStatus::result() must be of the type array, object given

Unfortunately this cannot be fixed by changing input type from array to in LinkablePartition.php:

public function result(PartitionResult $value)

as this results in:

Declaration of SaintSystems\Nova\LinkableMetrics\LinkablePartition::result(Laravel\Nova\Metrics\PartitionResult $value) should be compatible with Laravel\Nova\Metrics\Partition::result(array $value)

Link to a specific tab

Hey,

Using the tab package, the currently selected tab is reflected into the url ( /resources/users/123/#Campaign=sent ).

Is it currently possible to link to that in this version? If so, point it out and I'll write a PR for the README. If not, tag this with a feature-request.

Thanks

Call to undefined method App\Nova\Metrics\ProfilesToApprove::route()

I am encountering the following fatal error within my NovaServiceProvider class:

Error
Call to undefined method App\Nova\Metrics\ProfilesToApprove::route()

The code is:

    protected function cards()
    {
        return [
            (new ProfilesToApprove)->route('lens', ['resourceName' => 'members', 'lens' => 'testlens']),
        ];
    }

The card has:

use SaintSystems\Nova\LinkableMetrics\LinkableValue;

Range select box is not populating

Screenshot 2019-06-24 at 08 13 16

When you select a different date range, the box re-renders with the updated figure correctly, but the select box doesn't populate with the value. It looks like an issue with the components. Should be easy to fix but I can't work out how to recompile the assets.

resourceName with slash

Przechwytywanie

My URL looks like this:
https://xxx/nova/resources/bids%2Flens%2Fwon-pre-bids

Slashes have been replaced with %2

Adding LinkableValue trait disrupts time formatting

I have a metric card that uses ->format('output: "time"'). Without any other changes, simply adding "use LinkableValue" at the top changes the time output 00:00:00 to "0th". Is there something I should be doing differently?

Nova 4 support?

Anyone got a fork that's working on Nova 4? The front-end components need to be re-built with Vue 3 and I've been struggling to get a working solution

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.