avo 2.1.0 → 2.1.2.pre2
Sign up to get free protection for your applications and to get access to all the features.
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/assets/stylesheets/avo.css +1 -1
- 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/filters_component.html.erb +19 -20
- data/app/components/avo/panel_component.html.erb +5 -3
- data/app/components/avo/sidebar_component.html.erb +2 -0
- data/app/components/avo/sidebar_profile_component.html.erb +14 -10
- 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/controllers/avo/search_controller.rb +1 -1
- 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/app.rb +7 -3
- data/lib/avo/base_action.rb +1 -0
- data/lib/avo/base_card.rb +175 -0
- data/lib/avo/base_resource.rb +12 -2
- 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/dynamic_router.rb +1 -1
- data/lib/avo/engine.rb +7 -16
- 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/reloader.rb +51 -0
- data/lib/avo/version.rb +1 -1
- data/public/avo-assets/avo.css +18 -13
- metadata +11 -5
- data/lib/avo/dashboards/base_card.rb +0 -151
data/lib/avo/engine.rb
CHANGED
@@ -19,7 +19,8 @@ module Avo
|
|
19
19
|
|
20
20
|
config.i18n.load_path += Dir[Avo::Engine.root.join('lib', 'generators', 'avo', 'templates', 'locales', '*.{rb,yml}')]
|
21
21
|
|
22
|
-
initializer "avo.autoload", before: :set_autoload_paths do |app|
|
22
|
+
# initializer "avo.autoload", before: :set_autoload_paths do |app|
|
23
|
+
initializer "avo.autoload" do |app|
|
23
24
|
[
|
24
25
|
["app", "avo", "fields"],
|
25
26
|
["app", "avo", "filters"],
|
@@ -41,21 +42,11 @@ module Avo
|
|
41
42
|
::Avo::App.init_fields
|
42
43
|
end
|
43
44
|
|
44
|
-
initializer "avo.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
app.
|
49
|
-
# Register reloader
|
50
|
-
app.reloaders << app.config.file_watcher.new([], {
|
51
|
-
Avo::Engine.root.join("lib", "avo").to_s => ["rb"]
|
52
|
-
}) {}
|
53
|
-
|
54
|
-
# What to do on file change
|
55
|
-
config.to_prepare do
|
56
|
-
Dir.glob(avo_root_path + "/lib/avo/**/*.rb".to_s).each { |c| load c }
|
57
|
-
Avo::App.boot
|
58
|
-
end
|
45
|
+
initializer "avo.reloader" do |app|
|
46
|
+
Avo::Reloader.new.tap do |reloader|
|
47
|
+
reloader.execute
|
48
|
+
app.reloaders << reloader
|
49
|
+
app.reloader.to_run { reloader.execute }
|
59
50
|
end
|
60
51
|
end
|
61
52
|
|
@@ -104,7 +104,7 @@ module Avo
|
|
104
104
|
|
105
105
|
return @name if @name.present?
|
106
106
|
|
107
|
-
return t(translation_key, count: 1, default: default).capitalize if
|
107
|
+
return t(translation_key, count: 1, default: default).capitalize if translation_key
|
108
108
|
|
109
109
|
default
|
110
110
|
end
|
@@ -112,7 +112,7 @@ module Avo
|
|
112
112
|
def plural_name
|
113
113
|
default = name.pluralize
|
114
114
|
|
115
|
-
return t(translation_key, count: 2, default: default).capitalize if
|
115
|
+
return t(translation_key, count: 2, default: default).capitalize if translation_key
|
116
116
|
|
117
117
|
default
|
118
118
|
end
|
data/lib/avo/fields_collector.rb
CHANGED
@@ -2,14 +2,19 @@ module Avo
|
|
2
2
|
module FieldsCollector
|
3
3
|
def field(field_name, as:, **args, &block)
|
4
4
|
self.fields ||= []
|
5
|
+
self.invalid_fields ||= []
|
5
6
|
|
6
7
|
field_instance = parse_field(field_name, as: as, **args, &block)
|
7
8
|
|
8
9
|
if field_instance.present?
|
9
10
|
self.fields << field_instance
|
10
11
|
else
|
11
|
-
|
12
|
-
|
12
|
+
self.invalid_fields << ({
|
13
|
+
name: field_name,
|
14
|
+
as: as,
|
15
|
+
resource: name,
|
16
|
+
message: "There's an invalid field configuration for this resource. <br/> <code class='px-1 py-px rounded bg-red-600'>field :#{field_name}, as: #{as}</code>"
|
17
|
+
})
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
data/lib/avo/reloader.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class Avo::Reloader
|
2
|
+
delegate :execute_if_updated, :execute, :updated?, to: :updater
|
3
|
+
|
4
|
+
def reload!
|
5
|
+
# reload all files declared in paths
|
6
|
+
paths.each { |path| load path }
|
7
|
+
|
8
|
+
# reload all files declared in each directory
|
9
|
+
directories.keys.each do |dir|
|
10
|
+
Dir.glob("#{dir}/**/*.rb".to_s).each { |c| load c }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def updater
|
16
|
+
@updater ||= config.file_watcher.new(paths, directories) { reload! }
|
17
|
+
end
|
18
|
+
|
19
|
+
def paths
|
20
|
+
# we want to watch some files no matter what
|
21
|
+
files = [
|
22
|
+
Rails.root.join("config", "initializers", "avo.rb"),
|
23
|
+
]
|
24
|
+
|
25
|
+
# we want to watch some files only in Avo development
|
26
|
+
if reload_lib?
|
27
|
+
files += []
|
28
|
+
end
|
29
|
+
|
30
|
+
files
|
31
|
+
end
|
32
|
+
|
33
|
+
def directories
|
34
|
+
dirs = {}
|
35
|
+
|
36
|
+
# watch the lib directory in Avo development
|
37
|
+
if reload_lib?
|
38
|
+
dirs[Avo::Engine.root.join("lib", "avo").to_s] = ["rb"]
|
39
|
+
end
|
40
|
+
|
41
|
+
dirs
|
42
|
+
end
|
43
|
+
|
44
|
+
def config
|
45
|
+
Rails.application.config
|
46
|
+
end
|
47
|
+
|
48
|
+
def reload_lib?
|
49
|
+
Avo::IN_DEVELOPMENT || ENV['AVO_RELOAD_LIB_DIR']
|
50
|
+
end
|
51
|
+
end
|
data/lib/avo/version.rb
CHANGED
data/public/avo-assets/avo.css
CHANGED
@@ -6685,8 +6685,8 @@ progress[value]::-moz-progress-bar{
|
|
6685
6685
|
max-width:100%
|
6686
6686
|
}
|
6687
6687
|
|
6688
|
-
.max-w-
|
6689
|
-
max-width:
|
6688
|
+
.max-w-lg{
|
6689
|
+
max-width:32rem
|
6690
6690
|
}
|
6691
6691
|
|
6692
6692
|
.max-w-xs{
|
@@ -7174,6 +7174,11 @@ progress[value]::-moz-progress-bar{
|
|
7174
7174
|
border-color:rgb(87 93 102 / var(--tw-border-opacity))
|
7175
7175
|
}
|
7176
7176
|
|
7177
|
+
.bg-red-600{
|
7178
|
+
--tw-bg-opacity:1;
|
7179
|
+
background-color:rgb(220 38 38 / var(--tw-bg-opacity))
|
7180
|
+
}
|
7181
|
+
|
7177
7182
|
.bg-white{
|
7178
7183
|
--tw-bg-opacity:1;
|
7179
7184
|
background-color:rgb(255 255 255 / var(--tw-bg-opacity))
|
@@ -7291,6 +7296,16 @@ progress[value]::-moz-progress-bar{
|
|
7291
7296
|
padding:0.25rem
|
7292
7297
|
}
|
7293
7298
|
|
7299
|
+
.px-1{
|
7300
|
+
padding-left:0.25rem;
|
7301
|
+
padding-right:0.25rem
|
7302
|
+
}
|
7303
|
+
|
7304
|
+
.py-px{
|
7305
|
+
padding-top:1px;
|
7306
|
+
padding-bottom:1px
|
7307
|
+
}
|
7308
|
+
|
7294
7309
|
.px-2{
|
7295
7310
|
padding-left:0.5rem;
|
7296
7311
|
padding-right:0.5rem
|
@@ -7356,21 +7371,11 @@ progress[value]::-moz-progress-bar{
|
|
7356
7371
|
padding-bottom:0px
|
7357
7372
|
}
|
7358
7373
|
|
7359
|
-
.px-1{
|
7360
|
-
padding-left:0.25rem;
|
7361
|
-
padding-right:0.25rem
|
7362
|
-
}
|
7363
|
-
|
7364
7374
|
.py-4{
|
7365
7375
|
padding-top:1rem;
|
7366
7376
|
padding-bottom:1rem
|
7367
7377
|
}
|
7368
7378
|
|
7369
|
-
.py-px{
|
7370
|
-
padding-top:1px;
|
7371
|
-
padding-bottom:1px
|
7372
|
-
}
|
7373
|
-
|
7374
7379
|
.py-24{
|
7375
7380
|
padding-top:6rem;
|
7376
7381
|
padding-bottom:6rem
|
@@ -7848,7 +7853,7 @@ html, body{
|
|
7848
7853
|
|
7849
7854
|
.turbo-progress-bar{
|
7850
7855
|
--tw-bg-opacity:1;
|
7851
|
-
background-color:rgb(
|
7856
|
+
background-color:rgb(44 164 247 / var(--tw-bg-opacity))
|
7852
7857
|
}
|
7853
7858
|
|
7854
7859
|
body.os-mac .mac\:hidden {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -234,6 +234,9 @@ files:
|
|
234
234
|
- Gemfile.lock
|
235
235
|
- README.md
|
236
236
|
- Rakefile
|
237
|
+
- app/assets/builds/avo.css
|
238
|
+
- app/assets/builds/avo.js
|
239
|
+
- app/assets/builds/avo.js.map
|
237
240
|
- app/assets/config/avo_manifest.js
|
238
241
|
- app/assets/stylesheets/avo.css
|
239
242
|
- app/assets/stylesheets/css/active-storage.css
|
@@ -1085,6 +1088,7 @@ files:
|
|
1085
1088
|
- app/views/avo/partials/_navbar.html.erb
|
1086
1089
|
- app/views/avo/partials/_resource_search.html.erb
|
1087
1090
|
- app/views/avo/partials/_scripts.html.erb
|
1091
|
+
- app/views/avo/partials/_sidebar_extra.html.erb
|
1088
1092
|
- app/views/avo/partials/_sortable_component.html.erb
|
1089
1093
|
- app/views/avo/partials/_table_header.html.erb
|
1090
1094
|
- app/views/avo/partials/_view_toggle_button.html.erb
|
@@ -1120,12 +1124,13 @@ files:
|
|
1120
1124
|
- lib/avo/action_model.rb
|
1121
1125
|
- lib/avo/app.rb
|
1122
1126
|
- lib/avo/base_action.rb
|
1127
|
+
- lib/avo/base_card.rb
|
1123
1128
|
- lib/avo/base_resource.rb
|
1124
1129
|
- lib/avo/configuration.rb
|
1125
|
-
- lib/avo/dashboards/base_card.rb
|
1126
1130
|
- lib/avo/dashboards/base_dashboard.rb
|
1127
1131
|
- lib/avo/dashboards/base_divider.rb
|
1128
1132
|
- lib/avo/dashboards/chartkick_card.rb
|
1133
|
+
- lib/avo/dashboards/dashboard_card.rb
|
1129
1134
|
- lib/avo/dashboards/metric_card.rb
|
1130
1135
|
- lib/avo/dashboards/partial_card.rb
|
1131
1136
|
- lib/avo/dynamic_router.rb
|
@@ -1188,6 +1193,7 @@ files:
|
|
1188
1193
|
- lib/avo/loaders/fields_loader.rb
|
1189
1194
|
- lib/avo/loaders/filters_loader.rb
|
1190
1195
|
- lib/avo/loaders/loader.rb
|
1196
|
+
- lib/avo/reloader.rb
|
1191
1197
|
- lib/avo/services/authorization_service.rb
|
1192
1198
|
- lib/avo/tools_manager.rb
|
1193
1199
|
- lib/avo/version.rb
|
@@ -1280,9 +1286,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1280
1286
|
version: 2.4.0
|
1281
1287
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1282
1288
|
requirements:
|
1283
|
-
- - "
|
1289
|
+
- - ">"
|
1284
1290
|
- !ruby/object:Gem::Version
|
1285
|
-
version:
|
1291
|
+
version: 1.3.1
|
1286
1292
|
requirements: []
|
1287
1293
|
rubygems_version: 3.3.3
|
1288
1294
|
signing_key:
|
@@ -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
|