motor-admin 0.2.78 → 0.2.81
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/motor/run_graphql_requests_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/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: da078ff1a768cfd840bc95b76b6a4c3697e5eeca215d83623e1b72f05ebd3058
|
4
|
+
data.tar.gz: 5b322fdd899e6cbf80fa727afcb730a303703e0698f7b428b0766d354a32ea93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1f8bad1cf1f199de4f075bb48aa71a93a0dc677dd6c2b88397af664f5e3821f1a7335e86f0c6d6a2bb10d65feeab52c1ac25aff50f7b8da44e404f3e8cd030
|
7
|
+
data.tar.gz: b7a47b541405b70e8294de701c0a35e77be21506e348ed60527480301add81dab8126ff7eeeee2bffef7a430ec9008eefa32765667622d7ef5e715df4768979a
|
@@ -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
|
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.81
|
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_graphql_requests_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
|