bjorndcode / nova-analytics Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I mentioned it in #3 already but came to a false conclusion.
The problem
All Cards I did not register with Nova::cards
will be returned with the call to /nova-vendor/bjorndcode/nova-analytics/cards
, but their own call to metrics/{metric}
will result in a 404.
The reason of the problem
When the metrics/{metric}
route is called nova looks for all Cards inside the $cards
array with the instance of Metric::class
. Since a card which was not registered with Nova never resides inside the $cards
array, no card is found and the abort(404)
is called.
// NovaRequest
public function metric()
{
return $this->availableMetrics()->first(function ($metric) {
return $this->metric === $metric->uriKey();
}) ?: abort(404);
}
public function availableMetrics()
{
return Nova::availableDashboardCards($this)->whereInstanceOf(Metric::class);
}
The quick and dirty solution
Adding the cards when they are needed and remove them right afterwards.
// AnalyticsToolController
public function index(NovaRequest $request)
{
\Nova::cards(AnalyticsDashboard::indexCards($request)->toArray());
return tap(AnalyticsDashboard::indexCards($request), function ($cards) {
\Nova::$cards = [];
});
}
the clean solution
The problem arises from the endpoint metrics/{metric}
which is called from the Metrics/ValueMetric.vue
class.
metricEndpoint() {
// ...
} else {
return `/nova-api/metrics/${this.card.uriKey}`
}
},
The Metrics/ValueMetric.vue
component is resolved from the CardWrapper.vue
. Which itself is resolved from the Cards.vue
component.
<component
// ...
:is="card.component"
// ...
/>
So to wrap it all up:
api.php
fileProblem: There's a fill on the svg element, while the fill should be dynamic & on the path element of the svg image.
This results in a fixed color for the icon which is not following the theme settings.
Expected behavior: The icon should follow the theme settings.
What we have now:
<svg fill="#B3C1D1" width="20" height="15" xmlns="http://www.w3.org/2000/svg" class="sidebar-icon">
<path d="..."></path>
</svg>
What it should be like:
<svg viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg" class="sidebar-icon">
<path fill="var(--sidebar-icon)" fill-rule="evenodd" d="..."></path>
</svg>
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.