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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7103c85ab2173fce73651f6c94df44400326c3a0f6900d02958166334919764
4
- data.tar.gz: 2702651e4344a7e11a433e7af54a754413075e6de05fb56a12459f831a6087c9
3
+ metadata.gz: da078ff1a768cfd840bc95b76b6a4c3697e5eeca215d83623e1b72f05ebd3058
4
+ data.tar.gz: 5b322fdd899e6cbf80fa727afcb730a303703e0698f7b428b0766d354a32ea93
5
5
  SHA512:
6
- metadata.gz: bbebc6014289c848ac575afd1c21152e8671c7132af5806a0d550db254110e6b890c948dcdd216ccd54ec1f1849f0295237ad9f715775018b702059cff737e57
7
- data.tar.gz: efd8735097f2419c606fafee91bab1543888d5e2d98719a2b6efafb7fe2706e3dbe7d55b0aace3265ff78ddac94056b494980f4d42f2444587136913c95c82f1
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
@@ -307,6 +307,7 @@ el:
307
307
  there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
308
308
  send_file_url: Send file URL
309
309
  rating: Rating
310
+ total: Total
310
311
  i:
311
312
  locale: el
312
313
  select:
@@ -312,3 +312,4 @@ en:
312
312
  there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
313
313
  send_file_url: Send file URL
314
314
  rating: Rating
315
+ total: Total
@@ -307,6 +307,7 @@ es:
307
307
  there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
308
308
  send_file_url: Send file URL
309
309
  rating: Rating
310
+ total: Total
310
311
  i:
311
312
  locale: es
312
313
  select:
@@ -303,6 +303,7 @@ pt:
303
303
  there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
304
304
  send_file_url: Send file URL
305
305
  rating: Rating
306
+ total: Total
306
307
  i:
307
308
  locale: pt
308
309
  select:
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]
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.2.78'
4
+ VERSION = '0.2.81'
5
5
  end
@@ -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-490384ed80aab6944eff.css.gz": "main-490384ed80aab6944eff.css.gz",
3965
- "main-490384ed80aab6944eff.js.LICENSE.txt": "main-490384ed80aab6944eff.js.LICENSE.txt",
3966
- "main-490384ed80aab6944eff.js.gz": "main-490384ed80aab6944eff.js.gz",
3967
- "main.css": "main-490384ed80aab6944eff.css",
3968
- "main.js": "main-490384ed80aab6944eff.js"
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.78
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-25 00:00:00.000000000 Z
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-490384ed80aab6944eff.css.gz
2217
- - ui/dist/main-490384ed80aab6944eff.js.gz
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: