motor-admin 0.2.77 → 0.2.80
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/run_grapql_request_controller.rb +43 -0
- data/config/locales/el.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/pt.yml +1 -0
- data/config/routes.rb +1 -0
- data/lib/motor/api_configs.rb +14 -0
- data/lib/motor/configs/sync_from_hash.rb +8 -0
- data/lib/motor/version.rb +1 -1
- data/ui/dist/{main-490384ed80aab6944eff.css.gz → main-debd2ed9f328fcea487c.css.gz} +0 -0
- data/ui/dist/main-debd2ed9f328fcea487c.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +5 -4
- data/ui/dist/main-490384ed80aab6944eff.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: 7739ccc3f3a69f6040c87ff4cac7f02bd84fc236347800b11fe98c7807e14aca
|
4
|
+
data.tar.gz: 4e3715f4a68437d690b39188d329e861156d01425fd31bbe8596d352885dfff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96b7c6dd63520674aef9d9a6ada927453c0a5b672ef473fd46460688e05e82c4cd6b6e58e1e7fdc3cf30cae5c98533c333cb2987cabe4c8a59c8d46b7a59adf
|
7
|
+
data.tar.gz: 653862f91f58d82b5def8f1fb6673ca644d48c32a8a7cf2df5a7f0d8dfe58513c2b51eac5ddccbf890a2aed2cd318726ec92e5f26786ebedcdf1876e5eb74426
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Motor
|
4
|
+
class RunGraphqlRequestsController < ApiBaseController
|
5
|
+
JWT_TTL = 2.hours
|
6
|
+
|
7
|
+
wrap_parameters :data
|
8
|
+
|
9
|
+
def create
|
10
|
+
respond_with_result
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def respond_with_result
|
16
|
+
response = Motor::ApiConfigs.run_grapql(find_or_initialize_api_config,
|
17
|
+
query: request_params[:query],
|
18
|
+
variables: request_params[:variables],
|
19
|
+
headers: { 'Authorization' => "Bearer #{current_user_jwt}" })
|
20
|
+
|
21
|
+
self.response_body = response.body
|
22
|
+
self.status = response.code.to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_or_initialize_api_config
|
26
|
+
Motor::ApiConfig.find_by(name: request_params[:api_config_name]) ||
|
27
|
+
Motor::ApiConfig.new(url: request_params[:api_config_name])
|
28
|
+
end
|
29
|
+
|
30
|
+
def current_user_jwt
|
31
|
+
return '' unless defined?(JWT)
|
32
|
+
return '' unless current_user
|
33
|
+
|
34
|
+
payload = { uid: current_user.id, email: current_user.email, exp: JWT_TTL.from_now.to_i }
|
35
|
+
|
36
|
+
JWT.encode(payload, Rails.application.secrets.secret_key_base)
|
37
|
+
end
|
38
|
+
|
39
|
+
def request_params
|
40
|
+
params.require(:data).permit!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/config/locales/el.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/pt.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -15,6 +15,7 @@ Motor::Admin.routes.draw do
|
|
15
15
|
resources :schema, only: %i[index show], param: 'resource'
|
16
16
|
resources :dashboards, only: %i[index show create update destroy]
|
17
17
|
resource :run_api_request, only: %i[show create]
|
18
|
+
resource :run_graphql_request, only: %i[create]
|
18
19
|
resources :api_configs, only: %i[index create destroy]
|
19
20
|
resources :forms, only: %i[index show create update destroy]
|
20
21
|
resources :alerts, only: %i[index show create update destroy]
|
data/lib/motor/api_configs.rb
CHANGED
@@ -23,5 +23,19 @@ module Motor
|
|
23
23
|
body&.to_json
|
24
24
|
)
|
25
25
|
end
|
26
|
+
|
27
|
+
def run_grapql(api_config, query:, variables: {}, headers: {})
|
28
|
+
body = {
|
29
|
+
query: query,
|
30
|
+
variables: variables.merge(form_data: variables)
|
31
|
+
}
|
32
|
+
|
33
|
+
Motor::NetHttpUtils.post(
|
34
|
+
api_config.url,
|
35
|
+
{},
|
36
|
+
DEFAULT_HEADERS.merge(headers).merge(api_config.headers),
|
37
|
+
body.to_json
|
38
|
+
)
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
@@ -67,6 +67,8 @@ module Motor
|
|
67
67
|
|
68
68
|
record.update!(attrs)
|
69
69
|
end
|
70
|
+
|
71
|
+
ActiveRecordUtils.reset_id_sequence!(Motor::Config)
|
70
72
|
end
|
71
73
|
|
72
74
|
def sync_api_configs(configs_hash)
|
@@ -83,6 +85,8 @@ module Motor
|
|
83
85
|
end
|
84
86
|
|
85
87
|
archive_api_configs(configs_index, configs_hash[:api_configs])
|
88
|
+
|
89
|
+
ActiveRecordUtils.reset_id_sequence!(Motor::ApiConfig)
|
86
90
|
end
|
87
91
|
|
88
92
|
def archive_api_configs(configs_index, api_configs)
|
@@ -91,6 +95,7 @@ module Motor
|
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
98
|
+
# rubocop:disable Metrics/AbcSize
|
94
99
|
def sync_resources(configs_hash)
|
95
100
|
resources_index = Motor::Configs::LoadFromCache.load_resources.index_by(&:name)
|
96
101
|
|
@@ -105,7 +110,10 @@ module Motor
|
|
105
110
|
record.updated_at_will_change!
|
106
111
|
record.update!(attrs)
|
107
112
|
end
|
113
|
+
|
114
|
+
ActiveRecordUtils.reset_id_sequence!(Motor::Resource)
|
108
115
|
end
|
116
|
+
# rubocop:enable Metrics/AbcSize
|
109
117
|
|
110
118
|
def sync_taggable(records, config_items, configs_timestamp, update_proc)
|
111
119
|
processed_records, create_items = update_taggable_items(records, config_items, update_proc)
|
data/lib/motor/version.rb
CHANGED
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -3961,9 +3961,9 @@
|
|
3961
3961
|
"icons/zoom-pan.svg.gz": "icons/zoom-pan.svg.gz",
|
3962
3962
|
"icons/zoom-question.svg": "icons/zoom-question.svg",
|
3963
3963
|
"icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
|
3964
|
-
"main-
|
3965
|
-
"main-
|
3966
|
-
"main-
|
3967
|
-
"main.css": "main-
|
3968
|
-
"main.js": "main-
|
3964
|
+
"main-debd2ed9f328fcea487c.css.gz": "main-debd2ed9f328fcea487c.css.gz",
|
3965
|
+
"main-debd2ed9f328fcea487c.js.LICENSE.txt": "main-debd2ed9f328fcea487c.js.LICENSE.txt",
|
3966
|
+
"main-debd2ed9f328fcea487c.js.gz": "main-debd2ed9f328fcea487c.js.gz",
|
3967
|
+
"main.css": "main-debd2ed9f328fcea487c.css",
|
3968
|
+
"main.js": "main-debd2ed9f328fcea487c.js"
|
3969
3969
|
}
|
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.80
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Matsyburka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-filter
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- app/controllers/motor/resource_methods_controller.rb
|
130
130
|
- app/controllers/motor/resources_controller.rb
|
131
131
|
- app/controllers/motor/run_api_requests_controller.rb
|
132
|
+
- app/controllers/motor/run_grapql_request_controller.rb
|
132
133
|
- app/controllers/motor/run_queries_controller.rb
|
133
134
|
- app/controllers/motor/schema_controller.rb
|
134
135
|
- app/controllers/motor/send_alerts_controller.rb
|
@@ -2213,8 +2214,8 @@ files:
|
|
2213
2214
|
- ui/dist/icons/zoom-out.svg.gz
|
2214
2215
|
- ui/dist/icons/zoom-pan.svg.gz
|
2215
2216
|
- ui/dist/icons/zoom-question.svg.gz
|
2216
|
-
- ui/dist/main-
|
2217
|
-
- ui/dist/main-
|
2217
|
+
- ui/dist/main-debd2ed9f328fcea487c.css.gz
|
2218
|
+
- ui/dist/main-debd2ed9f328fcea487c.js.gz
|
2218
2219
|
- ui/dist/manifest.json
|
2219
2220
|
homepage:
|
2220
2221
|
licenses:
|
Binary file
|