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: {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/avo/dashboards/base_dashboard.rb', line 15

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

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

.classesObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/avo/dashboards/base_dashboard.rb', line 48

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



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

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

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

.is_hidden?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/avo/dashboards/base_dashboard.rb', line 83

def is_hidden?
  !is_visible?
end

.is_visible?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
80
81
# File 'lib/avo/dashboards/base_dashboard.rb', line 71

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



30
31
32
33
34
35
36
# File 'lib/avo/dashboards/base_dashboard.rb', line 30

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

    item.index == index
  end
end

.itemsObject



44
45
46
# File 'lib/avo/dashboards/base_dashboard.rb', line 44

def items
  self.items_holder
end


63
64
65
# File 'lib/avo/dashboards/base_dashboard.rb', line 63

def navigation_label
  name
end


67
68
69
# File 'lib/avo/dashboards/base_dashboard.rb', line 67

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