Class: Avo::Dashboards::BaseDashboard

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::DescendantsTracker
Defined in:
lib/avo/dashboards/base_dashboard.rb

Class Method Summary collapse

Class Method Details

.card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/avo/dashboards/base_dashboard.rb', line 20

def card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {})
  options_deprecation_message if options.present?
  self.items_holder ||= []

  self.items_holder << klass.new(dashboard: self,
    label: label,
    description: description,
    cols: cols,
    rows: rows,
    refresh_every: refresh_every,
    options: options,
    arguments: arguments,
    index: index
  )
  self.index += 1
end

.classesObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/avo/dashboards/base_dashboard.rb', line 55

def classes
  case grid_cols
  when 3
    "sm:grid-cols-3"
  when 4
    "sm:grid-cols-4"
  when 5
    "sm:grid-cols-5"
  when 6
    "sm:grid-cols-6"
  else
    "sm:grid-cols-3"
  end
end

.divider(**args) ⇒ Object



45
46
47
48
49
# File 'lib/avo/dashboards/base_dashboard.rb', line 45

def divider(**args)
  self.items_holder ||= []

  self.items_holder << BaseDivider.new(**args)
end

.is_hidden?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/avo/dashboards/base_dashboard.rb', line 90

def is_hidden?
  !is_visible?
end

.is_visible?Boolean

Returns:

  • (Boolean)


78
79
80
81
82
83
84
85
86
87
88
# File 'lib/avo/dashboards/base_dashboard.rb', line 78

def is_visible?
  # Default is true
  return true if visible == true

  # Hide if false
  return false if visible == false

  if visible.respond_to? :call
    ::Avo::Hosts::DashboardVisibility.new(block: visible, dashboard: self).handle
  end
end

.item_at_index(index) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/avo/dashboards/base_dashboard.rb', line 37

def item_at_index(index)
  items.find do |item|
    next if item.index.blank?

    item.index == index
  end
end

.itemsObject



51
52
53
# File 'lib/avo/dashboards/base_dashboard.rb', line 51

def items
  self.items_holder
end


70
71
72
# File 'lib/avo/dashboards/base_dashboard.rb', line 70

def navigation_label
  name
end


74
75
76
# File 'lib/avo/dashboards/base_dashboard.rb', line 74

def navigation_path
  Avo::App.view_context.avo.dashboard_path id
end

.options_deprecation_messageObject



16
17
18
# File 'lib/avo/dashboards/base_dashboard.rb', line 16

def options_deprecation_message
  Rails.logger.warn "DEPRECATION WARNING: Card options parameter is deprecated in favor of arguments parameter and will be removed from Avo version 3.0.0"
end