Giter VIP home page Giter VIP logo

nova-analytics's People

Contributors

bjorndcode avatar blackfyre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nova-analytics's Issues

Cards not registered with Nova load forever on the Analytics pages

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:

  • build a own Cards, CardWrapper & all Metrics Vue Component and point it to a different endpoint
  • add routes to the api.php file
  • mirror Nova's metrics request logic

Analytics Menu icon not following theme settings

Problem: 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>

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.