avo 2.3.1.pre.6 → 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 -3
- 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 +3 -3
- data/app/views/avo/debug/report.html.erb +1 -1
- data/app/views/avo/partials/_footer.html.erb +1 -1
- data/app/views/avo/partials/_navbar.html.erb +4 -1
- data/lib/avo/app.rb +37 -12
- 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 +52 -15
- 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 +4 -8
- data/app/assets/builds/avo.css +0 -8846
- 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,42 +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
9
|
CACHE_TIME = 3600 unless const_defined?(:CACHE_TIME) # seconds
|
10
10
|
|
11
|
-
|
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)
|
12
18
|
@current_request = current_request
|
13
19
|
@cache_store = Avo::App.cache_store
|
14
20
|
end
|
15
21
|
|
16
22
|
def response
|
23
|
+
expire_cache_if_overdue
|
24
|
+
|
17
25
|
make_request
|
18
26
|
end
|
19
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
|
+
|
20
40
|
def fresh_response
|
21
|
-
|
41
|
+
clear_response
|
42
|
+
|
43
|
+
make_request
|
44
|
+
end
|
45
|
+
|
46
|
+
def clear_response
|
47
|
+
cache_store.delete self.class.cache_key
|
22
48
|
end
|
23
49
|
|
24
50
|
def payload
|
25
|
-
{
|
51
|
+
result = {
|
26
52
|
license: Avo.configuration.license,
|
27
53
|
license_key: Avo.configuration.license_key,
|
28
54
|
avo_version: Avo::VERSION,
|
29
55
|
rails_version: Rails::VERSION::STRING,
|
30
56
|
ruby_version: RUBY_VERSION,
|
31
57
|
environment: Rails.env,
|
32
|
-
ip: current_request
|
33
|
-
host: current_request
|
34
|
-
port: current_request
|
58
|
+
ip: current_request&.ip,
|
59
|
+
host: current_request&.host,
|
60
|
+
port: current_request&.port,
|
35
61
|
app_name: app_name
|
36
62
|
}
|
63
|
+
|
64
|
+
metadata = avo_metadata
|
65
|
+
if metadata[:resources_count] != 0
|
66
|
+
result[:avo_metadata] = metadata
|
67
|
+
end
|
68
|
+
|
69
|
+
result
|
37
70
|
end
|
38
71
|
|
39
72
|
def avo_metadata
|
40
73
|
resources = App.resources
|
74
|
+
dashboards = App.dashboards
|
41
75
|
field_definitions = resources.map(&:get_field_definitions)
|
42
76
|
fields_count = field_definitions.map(&:count).sum
|
43
77
|
fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0))
|
@@ -55,6 +89,7 @@ module Avo
|
|
55
89
|
|
56
90
|
{
|
57
91
|
resources_count: resources.count,
|
92
|
+
dashboards_count: dashboards.count,
|
58
93
|
fields_count: fields_count,
|
59
94
|
fields_per_resource: fields_per_resource,
|
60
95
|
custom_fields_count: custom_fields_count,
|
@@ -64,12 +99,18 @@ module Avo
|
|
64
99
|
main_menu_present: Avo.configuration.main_menu.present?,
|
65
100
|
profile_menu_present: Avo.configuration.profile_menu.present?,
|
66
101
|
}
|
102
|
+
rescue
|
103
|
+
{}
|
104
|
+
end
|
105
|
+
|
106
|
+
def cached_response
|
107
|
+
cache_store.read self.class.cache_key
|
67
108
|
end
|
68
109
|
|
69
110
|
private
|
70
111
|
|
71
|
-
def make_request
|
72
|
-
return cached_response if has_cached_response
|
112
|
+
def make_request
|
113
|
+
return cached_response if has_cached_response
|
73
114
|
|
74
115
|
begin
|
75
116
|
perform_and_cache_request
|
@@ -107,7 +148,7 @@ module Avo
|
|
107
148
|
**payload
|
108
149
|
).stringify_keys!
|
109
150
|
|
110
|
-
|
151
|
+
cache_store.write(self.class.cache_key, response, expires_in: time)
|
111
152
|
|
112
153
|
response
|
113
154
|
end
|
@@ -142,11 +183,7 @@ module Avo
|
|
142
183
|
end
|
143
184
|
|
144
185
|
def has_cached_response
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
def cached_response
|
149
|
-
@cache_store.read CACHE_KEY
|
186
|
+
cache_store.exist? self.class.cache_key
|
150
187
|
end
|
151
188
|
end
|
152
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))
|