motor-admin 0.1.27 → 0.1.28
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.
- checksums.yaml +4 -4
- data/app/controllers/motor/active_storage_attachments_controller.rb +6 -1
- data/lib/motor/active_record_utils/types.rb +1 -2
- data/lib/motor/api_query/build_json.rb +17 -10
- data/lib/motor/api_query/sort.rb +5 -1
- data/lib/motor/build_schema/load_from_rails.rb +48 -36
- data/lib/motor/build_schema/merge_schema_configs.rb +47 -6
- data/lib/motor/build_schema/persist_resource_configs.rb +15 -36
- data/lib/motor/build_schema/reorder_schema.rb +22 -14
- data/lib/motor/queries/run_query.rb +31 -6
- data/lib/motor/ui_configs.rb +33 -13
- data/lib/motor/version.rb +1 -1
- data/ui/dist/{main-d6c1f237d3568a138874.css.gz → main-4da1a5102d7bc66aefd0.css.gz} +0 -0
- data/ui/dist/main-4da1a5102d7bc66aefd0.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +4 -4
- data/ui/dist/main-d6c1f237d3568a138874.js.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5799ce999fa943638fa7c4d655400c1418ee80977bf47f64a71e6d5c496d02de
|
4
|
+
data.tar.gz: da99ec7b1c48708d983b663a7f9cb79b6d0e270b2fc9f5538a8121cfabdbc209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5fc31a79b01ad0e716700a7c3daed980b293d13081294d1013918cce6f4d24cf4c104e0c44144cde225fd3b1ce07253f9b3ddaf44f1eca2252a01ff9124c52e
|
7
|
+
data.tar.gz: efca3a6d85ce6e33c83a63f3cd5addbd75b2baf099bd96c5efbac40445520a7725d68a5c3d0564792f06bdf12fed8958b13a6189047303d3c77f7f0af0ff0bd4
|
@@ -7,7 +7,7 @@ module Motor
|
|
7
7
|
load_and_authorize_resource :attachment, class: 'ActiveStorage::Attachment', parent: false
|
8
8
|
|
9
9
|
def create
|
10
|
-
if
|
10
|
+
if attachable?(@attachment.record)
|
11
11
|
@attachment.record.public_send(@attachment.name).attach(
|
12
12
|
io: StringIO.new(params.dig(:data, :file, :io).to_s.encode('ISO-8859-1')),
|
13
13
|
filename: params.dig(:data, :file, :filename)
|
@@ -21,6 +21,11 @@ module Motor
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
+
def attachable?(record)
|
25
|
+
record.respond_to?("#{@attachment.name}_attachment=") ||
|
26
|
+
record.respond_to?("#{@attachment.name}_attachments=")
|
27
|
+
end
|
28
|
+
|
24
29
|
def attachment_params
|
25
30
|
params.require(:data).except(:file).permit!
|
26
31
|
end
|
@@ -29,9 +29,11 @@ module Motor
|
|
29
29
|
hash = {}
|
30
30
|
|
31
31
|
path.split('.').reduce(hash) do |acc, part|
|
32
|
-
|
32
|
+
acc_hash = {}
|
33
33
|
|
34
|
-
acc[part]
|
34
|
+
acc[part] = acc_hash
|
35
|
+
|
36
|
+
acc_hash
|
35
37
|
end
|
36
38
|
|
37
39
|
accumulator.deep_merge(hash)
|
@@ -45,20 +47,25 @@ module Motor
|
|
45
47
|
return if params[:fields].blank?
|
46
48
|
|
47
49
|
model = rel.is_a?(ActiveRecord::Relation) ? rel.klass : rel.class
|
48
|
-
model_name = model.name.underscore
|
49
50
|
|
50
51
|
params[:fields].each do |key, fields|
|
51
52
|
fields = fields.split(',') if fields.is_a?(String)
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
hash = find_key_in_params(json_params, key)
|
54
|
+
merge_fields_params!(key, fields, json_params, model)
|
55
|
+
end
|
56
|
+
end
|
57
57
|
|
58
|
-
|
58
|
+
def merge_fields_params!(key, fields, json_params, model)
|
59
|
+
model_name = model.name.underscore
|
59
60
|
|
60
|
-
|
61
|
-
|
61
|
+
if key == model_name || model_name.split('/').last == key
|
62
|
+
json_params.merge!(build_fields_hash(model, fields))
|
63
|
+
else
|
64
|
+
hash = find_key_in_params(json_params, key)
|
65
|
+
|
66
|
+
fields_hash = build_fields_hash(model.reflections[key]&.klass, fields)
|
67
|
+
|
68
|
+
hash.merge!(fields_hash)
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
data/lib/motor/api_query/sort.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module Motor
|
4
4
|
module BuildSchema
|
5
5
|
module LoadFromRails
|
6
|
+
MUTEX = Mutex.new
|
7
|
+
|
6
8
|
module_function
|
7
9
|
|
8
10
|
def call
|
@@ -82,22 +84,26 @@ module Motor
|
|
82
84
|
model.columns.map do |column|
|
83
85
|
next if reference_columns.find { |c| c[:name] == column.name }
|
84
86
|
|
85
|
-
|
86
|
-
name: column.name,
|
87
|
-
display_name: column.name.humanize,
|
88
|
-
column_type: ActiveRecordUtils::Types::UNIFIED_TYPES[column.type.to_s] || column.type.to_s,
|
89
|
-
access_type: COLUMN_NAME_ACCESS_TYPES.fetch(column.name, ColumnAccessTypes::READ_WRITE),
|
90
|
-
default_value: default_attrs[column.name],
|
91
|
-
validators: fetch_validators(model, column.name),
|
92
|
-
reference: nil,
|
93
|
-
format: {},
|
94
|
-
virtual: false
|
95
|
-
}
|
87
|
+
build_table_column(column, model, default_attrs)
|
96
88
|
end.compact
|
97
89
|
|
98
90
|
reference_columns + table_columns
|
99
91
|
end
|
100
92
|
|
93
|
+
def build_table_column(column, model, default_attrs)
|
94
|
+
{
|
95
|
+
name: column.name,
|
96
|
+
display_name: column.name.humanize,
|
97
|
+
column_type: ActiveRecordUtils::Types::UNIFIED_TYPES[column.type.to_s] || column.type.to_s,
|
98
|
+
access_type: COLUMN_NAME_ACCESS_TYPES.fetch(column.name, ColumnAccessTypes::READ_WRITE),
|
99
|
+
default_value: default_attrs[column.name],
|
100
|
+
validators: fetch_validators(model, column.name),
|
101
|
+
reference: nil,
|
102
|
+
format: {},
|
103
|
+
virtual: false
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
101
107
|
def fetch_reference_columns(model)
|
102
108
|
default_attrs = model.new.attributes
|
103
109
|
|
@@ -110,32 +116,36 @@ module Motor
|
|
110
116
|
next
|
111
117
|
end
|
112
118
|
|
113
|
-
column_name = ref.belongs_to? ? ref.foreign_key.to_s : name
|
114
|
-
|
115
119
|
next if ref.klass.name == 'ActiveStorage::Blob'
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
{
|
120
|
-
name: column_name,
|
121
|
-
display_name: column_name.humanize,
|
122
|
-
column_type: is_attachment ? 'file' : 'integer',
|
123
|
-
access_type: ref.belongs_to? || is_attachment ? ColumnAccessTypes::READ_WRITE : ColumnAccessTypes::READ_ONLY,
|
124
|
-
default_value: default_attrs[column_name],
|
125
|
-
validators: fetch_validators(model, column_name),
|
126
|
-
format: {},
|
127
|
-
reference: {
|
128
|
-
name: name,
|
129
|
-
model_name: ref.klass.name.underscore,
|
130
|
-
reference_type: ref.belongs_to? ? 'belongs_to' : 'has_one',
|
131
|
-
foreign_key: ref.foreign_key,
|
132
|
-
polymorphic: ref.polymorphic? || is_attachment
|
133
|
-
},
|
134
|
-
virtual: false
|
135
|
-
}
|
121
|
+
build_reflection_column(name, model, ref, default_attrs)
|
136
122
|
end.compact
|
137
123
|
end
|
138
124
|
|
125
|
+
def build_reflection_column(name, model, ref, default_attrs)
|
126
|
+
column_name = ref.belongs_to? ? ref.foreign_key.to_s : name
|
127
|
+
is_attachment = ref.klass.name == 'ActiveStorage::Attachment'
|
128
|
+
access_type = ref.belongs_to? || is_attachment ? ColumnAccessTypes::READ_WRITE : ColumnAccessTypes::READ_ONLY
|
129
|
+
|
130
|
+
{
|
131
|
+
name: column_name,
|
132
|
+
display_name: column_name.humanize,
|
133
|
+
column_type: is_attachment ? 'file' : 'integer',
|
134
|
+
access_type: access_type,
|
135
|
+
default_value: default_attrs[column_name],
|
136
|
+
validators: fetch_validators(model, column_name),
|
137
|
+
format: {},
|
138
|
+
reference: {
|
139
|
+
name: name,
|
140
|
+
model_name: ref.klass.name.underscore,
|
141
|
+
reference_type: ref.belongs_to? ? 'belongs_to' : 'has_one',
|
142
|
+
foreign_key: ref.foreign_key,
|
143
|
+
polymorphic: ref.polymorphic? || is_attachment
|
144
|
+
},
|
145
|
+
virtual: false
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
139
149
|
def fetch_associations(model)
|
140
150
|
model.reflections.map do |name, ref|
|
141
151
|
next if ref.has_one? || ref.belongs_to?
|
@@ -182,10 +192,12 @@ module Motor
|
|
182
192
|
end
|
183
193
|
|
184
194
|
def eager_load_models!
|
185
|
-
|
186
|
-
Zeitwerk::Loader
|
187
|
-
|
188
|
-
|
195
|
+
MUTEX.synchronize do
|
196
|
+
if Rails::VERSION::MAJOR > 5 && defined?(Zeitwerk::Loader)
|
197
|
+
Zeitwerk::Loader.eager_load_all
|
198
|
+
else
|
199
|
+
Rails.application.eager_load!
|
200
|
+
end
|
189
201
|
end
|
190
202
|
end
|
191
203
|
end
|
@@ -27,40 +27,81 @@ module Motor
|
|
27
27
|
def merge_model(model, configs)
|
28
28
|
updated_model = model.merge(configs.slice(*RESOURCE_ATTRS))
|
29
29
|
|
30
|
-
updated_model
|
30
|
+
merge_actions!(updated_model, configs)
|
31
|
+
merge_assiciations!(updated_model, configs)
|
32
|
+
merge_columns!(updated_model, configs)
|
33
|
+
merge_tabs!(updated_model, configs)
|
34
|
+
merge_scopes!(updated_model, configs)
|
35
|
+
|
36
|
+
updated_model
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param model [HashWithIndifferentAccess]
|
40
|
+
# @param configs [HashWithIndifferentAccess]
|
41
|
+
# @return [HashWithIndifferentAccess]
|
42
|
+
def merge_assiciations!(model, configs)
|
43
|
+
model[:associations] = merge_by_name(
|
31
44
|
model[:associations],
|
32
45
|
configs[:associations],
|
33
46
|
{},
|
34
47
|
->(_) { true }
|
35
48
|
)
|
36
49
|
|
37
|
-
|
50
|
+
model
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param model [HashWithIndifferentAccess]
|
54
|
+
# @param configs [HashWithIndifferentAccess]
|
55
|
+
# @return [HashWithIndifferentAccess]
|
56
|
+
def merge_columns!(model, configs)
|
57
|
+
model[:columns] = merge_by_name(
|
38
58
|
model[:columns],
|
39
59
|
configs[:columns],
|
40
60
|
COLUMN_DEFAULTS,
|
41
61
|
->(scope) { !scope[:virtual] }
|
42
62
|
)
|
43
63
|
|
44
|
-
|
64
|
+
model
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param model [HashWithIndifferentAccess]
|
68
|
+
# @param configs [HashWithIndifferentAccess]
|
69
|
+
# @return [HashWithIndifferentAccess]
|
70
|
+
def merge_actions!(model, configs)
|
71
|
+
model[:actions] = merge_by_name(
|
45
72
|
model[:actions],
|
46
73
|
configs[:actions],
|
47
74
|
ACTION_DEFAULTS
|
48
75
|
)
|
49
76
|
|
50
|
-
|
77
|
+
model
|
78
|
+
end
|
79
|
+
|
80
|
+
# @param model [HashWithIndifferentAccess]
|
81
|
+
# @param configs [HashWithIndifferentAccess]
|
82
|
+
# @return [HashWithIndifferentAccess]
|
83
|
+
def merge_tabs!(model, configs)
|
84
|
+
model[:tabs] = merge_by_name(
|
51
85
|
model[:tabs],
|
52
86
|
configs[:tabs],
|
53
87
|
TAB_DEFAULTS
|
54
88
|
)
|
55
89
|
|
56
|
-
|
90
|
+
model
|
91
|
+
end
|
92
|
+
|
93
|
+
# @param model [HashWithIndifferentAccess]
|
94
|
+
# @param configs [HashWithIndifferentAccess]
|
95
|
+
# @return [HashWithIndifferentAccess]
|
96
|
+
def merge_scopes!(model, configs)
|
97
|
+
model[:scopes] = merge_by_name(
|
57
98
|
model[:scopes],
|
58
99
|
configs[:scopes],
|
59
100
|
SCOPE_DEFAULTS,
|
60
101
|
->(scope) { scope[:scope_type] != 'filter' }
|
61
102
|
)
|
62
103
|
|
63
|
-
|
104
|
+
model
|
64
105
|
end
|
65
106
|
|
66
107
|
# @param defaults [Array<HashWithIndifferentAccess>]
|
@@ -77,47 +77,26 @@ module Motor
|
|
77
77
|
normalized_preferences = existing_prefs.merge(normalized_preferences)
|
78
78
|
normalized_preferences = reject_default(default_prefs, normalized_preferences)
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
)
|
86
|
-
end
|
80
|
+
normalize_configs!(normalized_preferences, :columns, default_prefs, existing_prefs, new_prefs)
|
81
|
+
normalize_configs!(normalized_preferences, :associations, default_prefs, existing_prefs, new_prefs)
|
82
|
+
normalize_configs!(normalized_preferences, :actions, default_prefs, existing_prefs, new_prefs)
|
83
|
+
normalize_configs!(normalized_preferences, :tabs, default_prefs, existing_prefs, new_prefs)
|
84
|
+
normalize_configs!(normalized_preferences, :scopes, default_prefs, existing_prefs, new_prefs)
|
87
85
|
|
88
|
-
|
89
|
-
|
90
|
-
default_prefs[:associations],
|
91
|
-
existing_prefs.fetch(:associations, []),
|
92
|
-
new_prefs.fetch(:associations, [])
|
93
|
-
)
|
94
|
-
end
|
86
|
+
normalized_preferences.compact
|
87
|
+
end
|
95
88
|
|
96
|
-
|
97
|
-
|
98
|
-
default_prefs[:actions],
|
99
|
-
existing_prefs.fetch(:actions, []),
|
100
|
-
new_prefs.fetch(:actions, [])
|
101
|
-
)
|
102
|
-
end
|
89
|
+
def normalize_configs!(preferences, configs_name, default_prefs, existing_prefs, new_prefs)
|
90
|
+
return preferences if new_prefs[configs_name].blank?
|
103
91
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
new_prefs.fetch(:tabs, [])
|
109
|
-
)
|
110
|
-
end
|
92
|
+
normalized_configs = public_send("normalize_#{configs_name}",
|
93
|
+
default_prefs[:actions],
|
94
|
+
existing_prefs.fetch(:actions, []),
|
95
|
+
new_prefs.fetch(:actions, []))
|
111
96
|
|
112
|
-
|
113
|
-
normalized_preferences[:scopes] = normalize_scopes(
|
114
|
-
default_prefs[:scopes],
|
115
|
-
existing_prefs.fetch(:scopes, []),
|
116
|
-
new_prefs.fetch(:scopes, [])
|
117
|
-
)
|
118
|
-
end
|
97
|
+
preferences[configs_name] = normalized_configs
|
119
98
|
|
120
|
-
|
99
|
+
preferences
|
121
100
|
end
|
122
101
|
|
123
102
|
# @param default_columns [Array<HashWithIndifferentAccess>]
|
@@ -23,21 +23,29 @@ module Motor
|
|
23
23
|
|
24
24
|
schema = sort_by_name(schema, configs['resources.order'])
|
25
25
|
|
26
|
-
schema.map
|
27
|
-
|
28
|
-
associations_order = configs["resources.#{model[:name]}.associations.order"]
|
29
|
-
actions_order = configs["resources.#{model[:name]}.actions.order"]
|
30
|
-
tabs_order = configs["resources.#{model[:name]}.tabs.order"]
|
31
|
-
scopes_order = configs["resources.#{model[:name]}.scopes.order"]
|
26
|
+
schema.map { |model| reorder_model(model, configs) }
|
27
|
+
end
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
)
|
40
|
-
|
29
|
+
def reorder_model(model, configs)
|
30
|
+
order_configs = build_order_configs(model[:name], configs)
|
31
|
+
|
32
|
+
model.merge(
|
33
|
+
columns: sort_by_name(sort_columns(model[:columns]), order_configs[:columns], sort_alphabetically: false),
|
34
|
+
associations: sort_by_name(model[:associations], order_configs[:associations]),
|
35
|
+
actions: sort_by_name(model[:actions], order_configs[:actions], sort_alphabetically: false),
|
36
|
+
tabs: sort_by_name(model[:tabs], order_configs[:tabs], sort_alphabetically: false),
|
37
|
+
scopes: sort_by_name(model[:scopes], order_configs[:scopes])
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_order_configs(model_name, configs)
|
42
|
+
{
|
43
|
+
columns: configs["resources.#{model_name}.columns.order"],
|
44
|
+
associations: configs["resources.#{model_name}.associations.order"],
|
45
|
+
actions: configs["resources.#{model_name}.actions.order"],
|
46
|
+
tabs: configs["resources.#{model_name}.tabs.order"],
|
47
|
+
scopes: configs["resources.#{model_name}.scopes.order"]
|
48
|
+
}
|
41
49
|
end
|
42
50
|
|
43
51
|
# @param list [Array<HashWithIndifferentAccess>]
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Motor
|
4
4
|
module Queries
|
5
5
|
module RunQuery
|
6
|
-
DEFAULT_LIMIT =
|
6
|
+
DEFAULT_LIMIT = 100_000
|
7
7
|
|
8
8
|
QueryResult = Struct.new(:data, :columns, keyword_init: true)
|
9
9
|
|
@@ -13,6 +13,10 @@ module Motor
|
|
13
13
|
|
14
14
|
module_function
|
15
15
|
|
16
|
+
# @param query [Motor::Query]
|
17
|
+
# @param variables_hash [Hash]
|
18
|
+
# @param limit [Integer]
|
19
|
+
# @return [Motor::Queries::RunQuery::QueryResult]
|
16
20
|
def call(query, variables_hash: nil, limit: DEFAULT_LIMIT)
|
17
21
|
variables_hash ||= {}
|
18
22
|
|
@@ -21,15 +25,27 @@ module Motor
|
|
21
25
|
QueryResult.new(data: result.rows, columns: build_columns_hash(result))
|
22
26
|
end
|
23
27
|
|
28
|
+
# @param query [Motor::Query]
|
29
|
+
# @param limit [Integer]
|
30
|
+
# @param variables_hash [Hash]
|
31
|
+
# @return [ActiveRecord::Result]
|
24
32
|
def execute_query(query, limit, variables_hash)
|
33
|
+
result = nil
|
25
34
|
statement = prepare_sql_statement(query, limit, variables_hash)
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
36
|
+
ActiveRecord::Base.transaction do
|
37
|
+
result =
|
38
|
+
case ActiveRecord::Base.connection
|
39
|
+
when ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
40
|
+
PostgresqlExecQuery.call(ActiveRecord::Base.connection, statement)
|
41
|
+
else
|
42
|
+
ActiveRecord::Base.connection.exec_query(*statement)
|
43
|
+
end
|
44
|
+
|
45
|
+
raise ActiveRecord::Rollback
|
32
46
|
end
|
47
|
+
|
48
|
+
result
|
33
49
|
end
|
34
50
|
|
35
51
|
# @param result [ActiveRecord::Result]
|
@@ -46,6 +62,10 @@ module Motor
|
|
46
62
|
end
|
47
63
|
end
|
48
64
|
|
65
|
+
# @param query [Motor::Query]
|
66
|
+
# @param limit [Integer]
|
67
|
+
# @param variables_hash [Hash]
|
68
|
+
# @return [Array]
|
49
69
|
def prepare_sql_statement(query, limit, variables_hash)
|
50
70
|
variables = merge_variable_default_values(query.preferences.fetch(:variables, []), variables_hash)
|
51
71
|
|
@@ -56,6 +76,8 @@ module Motor
|
|
56
76
|
[format(WITH_STATEMENT_TEMPLATE, sql_body: sql.strip.gsub(/;\z/, ''), limit: limit), 'SQL', attributes]
|
57
77
|
end
|
58
78
|
|
79
|
+
# @param variables [Array<(String, Object)>]
|
80
|
+
# @return [Array<ActiveRecord::Relation::QueryAttribute>]
|
59
81
|
def build_statement_attributes(variables)
|
60
82
|
variables.map do |variable_name, value|
|
61
83
|
ActiveRecord::Relation::QueryAttribute.new(
|
@@ -66,6 +88,9 @@ module Motor
|
|
66
88
|
end
|
67
89
|
end
|
68
90
|
|
91
|
+
# @param variable_configs [Array<Hash>]
|
92
|
+
# @param variable_hash [Hash]
|
93
|
+
# @return [Hash]
|
69
94
|
def merge_variable_default_values(variable_configs, variables_hash)
|
70
95
|
variable_configs.each_with_object({}) do |variable, acc|
|
71
96
|
acc[variable[:name]] = variables_hash[variable[:name]] || variable[:default_value]
|
data/lib/motor/ui_configs.rb
CHANGED
@@ -27,22 +27,42 @@ module Motor
|
|
27
27
|
{
|
28
28
|
base_path: Motor::Admin.routes.url_helpers.motor_path,
|
29
29
|
schema: Motor::BuildSchema.call,
|
30
|
-
header_links:
|
31
|
-
queries:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
.as_json(only: %i[id title updated_at],
|
36
|
-
include: { tags: { only: %i[id name] } }),
|
37
|
-
alerts: Motor::Alert.all.active.preload(:tags)
|
38
|
-
.as_json(only: %i[id name is_enabled updated_at],
|
39
|
-
include: { tags: { only: %i[id name] } }),
|
40
|
-
forms: Motor::Form.all.active.preload(:tags)
|
41
|
-
.as_json(only: %i[id name updated_at],
|
42
|
-
include: { tags: { only: %i[id name] } })
|
30
|
+
header_links: header_links_data_hash,
|
31
|
+
queries: queries_data_hash,
|
32
|
+
dashboards: dashboards_data_hash,
|
33
|
+
alerts: alerts_data_hash,
|
34
|
+
forms: forms_data_hash
|
43
35
|
}
|
44
36
|
end
|
45
37
|
|
38
|
+
def header_links_data_hash
|
39
|
+
Motor::Config.find_by(key: 'header.links')&.value || []
|
40
|
+
end
|
41
|
+
|
42
|
+
def queries_data_hash
|
43
|
+
Motor::Query.all.active.preload(:tags)
|
44
|
+
.as_json(only: %i[id name updated_at],
|
45
|
+
include: { tags: { only: %i[id name] } })
|
46
|
+
end
|
47
|
+
|
48
|
+
def dashboards_data_hash
|
49
|
+
Motor::Dashboard.all.active.preload(:tags)
|
50
|
+
.as_json(only: %i[id title updated_at],
|
51
|
+
include: { tags: { only: %i[id name] } })
|
52
|
+
end
|
53
|
+
|
54
|
+
def alerts_data_hash
|
55
|
+
Motor::Alert.all.active.preload(:tags)
|
56
|
+
.as_json(only: %i[id name is_enabled updated_at],
|
57
|
+
include: { tags: { only: %i[id name] } })
|
58
|
+
end
|
59
|
+
|
60
|
+
def forms_data_hash
|
61
|
+
Motor::Form.all.active.preload(:tags)
|
62
|
+
.as_json(only: %i[id name updated_at],
|
63
|
+
include: { tags: { only: %i[id name] } })
|
64
|
+
end
|
65
|
+
|
46
66
|
# @return [String]
|
47
67
|
def cache_key
|
48
68
|
ActiveRecord::Base.connection.execute(
|
data/lib/motor/version.rb
CHANGED
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
"fonts/ionicons.ttf?v=3.0.0-alpha.3": "fonts/ionicons.ttf",
|
6
6
|
"fonts/ionicons.woff2?v=3.0.0-alpha.3": "fonts/ionicons.woff2",
|
7
7
|
"fonts/ionicons.woff?v=3.0.0-alpha.3": "fonts/ionicons.woff",
|
8
|
-
"main-
|
9
|
-
"main-
|
10
|
-
"main-
|
11
|
-
"main.css": "main-
|
12
|
-
"main.js": "main-
|
8
|
+
"main-4da1a5102d7bc66aefd0.css.gz": "main-4da1a5102d7bc66aefd0.css.gz",
|
9
|
+
"main-4da1a5102d7bc66aefd0.js.LICENSE.txt": "main-4da1a5102d7bc66aefd0.js.LICENSE.txt",
|
10
|
+
"main-4da1a5102d7bc66aefd0.js.gz": "main-4da1a5102d7bc66aefd0.js.gz",
|
11
|
+
"main.css": "main-4da1a5102d7bc66aefd0.css",
|
12
|
+
"main.js": "main-4da1a5102d7bc66aefd0.js"
|
13
13
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motor-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Matsyburka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-filter
|
@@ -214,8 +214,8 @@ files:
|
|
214
214
|
- lib/motor/ui_configs.rb
|
215
215
|
- lib/motor/version.rb
|
216
216
|
- ui/dist/fonts/ionicons.woff2
|
217
|
-
- ui/dist/main-
|
218
|
-
- ui/dist/main-
|
217
|
+
- ui/dist/main-4da1a5102d7bc66aefd0.css.gz
|
218
|
+
- ui/dist/main-4da1a5102d7bc66aefd0.js.gz
|
219
219
|
- ui/dist/manifest.json
|
220
220
|
homepage:
|
221
221
|
licenses:
|
Binary file
|