avo 2.3.1.pre.4 → 2.4.0
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/stylesheets/css/components/code.css +1 -0
- data/app/components/avo/profile_item_component.html.erb +1 -1
- data/app/components/avo/profile_item_component.rb +6 -1
- data/app/components/avo/sidebar_component.html.erb +5 -2
- data/app/components/avo/sidebar_profile_component.html.erb +4 -1
- data/app/controllers/avo/base_controller.rb +14 -9
- data/app/controllers/avo/debug_controller.rb +3 -0
- data/app/javascript/js/controllers/fields/code_field_controller.js +0 -1
- data/app/javascript/js/controllers/filter_controller.js +11 -1
- data/app/javascript/js/controllers/multiple_select_filter_controller.js +3 -1
- data/app/javascript/js/controllers/select_filter_controller.js +1 -1
- data/app/views/avo/base/_boolean_filter.html.erb +1 -14
- data/app/views/avo/base/_multiple_select_filter.html.erb +2 -13
- data/app/views/avo/base/_select_filter.html.erb +1 -9
- data/app/views/avo/base/_text_filter.html.erb +2 -10
- data/app/views/avo/debug/index.html.erb +7 -23
- data/app/views/avo/debug/report.html.erb +21 -0
- data/app/views/avo/partials/_footer.html.erb +1 -1
- data/app/views/avo/partials/_navbar.html.erb +4 -1
- data/config/routes.rb +1 -0
- data/lib/avo/app.rb +37 -10
- data/lib/avo/configuration.rb +2 -0
- data/lib/avo/engine.rb +13 -0
- data/lib/avo/fields/code_field.rb +1 -1
- data/lib/avo/filters/base_filter.rb +17 -2
- data/lib/avo/filters/boolean_filter.rb +12 -0
- data/lib/avo/filters/multiple_select_filter.rb +15 -0
- data/lib/avo/filters/text_filter.rb +4 -0
- data/lib/avo/licensing/h_q.rb +60 -20
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +1 -0
- data/lib/tasks/avo_tasks.rake +30 -0
- data/public/avo-assets/avo.css +11 -0
- data/public/avo-assets/avo.js +3 -3
- data/public/avo-assets/avo.js.map +2 -2
- metadata +5 -8
- data/app/assets/builds/avo.css +0 -8840
- data/app/assets/builds/avo.js +0 -423
- data/app/assets/builds/avo.js.map +0 -7
- data/app/mailers/avo/application_mailer.rb +0 -6
data/lib/avo/licensing/h_q.rb
CHANGED
@@ -2,41 +2,76 @@ module Avo
|
|
2
2
|
module Licensing
|
3
3
|
class HQ
|
4
4
|
attr_accessor :current_request
|
5
|
+
attr_accessor :cache_store
|
5
6
|
|
6
7
|
ENDPOINT = "https://avohq.io/api/v1/licenses/check".freeze unless const_defined?(:ENDPOINT)
|
7
|
-
CACHE_KEY = "avo.hq.response".freeze unless const_defined?(:CACHE_KEY)
|
8
8
|
REQUEST_TIMEOUT = 5 unless const_defined?(:REQUEST_TIMEOUT) # seconds
|
9
|
+
CACHE_TIME = 3600 unless const_defined?(:CACHE_TIME) # seconds
|
9
10
|
|
10
|
-
|
11
|
+
class << self
|
12
|
+
def cache_key
|
13
|
+
"avo.hq-#{Avo::VERSION.parameterize}.response"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(current_request = nil)
|
11
18
|
@current_request = current_request
|
12
19
|
@cache_store = Avo::App.cache_store
|
13
20
|
end
|
14
21
|
|
15
22
|
def response
|
23
|
+
expire_cache_if_overdue
|
24
|
+
|
16
25
|
make_request
|
17
26
|
end
|
18
27
|
|
28
|
+
# Some cache stores don't auto-expire their keys and payloads so we need to do it for them
|
29
|
+
def expire_cache_if_overdue
|
30
|
+
return unless cached_response.present?
|
31
|
+
return unless cached_response['fetched_at'].present?
|
32
|
+
|
33
|
+
allowed_time = 1.hour
|
34
|
+
parsed_time = Time.parse(cached_response['fetched_at'].to_s)
|
35
|
+
time_has_passed = parsed_time < Time.now - allowed_time
|
36
|
+
|
37
|
+
clear_response if time_has_passed
|
38
|
+
end
|
39
|
+
|
19
40
|
def fresh_response
|
20
|
-
|
41
|
+
clear_response
|
42
|
+
|
43
|
+
make_request
|
44
|
+
end
|
45
|
+
|
46
|
+
def clear_response
|
47
|
+
cache_store.delete self.class.cache_key
|
21
48
|
end
|
22
49
|
|
23
50
|
def payload
|
24
|
-
{
|
51
|
+
result = {
|
25
52
|
license: Avo.configuration.license,
|
26
53
|
license_key: Avo.configuration.license_key,
|
27
54
|
avo_version: Avo::VERSION,
|
28
55
|
rails_version: Rails::VERSION::STRING,
|
29
56
|
ruby_version: RUBY_VERSION,
|
30
57
|
environment: Rails.env,
|
31
|
-
ip: current_request
|
32
|
-
host: current_request
|
33
|
-
port: current_request
|
58
|
+
ip: current_request&.ip,
|
59
|
+
host: current_request&.host,
|
60
|
+
port: current_request&.port,
|
34
61
|
app_name: app_name
|
35
62
|
}
|
63
|
+
|
64
|
+
metadata = avo_metadata
|
65
|
+
if metadata[:resources_count] != 0
|
66
|
+
result[:avo_metadata] = metadata
|
67
|
+
end
|
68
|
+
|
69
|
+
result
|
36
70
|
end
|
37
71
|
|
38
72
|
def avo_metadata
|
39
73
|
resources = App.resources
|
74
|
+
dashboards = App.dashboards
|
40
75
|
field_definitions = resources.map(&:get_field_definitions)
|
41
76
|
fields_count = field_definitions.map(&:count).sum
|
42
77
|
fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0))
|
@@ -54,21 +89,28 @@ module Avo
|
|
54
89
|
|
55
90
|
{
|
56
91
|
resources_count: resources.count,
|
92
|
+
dashboards_count: dashboards.count,
|
57
93
|
fields_count: fields_count,
|
58
94
|
fields_per_resource: fields_per_resource,
|
59
95
|
custom_fields_count: custom_fields_count,
|
60
96
|
field_types: field_types,
|
61
97
|
**other_metadata(:actions),
|
62
98
|
**other_metadata(:filters),
|
63
|
-
main_menu_present: Avo
|
64
|
-
profile_menu_present: Avo
|
99
|
+
main_menu_present: Avo.configuration.main_menu.present?,
|
100
|
+
profile_menu_present: Avo.configuration.profile_menu.present?,
|
65
101
|
}
|
102
|
+
rescue
|
103
|
+
{}
|
104
|
+
end
|
105
|
+
|
106
|
+
def cached_response
|
107
|
+
cache_store.read self.class.cache_key
|
66
108
|
end
|
67
109
|
|
68
110
|
private
|
69
111
|
|
70
|
-
def make_request
|
71
|
-
return cached_response if has_cached_response
|
112
|
+
def make_request
|
113
|
+
return cached_response if has_cached_response
|
72
114
|
|
73
115
|
begin
|
74
116
|
perform_and_cache_request
|
@@ -94,17 +136,19 @@ module Avo
|
|
94
136
|
|
95
137
|
return cache_and_return_error "Avo HQ Internal server error.", hq_response.body if hq_response.code == 500
|
96
138
|
|
97
|
-
|
139
|
+
if hq_response.code == 200
|
140
|
+
cache_response response: hq_response.parsed_response
|
141
|
+
end
|
98
142
|
end
|
99
143
|
|
100
|
-
def cache_response(
|
144
|
+
def cache_response(response: nil, time: CACHE_TIME)
|
101
145
|
response.merge!(
|
102
146
|
expiry: time,
|
103
147
|
fetched_at: Time.now,
|
104
148
|
**payload
|
105
149
|
).stringify_keys!
|
106
150
|
|
107
|
-
|
151
|
+
cache_store.write(self.class.cache_key, response, expires_in: time)
|
108
152
|
|
109
153
|
response
|
110
154
|
end
|
@@ -135,15 +179,11 @@ module Avo
|
|
135
179
|
end
|
136
180
|
|
137
181
|
def cache_and_return_error(error, exception_message = "")
|
138
|
-
cache_response
|
182
|
+
cache_response response: {error: error, exception_message: exception_message}.stringify_keys, time: 5.minutes.to_i
|
139
183
|
end
|
140
184
|
|
141
185
|
def has_cached_response
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
def cached_response
|
146
|
-
@cache_store.read CACHE_KEY
|
186
|
+
cache_store.exist? self.class.cache_key
|
147
187
|
end
|
148
188
|
end
|
149
189
|
end
|
data/lib/avo/version.rb
CHANGED
@@ -42,6 +42,7 @@ Avo.configure do |config|
|
|
42
42
|
# config.per_page_steps = [12, 24, 48, 72]
|
43
43
|
# config.via_per_page = 8
|
44
44
|
# config.default_view_type = :table
|
45
|
+
# config.hide_layout_when_printing = false
|
45
46
|
# config.id_links_to_resource = false
|
46
47
|
# config.full_width_container = false
|
47
48
|
# config.full_width_index_view = false
|
data/lib/tasks/avo_tasks.rake
CHANGED
@@ -2,3 +2,33 @@
|
|
2
2
|
# task :avo do
|
3
3
|
# # Task goes here
|
4
4
|
# end
|
5
|
+
|
6
|
+
desc 'Installs Avo assets and bundles them for when you want to use the GitHub repo in your app'
|
7
|
+
task 'avo:build-assets' do
|
8
|
+
enabled = true
|
9
|
+
|
10
|
+
if enabled
|
11
|
+
puts "Starting avo:build-assets"
|
12
|
+
path = locate_gem 'avo'
|
13
|
+
|
14
|
+
Dir.chdir(path) do
|
15
|
+
system 'yarn'
|
16
|
+
system 'yarn prod:build'
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "Done"
|
20
|
+
else
|
21
|
+
puts "Not starting avo:build-assets"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# From
|
26
|
+
# https://stackoverflow.com/questions/9322078/programmatically-determine-gems-path-using-bundler
|
27
|
+
def locate_gem(name)
|
28
|
+
spec = Bundler.load.specs.find{|s| s.name == name }
|
29
|
+
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
|
30
|
+
if spec.name == 'bundler'
|
31
|
+
return File.expand_path('../../../', __FILE__)
|
32
|
+
end
|
33
|
+
spec.full_gem_path
|
34
|
+
end
|
data/public/avo-assets/avo.css
CHANGED
@@ -5482,6 +5482,7 @@ span.CodeMirror-selectedtext {
|
|
5482
5482
|
.CodeMirror {
|
5483
5483
|
height: var(--height) !important;
|
5484
5484
|
min-height: auto;
|
5485
|
+
padding: 0;
|
5485
5486
|
}
|
5486
5487
|
|
5487
5488
|
/* overlay CodeMirror fullscreen & Preview on small screens */
|
@@ -7507,6 +7508,10 @@ progress[value]::-moz-progress-bar{
|
|
7507
7508
|
font-weight:500
|
7508
7509
|
}
|
7509
7510
|
|
7511
|
+
.font-normal{
|
7512
|
+
font-weight:400
|
7513
|
+
}
|
7514
|
+
|
7510
7515
|
.font-bold{
|
7511
7516
|
font-weight:700
|
7512
7517
|
}
|
@@ -8526,6 +8531,12 @@ trix-editor {
|
|
8526
8531
|
padding-top:1rem
|
8527
8532
|
}
|
8528
8533
|
|
8534
|
+
@media print{
|
8535
|
+
.print\:hidden{
|
8536
|
+
display:none
|
8537
|
+
}
|
8538
|
+
}
|
8539
|
+
|
8529
8540
|
@media (min-width: 495px){
|
8530
8541
|
.xs\:grid-cols-2{
|
8531
8542
|
grid-template-columns:repeat(2, minmax(0, 1fr))
|