motor-admin 0.2.10 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/controllers/motor/api_base_controller.rb +5 -1
- data/app/controllers/motor/data_controller.rb +8 -4
- data/app/controllers/motor/sessions_controller.rb +13 -0
- data/config/locales/en.yml +9 -0
- data/config/locales/es.yml +9 -0
- data/config/locales/pt.yml +9 -0
- data/config/routes.rb +1 -0
- data/lib/motor/active_record_utils/types.rb +1 -0
- data/lib/motor/active_record_utils.rb +12 -0
- data/lib/motor/build_schema/load_from_rails.rb +2 -1
- data/lib/motor/build_schema/merge_schema_configs.rb +1 -1
- data/lib/motor/queries/run_query.rb +37 -3
- data/lib/motor/resources.rb +1 -1
- data/lib/motor/version.rb +1 -1
- data/ui/dist/{main-9d527c31af98f3d09fea.css.gz → main-6568183ef6647799a421.css.gz} +0 -0
- data/ui/dist/main-6568183ef6647799a421.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +5 -4
- data/ui/dist/main-9d527c31af98f3d09fea.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: 83d142a47680bf5eed1aea0f1fccb5b90de231d8105036a5d284cf79d43d586e
|
4
|
+
data.tar.gz: 2a9dfd66258c1c446aabc2e1367fad73f1df56867b61d79d47142eefea71622a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdbfad1a4edd14c987c1f956e525044176ef445125a3e43ae4284618cc0721343a2a28a3c03dcb1d470fd9f746e699cff209911597c71b320540cc11655774b8
|
7
|
+
data.tar.gz: d2c662baf663b0cb76edc3ced65c1b331bbf452aaa1a6fa75d4a73cfcd72d7ad0018a4529536a33fe91d6825aa553ad867289895d79398cc73b86ebd1bc0116f
|
data/README.md
CHANGED
@@ -39,6 +39,19 @@ $ rails motor:install && rake db:migrate
|
|
39
39
|
* [Optimized for mobile](#optimized-for-mobile)
|
40
40
|
* [Configurations sync between environments](#configurations-sync)
|
41
41
|
|
42
|
+
## [Pro](https://www.getmotoradmin.com/pro)
|
43
|
+
|
44
|
+
* Multiple databases support
|
45
|
+
* Audit log
|
46
|
+
* Live collaboration
|
47
|
+
* Multi-factor authentication
|
48
|
+
* Custom styling
|
49
|
+
* Personalized report alerts via Slack
|
50
|
+
* Full-text search
|
51
|
+
* Stripe integration
|
52
|
+
* Shareable forms and reports
|
53
|
+
* [learn more](https://www.getmotoradmin.com/pro)
|
54
|
+
|
42
55
|
### Customizable CRUD
|
43
56
|
|
44
57
|
![Resource settings](https://user-images.githubusercontent.com/5418788/119318569-2a840e80-bc82-11eb-9ba3-f3964eb6f997.png)
|
@@ -22,7 +22,11 @@ module Motor
|
|
22
22
|
rescue_from CanCan::AccessDenied do |e|
|
23
23
|
Rails.logger.error(e)
|
24
24
|
|
25
|
-
|
25
|
+
if params[:action].in?(%w[create update destroy])
|
26
|
+
render json: { errors: [I18n.t('motor.not_authorized_to_perform_action')] }, status: :forbidden
|
27
|
+
else
|
28
|
+
render json: { errors: [e.message] }, status: :forbidden
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -10,10 +10,14 @@ module Motor
|
|
10
10
|
def index
|
11
11
|
@resources = Motor::ApiQuery.call(@resources, params)
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
if params[:format] == 'csv'
|
14
|
+
render plain: Motor::ActiveRecordUtils.generate_csv_for_relation(@resources, reset_limit: true)
|
15
|
+
else
|
16
|
+
render json: {
|
17
|
+
data: Motor::ApiQuery::BuildJson.call(@resources, params, current_ability),
|
18
|
+
meta: Motor::ApiQuery::BuildMeta.call(@resources, params)
|
19
|
+
}
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def show
|
data/config/locales/en.yml
CHANGED
@@ -265,3 +265,12 @@ en:
|
|
265
265
|
audio: Audio
|
266
266
|
video: Video
|
267
267
|
display_column: Display column
|
268
|
+
not_authorized_to_perform_action: You are not authorized to perform this action.
|
269
|
+
download: Download
|
270
|
+
alert: Alert
|
271
|
+
downloading: Downloading
|
272
|
+
display_id: Display ID
|
273
|
+
display_settings: Display settings
|
274
|
+
sign_out: Sign out
|
275
|
+
header: Header
|
276
|
+
user_dropdown: User dropdown
|
data/config/locales/es.yml
CHANGED
@@ -265,6 +265,15 @@ es:
|
|
265
265
|
audio: Audio
|
266
266
|
video: Video
|
267
267
|
display_column: Columna de visualización
|
268
|
+
not_authorized_to_perform_action: No está autorizado a realizar esta acción.
|
269
|
+
download: Descargar
|
270
|
+
alert: Alerta
|
271
|
+
downloading: Descargando
|
272
|
+
display_id: Visualizar ID
|
273
|
+
display_settings: Configuración de la pantalla
|
274
|
+
sign_out: Sign out
|
275
|
+
header: Header
|
276
|
+
user_dropdown: User dropdown
|
268
277
|
i:
|
269
278
|
locale: es
|
270
279
|
select:
|
data/config/locales/pt.yml
CHANGED
@@ -261,6 +261,15 @@ pt:
|
|
261
261
|
audio: Áudio
|
262
262
|
video: Vídeo
|
263
263
|
display_column: Coluna de exibição
|
264
|
+
not_authorized_to_perform_action: Não está autorizado a realizar esta acção.
|
265
|
+
download: Descarregar
|
266
|
+
alert: Alerta
|
267
|
+
downloading: Descarregamento
|
268
|
+
display_id: Mostrar ID
|
269
|
+
display_settings: Definições de visualização
|
270
|
+
sign_out: Sign out
|
271
|
+
header: Header
|
272
|
+
user_dropdown: User dropdown
|
264
273
|
i:
|
265
274
|
locale: pt
|
266
275
|
select:
|
data/config/routes.rb
CHANGED
@@ -19,6 +19,7 @@ Motor::Admin.routes.draw do
|
|
19
19
|
resources :icons, only: %i[index]
|
20
20
|
resources :active_storage_attachments, only: %i[create], path: 'data/active_storage__attachments'
|
21
21
|
resources :audits, only: %i[index]
|
22
|
+
resource :session, only: %i[destroy]
|
22
23
|
resources :resources, path: '/data/:resource',
|
23
24
|
only: %i[index show update create destroy],
|
24
25
|
controller: 'data',
|
@@ -12,6 +12,18 @@ module Motor
|
|
12
12
|
ActiveRecord::Base.connection.reset_sequence!(model.table_name, 'id')
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def generate_csv_for_relation(relation, reset_limit: false)
|
17
|
+
relation = relation.limit(nil).offset(nil) if reset_limit
|
18
|
+
|
19
|
+
result = relation.klass.connection.exec_query(relation.to_sql)
|
20
|
+
|
21
|
+
CSV.generate do |csv|
|
22
|
+
csv << result.columns
|
23
|
+
|
24
|
+
result.rows.each { |row| csv << row }
|
25
|
+
end
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
17
29
|
|
@@ -135,7 +135,7 @@ module Motor
|
|
135
135
|
access_type: ColumnAccessTypes::READ_ONLY,
|
136
136
|
column_source: ColumnSources::QUERY,
|
137
137
|
virtual: false
|
138
|
-
)
|
138
|
+
).with_indifferent_access
|
139
139
|
end
|
140
140
|
|
141
141
|
reflection_columns = columns_index.values.select { |c| c[:column_source] == ColumnSources::REFLECTION }
|
@@ -83,18 +83,52 @@ module Motor
|
|
83
83
|
# @param result [ActiveRecord::Result]
|
84
84
|
# @return [Hash]
|
85
85
|
def build_columns_hash(result)
|
86
|
-
result.columns.map do |column_name|
|
87
|
-
|
86
|
+
result.columns.map.with_index do |column_name, index|
|
87
|
+
column_type_class = result.column_types[column_name]
|
88
|
+
|
89
|
+
column_type =
|
90
|
+
if column_type_class
|
91
|
+
ActiveRecordUtils::Types.find_name_for_type(column_type_class)
|
92
|
+
else
|
93
|
+
not_nil_value = result.rows.reduce(nil) do |acc, row|
|
94
|
+
column = row[index]
|
95
|
+
|
96
|
+
break column unless column.nil?
|
97
|
+
|
98
|
+
acc
|
99
|
+
end
|
100
|
+
|
101
|
+
fetch_column_type_from_value(not_nil_value)
|
102
|
+
end
|
88
103
|
|
89
104
|
{
|
90
105
|
name: column_name,
|
91
106
|
display_name: column_name.humanize,
|
92
|
-
column_type:
|
107
|
+
column_type: column_type,
|
93
108
|
is_array: column_type.class.to_s == 'ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array'
|
94
109
|
}
|
95
110
|
end
|
96
111
|
end
|
97
112
|
|
113
|
+
# @param value [Object]
|
114
|
+
# @return [String]
|
115
|
+
def fetch_column_type_from_value(value)
|
116
|
+
case value
|
117
|
+
when Integer
|
118
|
+
'integer'
|
119
|
+
when Float
|
120
|
+
'float'
|
121
|
+
when Time
|
122
|
+
'datetime'
|
123
|
+
when Date
|
124
|
+
'date'
|
125
|
+
when TrueClass, FalseClass
|
126
|
+
'boolean'
|
127
|
+
else
|
128
|
+
'string'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
98
132
|
# @param query [Motor::Query]
|
99
133
|
# @param limit [Integer]
|
100
134
|
# @param variables_hash [Hash]
|
data/lib/motor/resources.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Motor
|
4
4
|
module Resources
|
5
|
-
RESOURCE_ATTRS = %w[display_name display_column icon custom_sql visible].freeze
|
5
|
+
RESOURCE_ATTRS = %w[display_name display_column icon custom_sql visible display_primary_key].freeze
|
6
6
|
COLUMN_ATTRS = %w[name display_name column_type access_type default_value reference virtual format].freeze
|
7
7
|
ASSOCIATION_ATTRS = %w[name display_name model_name icon visible foreign_key primary_key options virtual
|
8
8
|
polymorphic slug].freeze
|
data/lib/motor/version.rb
CHANGED
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -2601,9 +2601,9 @@
|
|
2601
2601
|
"icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
|
2602
2602
|
"icons/zoom-question.svg": "icons/zoom-question.svg",
|
2603
2603
|
"icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
|
2604
|
-
"main-
|
2605
|
-
"main-
|
2606
|
-
"main-
|
2607
|
-
"main.css": "main-
|
2608
|
-
"main.js": "main-
|
2604
|
+
"main-6568183ef6647799a421.css.gz": "main-6568183ef6647799a421.css.gz",
|
2605
|
+
"main-6568183ef6647799a421.js.LICENSE.txt": "main-6568183ef6647799a421.js.LICENSE.txt",
|
2606
|
+
"main-6568183ef6647799a421.js.gz": "main-6568183ef6647799a421.js.gz",
|
2607
|
+
"main.css": "main-6568183ef6647799a421.css",
|
2608
|
+
"main.js": "main-6568183ef6647799a421.js"
|
2609
2609
|
}
|
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.2.
|
4
|
+
version: 0.2.14
|
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-10-
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-filter
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- app/controllers/motor/run_queries_controller.rb
|
131
131
|
- app/controllers/motor/schema_controller.rb
|
132
132
|
- app/controllers/motor/send_alerts_controller.rb
|
133
|
+
- app/controllers/motor/sessions_controller.rb
|
133
134
|
- app/controllers/motor/tags_controller.rb
|
134
135
|
- app/controllers/motor/ui_controller.rb
|
135
136
|
- app/jobs/motor/alert_sending_job.rb
|
@@ -1524,8 +1525,8 @@ files:
|
|
1524
1525
|
- ui/dist/icons/zoom-money.svg.gz
|
1525
1526
|
- ui/dist/icons/zoom-out.svg.gz
|
1526
1527
|
- ui/dist/icons/zoom-question.svg.gz
|
1527
|
-
- ui/dist/main-
|
1528
|
-
- ui/dist/main-
|
1528
|
+
- ui/dist/main-6568183ef6647799a421.css.gz
|
1529
|
+
- ui/dist/main-6568183ef6647799a421.js.gz
|
1529
1530
|
- ui/dist/manifest.json
|
1530
1531
|
homepage:
|
1531
1532
|
licenses:
|
Binary file
|