motor-admin 0.1.47 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +19 -13
- data/app/controllers/concerns/motor/current_user_method.rb +15 -0
- data/app/controllers/motor/api_base_controller.rb +11 -17
- data/app/controllers/motor/application_controller.rb +1 -0
- data/app/controllers/motor/assets_controller.rb +1 -1
- data/app/controllers/motor/ui_controller.rb +2 -0
- data/app/mailers/motor/alerts_mailer.rb +3 -3
- data/app/models/motor/tag.rb +1 -1
- data/app/views/motor/ui/show.html.erb +1 -1
- data/lib/motor/api_query/apply_scope.rb +1 -1
- data/lib/motor/api_query/build_json.rb +2 -2
- data/lib/motor/api_query/search.rb +1 -7
- data/lib/motor/assets.rb +1 -1
- data/lib/motor/build_schema/find_icon.rb +1 -0
- data/lib/motor/configs/build_ui_app_tag.rb +6 -6
- data/lib/motor/configs/load_from_cache.rb +1 -1
- data/lib/motor/configs/sync_with_remote.rb +1 -1
- data/lib/motor/queries/run_query.rb +1 -1
- data/lib/motor/tags.rb +1 -1
- data/lib/motor/tasks/motor.rake +4 -0
- data/lib/motor/version.rb +1 -1
- data/ui/dist/{main-5cac10cadc5aa16e9b69.css.gz → main-af386d0c907b80c29f22.css.gz} +0 -0
- data/ui/dist/main-af386d0c907b80c29f22.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +5 -4
- data/ui/dist/main-5cac10cadc5aa16e9b69.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: 55c1bf8c2fc221d84cbb142204893b6625d980d9c9966fe08cab12b1b8b9e9f6
|
4
|
+
data.tar.gz: 25c3c29dac2b0abd4414cf5c90ada44e4af357efb43ddd63fad4a632321bf89f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6faa1ebe8212cf8855b064f4c80df93b6f8a4ef93b09ba98d5565a24a86d6e4274f746511c28ffc5fca2da67710572ee53b2aaa384199ef3fa6de908cf774330
|
7
|
+
data.tar.gz: 737e7e1768be0721d825029176e3397007feb21794eb1eeec2ebe777c0a5c3880b3942f23be50476bdf7f12f564fd03fa3aadb8a69a31d8b06ba2dfb1111e845
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Low-code Admin panel and Business intelligence Rails engine **(no DSL - configurable from the UI)**.
|
4
4
|
|
5
|
-
🤓 [Demo App](https://motor-admin
|
5
|
+
🤓 [Demo App](https://motor-admin.herokuapp.com/demo) | [Features overview](https://www.youtube.com/watch?v=ngVoci8Hll4&list=PLu7llEMh0KcOkR3Uy_RJT0cXPZQKAYVsq&index=1)
|
6
6
|
|
7
|
-
[![Admin Panel](https://user-images.githubusercontent.com/5418788/
|
7
|
+
[![Admin Panel](https://user-images.githubusercontent.com/5418788/119318538-1f30e300-bc82-11eb-94a4-107c31c93b13.png)](https://motor-admin.herokuapp.com/demo)
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
Add this line to your application's Gemfile:
|
@@ -20,7 +20,7 @@ $ bundle install
|
|
20
20
|
|
21
21
|
Create and run migration:
|
22
22
|
```bash
|
23
|
-
$ rails
|
23
|
+
$ rails motor:install && rake db:migrate
|
24
24
|
```
|
25
25
|
|
26
26
|
## Features
|
@@ -38,11 +38,11 @@ $ rails generate motor:install && rake db:migrate
|
|
38
38
|
|
39
39
|
### Customizable CRUD
|
40
40
|
|
41
|
-
![Resource settings](https://user-images.githubusercontent.com/5418788/
|
41
|
+
![Resource settings](https://user-images.githubusercontent.com/5418788/119318569-2a840e80-bc82-11eb-9ba3-f3964eb6f997.png)
|
42
42
|
|
43
43
|
![Settings UI](https://user-images.githubusercontent.com/5418788/119263883-90708780-bbe9-11eb-9f9f-f76fed0b7f27.png)
|
44
44
|
|
45
|
-
Everything in the admin panel can be configured using
|
45
|
+
Everything in the admin panel can be configured using intuitive settings UI, which can be opened via the icon in the top right corner.
|
46
46
|
|
47
47
|
Data displayed on the resource page can be completely custimized via [SQL queries](#sql-queries) and [dashboards](#dashboards) attached to the resource as a tab. Usually, queries used to display resource data should contain `{{resource_name_id}}` [variable](#sql-queries).
|
48
48
|
|
@@ -50,13 +50,13 @@ Data displayed on the resource page can be completely custimized via [SQL querie
|
|
50
50
|
|
51
51
|
![Custom actions](https://user-images.githubusercontent.com/5418788/119266132-3c1dd580-bbf2-11eb-9666-09e1640eaf7b.png)
|
52
52
|
|
53
|
-
Custom resource actions can be added via Active Record method call, API endpoint, or [custom forms](#forms-builder). Also, it's possible to override default
|
53
|
+
Custom resource actions can be added via Active Record method call, API endpoint, or [custom forms](#forms-builder). Also, it's possible to override default create/update/delete actions.
|
54
54
|
|
55
55
|
### Forms Builder
|
56
56
|
|
57
57
|
![Custom form](https://user-images.githubusercontent.com/5418788/119264008-1391dd80-bbea-11eb-9f14-cb405e77fb60.png)
|
58
58
|
|
59
|
-
Values from the form fields can be used in API path via `{field_name}` syntax: `/api/some-endpoint/{
|
59
|
+
Values from the form fields can be used in API path via `{field_name}` syntax: `/api/some-endpoint/{resource_id}/apply`
|
60
60
|
|
61
61
|
### SQL Queries
|
62
62
|
|
@@ -68,7 +68,7 @@ Queries can include embeded variables via `{{variable}}` syntax ([mustache](http
|
|
68
68
|
|
69
69
|
![motor-visualization](https://user-images.githubusercontent.com/5418788/119264625-a2075e80-bbec-11eb-986c-6106dd6e47ce.png)
|
70
70
|
|
71
|
-
Data from the SQL query can be represented as: [table](https://motor-admin
|
71
|
+
Data from the SQL query can be represented as: [table](https://motor-admin.herokuapp.com/demo/queries/12), [number](https://motor-admin.herokuapp.com/demo/queries/6), [line chart](https://motor-admin.herokuapp.com/demo/queries/3), [bar chart](https://motor-admin.herokuapp.com/demo/queries/1), [pie chart](https://motor-admin.herokuapp.com/demo/queries/9), [funnel](https://motor-admin.herokuapp.com/demo/queries/7), [markdown](https://motor-admin.herokuapp.com/demo/queries/8)
|
72
72
|
|
73
73
|
### Dashboards
|
74
74
|
|
@@ -80,20 +80,20 @@ SQL queries can be organized into dashboards to create a convenient representati
|
|
80
80
|
|
81
81
|
![Email alert](https://user-images.githubusercontent.com/5418788/119265049-feb74900-bbed-11eb-8070-bcc8d6113b9b.png)
|
82
82
|
|
83
|
-
Query data can be sent via email periodically using the alerts feature. Interval of the alert email can be specified using natural language, e.g
|
83
|
+
Query data can be sent via email periodically using the alerts feature. Interval of the alert email can be specified using natural language, e.g., `every day at midnight`, `every Monday at 8 PM`, `every weekday at 6AM and 6PM`, `every minute`.
|
84
84
|
|
85
|
-
The sender address can be specified using `
|
85
|
+
The sender address can be specified using `MOTOR_ALERTS_FROM_ADDRESS` environment variable.
|
86
86
|
|
87
87
|
### Intelligence Search
|
88
88
|
|
89
89
|
![Intelligence search](https://user-images.githubusercontent.com/5418788/119266559-eea26800-bbf3-11eb-8cb3-d0538aa386a9.png)
|
90
90
|
|
91
|
-
Intelligence search can be opened
|
91
|
+
Intelligence search can be opened via the top right corner button or using <kbd>Cmd</kbd> + <kbd>P</kbd> shortcut.
|
92
92
|
|
93
93
|
|
94
94
|
### Optimized for Mobile
|
95
95
|
|
96
|
-
![motor-mobile](https://user-images.githubusercontent.com/5418788/
|
96
|
+
![motor-mobile](https://user-images.githubusercontent.com/5418788/119269566-03392d00-bc01-11eb-9e9d-1f6a58fe0749.png)
|
97
97
|
|
98
98
|
|
99
99
|
### Configurations Sync
|
@@ -127,6 +127,12 @@ Start webpack dev server:
|
|
127
127
|
yarn install && yarn serve
|
128
128
|
```
|
129
129
|
|
130
|
+
Setup development database:
|
131
|
+
|
132
|
+
```bash
|
133
|
+
rake app:db:create && rake app:db:setup
|
134
|
+
```
|
135
|
+
|
130
136
|
Start example application in development mode:
|
131
137
|
|
132
138
|
```bash
|
@@ -143,4 +149,4 @@ MOTOR_DEVELOPMENT=true rails s
|
|
143
149
|
|
144
150
|
## License
|
145
151
|
|
146
|
-
The gem is available as open source under the terms of the [MIT License](https://
|
152
|
+
The gem is available as open source under the terms of the [MIT License](https://github.com/omohokcoj/motor-admin/blob/master/LICENSE).
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Motor
|
4
|
+
module CurrentUserMethod
|
5
|
+
def current_user
|
6
|
+
if defined?(current_admin)
|
7
|
+
current_admin
|
8
|
+
elsif defined?(current_admin_user)
|
9
|
+
current_admin_user
|
10
|
+
elsif defined?(super)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,30 +2,24 @@
|
|
2
2
|
|
3
3
|
module Motor
|
4
4
|
class ApiBaseController < ActionController::API
|
5
|
+
include Motor::CurrentUserMethod
|
6
|
+
|
7
|
+
class CanCanAbilityManageAll
|
8
|
+
include CanCan::Ability
|
9
|
+
|
10
|
+
def initialize(_)
|
11
|
+
can :manage, :all
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
rescue_from StandardError do |e|
|
6
16
|
Rails.logger.error(e)
|
7
17
|
|
8
18
|
render json: { errors: [e.message] }, status: :internal_server_error
|
9
19
|
end
|
10
20
|
|
11
|
-
def current_user
|
12
|
-
if defined?(current_admin)
|
13
|
-
current_admin
|
14
|
-
elsif defined?(current_admin_user)
|
15
|
-
current_admin_user
|
16
|
-
elsif defined?(super)
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
21
|
def current_ability
|
22
|
-
|
23
|
-
klass.include(CanCan::Ability)
|
24
|
-
klass.define_method(:initialize) do |_user|
|
25
|
-
can :manage, :all
|
26
|
-
end
|
27
|
-
|
28
|
-
klass.new(current_user)
|
22
|
+
CanCanAbilityManageAll.new(current_user)
|
29
23
|
end
|
30
24
|
end
|
31
25
|
end
|
@@ -26,11 +26,11 @@ module Motor
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def from_address
|
29
|
-
from = ENV['
|
29
|
+
from = ENV['MOTOR_ALERTS_FROM_ADDRESS'].presence
|
30
30
|
|
31
31
|
from ||= application_mailer_default_from
|
32
32
|
from ||= mailer_config_from_address
|
33
|
-
from ||= "reports@#{ENV['HOST'].
|
33
|
+
from ||= "reports@#{ENV['HOST'].delete_prefix('www.')}" if ENV['HOST'].present?
|
34
34
|
|
35
35
|
from || 'reports@example.com'
|
36
36
|
end
|
@@ -44,7 +44,7 @@ module Motor
|
|
44
44
|
def mailer_config_from_address
|
45
45
|
return if Rails.application.config.action_mailer.default_url_options&.dig(:host).blank?
|
46
46
|
|
47
|
-
"reports@#{Rails.application.config.action_mailer.default_url_options[:host].
|
47
|
+
"reports@#{Rails.application.config.action_mailer.default_url_options[:host].delete_prefix('www.')}"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/app/models/motor/tag.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<%= raw(Motor::Configs::BuildUiAppTag.call) %>
|
1
|
+
<%= raw(Motor::Configs::BuildUiAppTag.call(current_user)) %>
|
@@ -96,8 +96,8 @@ module Motor
|
|
96
96
|
def normalize_include_params(params)
|
97
97
|
case params
|
98
98
|
when Array
|
99
|
-
params.
|
100
|
-
|
99
|
+
params.index_with do |_|
|
100
|
+
{ 'include' => {} }
|
101
101
|
end
|
102
102
|
when String
|
103
103
|
{ params => { 'include' => {} } }
|
@@ -57,13 +57,7 @@ module Motor
|
|
57
57
|
def find_searchable_columns(model)
|
58
58
|
model.columns.map do |column|
|
59
59
|
next unless column.type.in?(COLUMN_TYPES)
|
60
|
-
|
61
|
-
has_inclusion_validator =
|
62
|
-
model.validators_on(column.name).any? do |e|
|
63
|
-
e.is_a?(ActiveModel::Validations::InclusionValidator)
|
64
|
-
end
|
65
|
-
|
66
|
-
next if has_inclusion_validator
|
60
|
+
next if model.validators_on(column.name).any?(ActiveModel::Validations::InclusionValidator)
|
67
61
|
|
68
62
|
column.name
|
69
63
|
end.compact
|
data/lib/motor/assets.rb
CHANGED
@@ -12,21 +12,21 @@ module Motor
|
|
12
12
|
|
13
13
|
module_function
|
14
14
|
|
15
|
-
def call
|
15
|
+
def call(current_user = nil)
|
16
16
|
cache_keys = LoadFromCache.load_cache_keys
|
17
17
|
|
18
|
-
CACHE_STORE.fetch(cache_keys.hash) do
|
18
|
+
CACHE_STORE.fetch("#{cache_keys.hash}#{current_user&.id}") do
|
19
19
|
CACHE_STORE.clear
|
20
20
|
|
21
|
-
Motor::ApplicationController.helpers.
|
22
|
-
:div, '', id: 'app', data: build_data(cache_keys)
|
23
|
-
)
|
21
|
+
Motor::ApplicationController.helpers.tag.div('', id: 'app', data: build_data(cache_keys, current_user))
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
25
|
# @return [Hash]
|
28
|
-
def build_data(cache_keys = {})
|
26
|
+
def build_data(cache_keys = {}, current_user = nil)
|
29
27
|
{
|
28
|
+
current_user: current_user&.as_json(only: %i[id email]),
|
29
|
+
audits_count: Motor::Audit.count,
|
30
30
|
base_path: Motor::Admin.routes.url_helpers.motor_path,
|
31
31
|
schema: Motor::BuildSchema.call(cache_keys),
|
32
32
|
header_links: header_links_data_hash(cache_keys[:configs]),
|
@@ -9,7 +9,7 @@ module Motor
|
|
9
9
|
module_function
|
10
10
|
|
11
11
|
def call(remote_url, api_key)
|
12
|
-
url = remote_url.
|
12
|
+
url = remote_url.delete_suffix('/') + Motor::Configs::SYNC_API_PATH
|
13
13
|
|
14
14
|
sync_from_remote!(url, api_key)
|
15
15
|
sync_to_remote!(url, api_key)
|
@@ -73,7 +73,7 @@ module Motor
|
|
73
73
|
|
74
74
|
attributes = build_statement_attributes(query_variables)
|
75
75
|
|
76
|
-
[format(WITH_STATEMENT_TEMPLATE, sql_body: sql.strip.
|
76
|
+
[format(WITH_STATEMENT_TEMPLATE, sql_body: sql.strip.delete_suffix(';'), limit: limit), 'SQL', attributes]
|
77
77
|
end
|
78
78
|
|
79
79
|
# @param variables [Array<(String, Object)>]
|
data/lib/motor/tags.rb
CHANGED
@@ -8,7 +8,7 @@ module Motor
|
|
8
8
|
return taggable unless tags
|
9
9
|
|
10
10
|
tags.each do |tag_name|
|
11
|
-
next if taggable.taggable_tags.find { |tt| tt.tag.name.
|
11
|
+
next if taggable.taggable_tags.find { |tt| tt.tag.name.casecmp(tag_name).zero? }
|
12
12
|
|
13
13
|
tag = Tag.where('lower(name) = ?', tag_name.downcase).take || Tag.new(name: tag_name)
|
14
14
|
|
data/lib/motor/tasks/motor.rake
CHANGED
data/lib/motor/version.rb
CHANGED
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -2068,11 +2068,11 @@
|
|
2068
2068
|
"mail-opened.svg": "icons/mail-opened.svg",
|
2069
2069
|
"mail.svg": "icons/mail.svg",
|
2070
2070
|
"mailbox.svg": "icons/mailbox.svg",
|
2071
|
-
"main-
|
2072
|
-
"main-
|
2073
|
-
"main-
|
2074
|
-
"main.css": "main-
|
2075
|
-
"main.js": "main-
|
2071
|
+
"main-af386d0c907b80c29f22.css.gz": "main-af386d0c907b80c29f22.css.gz",
|
2072
|
+
"main-af386d0c907b80c29f22.js.LICENSE.txt": "main-af386d0c907b80c29f22.js.LICENSE.txt",
|
2073
|
+
"main-af386d0c907b80c29f22.js.gz": "main-af386d0c907b80c29f22.js.gz",
|
2074
|
+
"main.css": "main-af386d0c907b80c29f22.css",
|
2075
|
+
"main.js": "main-af386d0c907b80c29f22.js",
|
2076
2076
|
"man.svg": "icons/man.svg",
|
2077
2077
|
"manual-gearbox.svg": "icons/manual-gearbox.svg",
|
2078
2078
|
"map-2.svg": "icons/map-2.svg",
|
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.48
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-filter
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- LICENSE
|
119
119
|
- README.md
|
120
120
|
- Rakefile
|
121
|
+
- app/controllers/concerns/motor/current_user_method.rb
|
121
122
|
- app/controllers/concerns/motor/load_and_authorize_dynamic_resource.rb
|
122
123
|
- app/controllers/concerns/motor/wrap_io_params.rb
|
123
124
|
- app/controllers/motor/active_storage_attachments_controller.rb
|
@@ -1480,8 +1481,8 @@ files:
|
|
1480
1481
|
- ui/dist/icons/zoom-money.svg.gz
|
1481
1482
|
- ui/dist/icons/zoom-out.svg.gz
|
1482
1483
|
- ui/dist/icons/zoom-question.svg.gz
|
1483
|
-
- ui/dist/main-
|
1484
|
-
- ui/dist/main-
|
1484
|
+
- ui/dist/main-af386d0c907b80c29f22.css.gz
|
1485
|
+
- ui/dist/main-af386d0c907b80c29f22.js.gz
|
1485
1486
|
- ui/dist/manifest.json
|
1486
1487
|
homepage:
|
1487
1488
|
licenses:
|
Binary file
|