saintsystems / nova-linkable-metrics Goto Github PK
View Code? Open in Web Editor NEWAdd custom router-links to your Laravel Nova metrics.
License: MIT License
Add custom router-links to your Laravel Nova metrics.
License: MIT License
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.
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.
Does it have to be a lens or can we link with a filter? Would be great to be able to do that as well.
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.
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?
Hi,
Is it or could be by any chance compatible with nova version ~2.0?
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.
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!
Nova-doc:https://nova.laravel.com/docs/metrics/defining-metrics.html#formatting-the-value
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
`
This does not seem to work on Nova 3. Is this still maintained?
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.
Can anyone give me an example on how to use the LinkakleTrend
. I can not find my way around it.
Hey, I've already pushed a PR for another of your nova repos, and this is suffering from the same issue. I'll push a PR for this, but the details are here: saintsystems/nova-resource-group-menu#2
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.
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';
}
}
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?
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.
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)
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
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;
In the latest verison of nova, the package doesn't do anything at all. There's no change at all to the cards after implementing the code for this package.
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?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.