avo 2.1.1 → 2.1.2.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/builds/avo.css +8810 -0
- data/app/assets/builds/avo.js +423 -0
- data/app/assets/builds/avo.js.map +7 -0
- data/app/components/avo/alert_component.html.erb +1 -1
- data/app/components/avo/alert_component.rb +1 -1
- data/app/components/avo/card_component.html.erb +7 -2
- data/app/components/avo/panel_component.html.erb +5 -3
- data/app/components/avo/sidebar_component.html.erb +2 -0
- data/app/components/avo/views/resource_show_component.html.erb +10 -0
- data/app/components/avo/views/resource_show_component.rb +5 -0
- data/app/controllers/avo/base_controller.rb +30 -10
- data/app/controllers/avo/dashboards_controller.rb +1 -5
- data/app/helpers/avo/url_helpers.rb +6 -2
- data/app/views/avo/dashboards/show.html.erb +4 -1
- data/app/views/avo/partials/_sidebar_extra.html.erb +0 -0
- data/lib/avo/base_action.rb +1 -0
- data/lib/avo/base_card.rb +175 -0
- data/lib/avo/base_resource.rb +8 -1
- data/lib/avo/dashboards/base_dashboard.rb +20 -2
- data/lib/avo/dashboards/base_divider.rb +3 -1
- data/lib/avo/dashboards/dashboard_card.rb +6 -0
- data/lib/avo/dashboards/partial_card.rb +1 -1
- data/lib/avo/fields/base_field.rb +2 -2
- data/lib/avo/fields/date_field.rb +1 -1
- data/lib/avo/fields_collector.rb +7 -2
- data/lib/avo/hosts/dashboard_card.rb +1 -0
- data/lib/avo/version.rb +1 -1
- data/public/avo-assets/avo.css +17 -12
- metadata +10 -5
- data/lib/avo/dashboards/base_card.rb +0 -151
@@ -1,151 +0,0 @@
|
|
1
|
-
module Avo
|
2
|
-
module Dashboards
|
3
|
-
class BaseCard
|
4
|
-
class_attribute :id
|
5
|
-
class_attribute :label
|
6
|
-
class_attribute :description
|
7
|
-
class_attribute :cols, default: 1
|
8
|
-
class_attribute :rows, default: 1
|
9
|
-
class_attribute :initial_range
|
10
|
-
class_attribute :ranges, default: []
|
11
|
-
class_attribute :refresh_every
|
12
|
-
class_attribute :display_header, default: true
|
13
|
-
# private
|
14
|
-
class_attribute :result_data
|
15
|
-
class_attribute :query_block
|
16
|
-
|
17
|
-
attr_accessor :dashboard
|
18
|
-
attr_accessor :params
|
19
|
-
|
20
|
-
delegate :context, to: ::Avo::App
|
21
|
-
|
22
|
-
class << self
|
23
|
-
def query(&block)
|
24
|
-
self.query_block = block
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize(dashboard:)
|
29
|
-
@dashboard = dashboard
|
30
|
-
end
|
31
|
-
|
32
|
-
def label
|
33
|
-
return self.class.label.to_s if self.class.label.to_s.present?
|
34
|
-
|
35
|
-
self.class.id.to_s.humanize
|
36
|
-
end
|
37
|
-
|
38
|
-
def translated_range(range)
|
39
|
-
return "#{range} days" if range.is_a? Integer
|
40
|
-
|
41
|
-
case range
|
42
|
-
when "MTD"
|
43
|
-
"Month to date"
|
44
|
-
when "QTD"
|
45
|
-
"Quarter to date"
|
46
|
-
when "YTD"
|
47
|
-
"Year to date"
|
48
|
-
when "TODAY"
|
49
|
-
"Today"
|
50
|
-
else
|
51
|
-
range
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def parsed_ranges
|
56
|
-
return unless ranges.present?
|
57
|
-
|
58
|
-
ranges.map { |range| [translated_range(range), range] }
|
59
|
-
end
|
60
|
-
|
61
|
-
def turbo_frame
|
62
|
-
"#{dashboard.id}_#{id}"
|
63
|
-
end
|
64
|
-
|
65
|
-
def frame_url(enforced_range: nil)
|
66
|
-
enforced_range ||= initial_range || ranges.first
|
67
|
-
"#{Avo::App.root_path}/dashboards/#{dashboard.id}/cards/#{id}?turbo_frame=#{turbo_frame}&range=#{enforced_range}"
|
68
|
-
end
|
69
|
-
|
70
|
-
def card_classes
|
71
|
-
result = ""
|
72
|
-
|
73
|
-
result += case self.class.cols.to_i
|
74
|
-
when 1
|
75
|
-
" sm:col-span-1"
|
76
|
-
when 2
|
77
|
-
" sm:col-span-2"
|
78
|
-
when 3
|
79
|
-
" sm:col-span-3"
|
80
|
-
when 4
|
81
|
-
" sm:col-span-4"
|
82
|
-
when 5
|
83
|
-
" sm:col-span-5"
|
84
|
-
when 6
|
85
|
-
" sm:col-span-6"
|
86
|
-
else
|
87
|
-
" sm:col-span-1"
|
88
|
-
end
|
89
|
-
|
90
|
-
result += case self.class.rows.to_i
|
91
|
-
when 1
|
92
|
-
" h-36"
|
93
|
-
when 2
|
94
|
-
" h-72"
|
95
|
-
when 3
|
96
|
-
" h-[27rem]"
|
97
|
-
when 4
|
98
|
-
" h-[36rem]"
|
99
|
-
when 5
|
100
|
-
" h-[45rem]"
|
101
|
-
when 6
|
102
|
-
" h-[54rem]"
|
103
|
-
end
|
104
|
-
|
105
|
-
result
|
106
|
-
end
|
107
|
-
|
108
|
-
def type
|
109
|
-
return :metric if self.class.superclass == ::Avo::Dashboards::MetricCard
|
110
|
-
return :chartkick if self.class.superclass == ::Avo::Dashboards::ChartkickCard
|
111
|
-
return :partial if self.class.superclass == ::Avo::Dashboards::PartialCard
|
112
|
-
end
|
113
|
-
|
114
|
-
def compute_result
|
115
|
-
Avo::Hosts::DashboardCard.new(card: self, dashboard: dashboard, params: params, context: context, range: range)
|
116
|
-
.compute_result
|
117
|
-
|
118
|
-
self
|
119
|
-
end
|
120
|
-
|
121
|
-
def hydrate(dashboard: nil, params: nil)
|
122
|
-
@dashboard = dashboard if dashboard.present?
|
123
|
-
@params = params if params.present?
|
124
|
-
|
125
|
-
self
|
126
|
-
end
|
127
|
-
|
128
|
-
def range
|
129
|
-
return params[:range] if params.present? && params[:range].present?
|
130
|
-
|
131
|
-
return initial_range if initial_range.present?
|
132
|
-
|
133
|
-
ranges.first
|
134
|
-
end
|
135
|
-
|
136
|
-
def result(data)
|
137
|
-
self.result_data = data
|
138
|
-
|
139
|
-
self
|
140
|
-
end
|
141
|
-
|
142
|
-
def is_card?
|
143
|
-
true
|
144
|
-
end
|
145
|
-
|
146
|
-
def is_divider?
|
147
|
-
false
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|