motor-admin 0.2.77 → 0.2.80

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: d8079828af8d469f3dd4f3a77827541377f39522a9f2dbfbf7e867afbc3745af
4
- data.tar.gz: 34137b38f20933daf40643c1005b36d59be11b8c2f0374e39d615a01b6f9abd9
3
+ metadata.gz: 7739ccc3f3a69f6040c87ff4cac7f02bd84fc236347800b11fe98c7807e14aca
4
+ data.tar.gz: 4e3715f4a68437d690b39188d329e861156d01425fd31bbe8596d352885dfff6
5
5
  SHA512:
6
- metadata.gz: ede5d9f24ad96a896b332995bc288bf87272d676a65ff6ed735d4da6772a15f3f6daf707f6f81670957c45df66e48bb2f74439120e7b2b209a5a2007e2f63f66
7
- data.tar.gz: 654307b067e993885d1d911ea682b06825a4f4d11238bd92692a892da0f215a00e983332f2acab2d9e04e6295ec51a883797b8f73368ae3792d772c923eef0c0
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
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.2.77'
4
+ VERSION = '0.2.80'
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.77
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-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_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-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: