Sha256: b2fb5a819b334c16e01c56b458cf21802109314ea006824b7ff0d46d2667a431

Contents?: true

Size: 952 Bytes

Versions: 82

Compression:

Stored size: 952 Bytes

Contents

require_dependency "avo/application_controller"

module Avo
  module Dashboards
    class CardsController < ApplicationController
      before_action :set_dashboard
      before_action :set_card
      before_action :detect_chartkick

      def show
        render(:chartkick_missing) unless @chartkick_installed
      end

      private

      def set_dashboard
        @dashboard = Avo::App.get_dashboard_by_id params[:dashboard_id]

        raise ActionController::RoutingError.new("Not Found") if @dashboard.nil? || @dashboard.is_hidden?
      end

      def set_card
        @card = @dashboard.item_at_index(params[:index].to_i).tap do |card|
          card.hydrate(dashboard: @dashboard)
        end
      end

      def detect_chartkick
        @chartkick_installed = if @card.class.ancestors.map(&:to_s).include?("Avo::Dashboards::ChartkickCard")
          defined?(Chartkick)
        else
          true
        end
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
avo-2.28.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.27.2.pre.pr1606 app/controllers/avo/dashboards/cards_controller.rb
avo-2.27.1 app/controllers/avo/dashboards/cards_controller.rb
avo-2.27.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.26.3.pre.pr1601 app/controllers/avo/dashboards/cards_controller.rb
avo-2.26.2.pre.pr1579 app/controllers/avo/dashboards/cards_controller.rb
avo-2.26.1.pr1584.pre.1 app/controllers/avo/dashboards/cards_controller.rb
avo-2.25.1.pre.1.pr1579 app/controllers/avo/dashboards/cards_controller.rb
avo-2.26.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.25.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.24.1 app/controllers/avo/dashboards/cards_controller.rb
avo-2.24.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.23.3.pre.1.pr1529 app/controllers/avo/dashboards/cards_controller.rb
avo-2.23.2 app/controllers/avo/dashboards/cards_controller.rb
avo-2.23.1 app/controllers/avo/dashboards/cards_controller.rb
avo-2.23.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.22.0 app/controllers/avo/dashboards/cards_controller.rb
avo-2.21.3.pre.pr1489 app/controllers/avo/dashboards/cards_controller.rb
avo-2.21.2.pre.pr1486 app/controllers/avo/dashboards/cards_controller.rb
avo-2.21.1.pre.pr1484 app/controllers/avo/dashboards/cards_controller.rb