Module: IfdTools::ActiveAdmin::Dashboard::Tracking

Defined in:
lib/ifd_tools/active_admin/dashboard/tracking.rb

Class Method Summary collapse

Class Method Details

.included(dsl) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ifd_tools/active_admin/dashboard/tracking.rb', line 6

def self.included(dsl)

  index_page_presenter = dsl.config.get_page_presenter(:index) || ::ActiveAdmin::PagePresenter.new(title: proc { I18n.t("active_admin.dashboard") })

  dsl.content(title: index_page_presenter[:title]) do 
            
    # First row of content
    columns do
      column do
        panel "Top Users" do
          div(id: :top_users_panel) { render "usa_map" }
        end
      end

      column do
        panel "Top Content" do
          div(id: :top_content_panel) { render "line_graph" }
        end
      end
    end

    # Second row of content
    columns do
      column do
        panel "Most Active Users" do
          table_for Customer.top_users.limit(25) do
            column(:name) { |c| link_to c.full_name, [:admin, c] }
            column(:email) { |c| mail_to c.email, c.email }
            column(:phone) { |c| number_to_phone c.phone, area_code: true }
            column(:activity) { |c| c.tracking_events.count }
          end
        end
      end
      column do
        panel "Most Active Content" do
          table_for IfdTools::Tracking::Event.top_content do
            column(:name) { |event| link_to event.trackable_title, [:admin, event.trackable_resource] }
            column(:type) { |event| event.trackable_type }
            column(:activity) { |event| event.trackable_activity }
          end
        end
      end
    end
  
    # Execute any code provided in the application dashboard itself
    instance_exec &index_page_presenter.block if index_page_presenter.block.present?
  
  end

end