glib-web 3.27.1 → 3.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/glib/auth/response.rb +0 -22
- data/app/controllers/concerns/glib/json/libs.rb +33 -10
- data/app/helpers/glib/json_ui/action_builder/dialogs.rb +4 -0
- data/app/helpers/glib/json_ui/action_builder/windows.rb +5 -0
- data/app/helpers/glib/json_ui/page_helper.rb +3 -1
- data/app/helpers/glib/json_ui/view_builder/fields.rb +16 -0
- data/app/helpers/glib/json_ui/view_builder.rb +2 -0
- data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +19 -0
- data/app/views/json_ui/garage/actions/_windows.json.jbuilder +5 -0
- data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +13 -0
- data/lib/glib/blob.rb +15 -0
- data/lib/glib/direct_uploads_controller.rb +15 -7
- data/lib/glib/engine.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 575e99be2d5c58f1f7c9422f254b6a4b5b24180c82b38496e84c8dec22c41bcc
|
4
|
+
data.tar.gz: 76e6c254672deb1e9cd34a9452978ef4c9c32fc276fb8ac3e1e6eec1cbe8df85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a32237713616d6611d7cc6e57f57d81e7ff02823a68ed1d633e5de7276d4894ce67f30ff1766bda40df3bde0d53a9d69db2c677b740b266ae040e98f91c72a0b
|
7
|
+
data.tar.gz: 5fb068a0f809fc0ab4245fcbf1116758c253b04629a378fe8bd262486dc18d55490ac1cd854e0b4c1494a98cc4414abb108eb7f60baf1a84752565f66b7049ff
|
@@ -11,28 +11,6 @@ module Glib::Auth
|
|
11
11
|
params[:_dialog].present? # E.g. _dialog=v1
|
12
12
|
end
|
13
13
|
|
14
|
-
def __glib_error_dialog(title, message, bottom_views = [])
|
15
|
-
{
|
16
|
-
action: 'dialogs/show',
|
17
|
-
# Don't show another dialog, just use the current one since it's a new dialog anyway, which means
|
18
|
-
# that it wouldn't contain existing user data.
|
19
|
-
updateExisting: glib_json_dialog_mode?,
|
20
|
-
title: title,
|
21
|
-
body: {
|
22
|
-
childViews: [
|
23
|
-
{
|
24
|
-
view: 'label',
|
25
|
-
text: message
|
26
|
-
},
|
27
|
-
].concat(bottom_views),
|
28
|
-
padding: {
|
29
|
-
x: 20,
|
30
|
-
y: 22,
|
31
|
-
},
|
32
|
-
}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
14
|
def json_ui_401_response(sign_in_url)
|
37
15
|
{
|
38
16
|
# Handle dialogs_open and windows_open
|
@@ -178,7 +178,7 @@ module Glib::Json::Libs
|
|
178
178
|
# end
|
179
179
|
# end
|
180
180
|
|
181
|
-
def __glib_error_dialog(title, message)
|
181
|
+
def __glib_error_dialog(title, message, bottom_views = [])
|
182
182
|
{
|
183
183
|
action: 'dialogs/show',
|
184
184
|
# Don't show another dialog, just use the current one since it's a new dialog anyway, which means
|
@@ -188,14 +188,21 @@ module Glib::Json::Libs
|
|
188
188
|
body: {
|
189
189
|
childViews: [
|
190
190
|
{
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
191
|
+
view: 'panels/vertical',
|
192
|
+
styleClasses: ['glib-error-dialog'],
|
193
|
+
childViews: [
|
194
|
+
{
|
195
|
+
view: 'label',
|
196
|
+
text: message
|
197
|
+
},
|
198
|
+
].concat(bottom_views),
|
199
|
+
}
|
200
|
+
]
|
201
|
+
# Set this in the project's custom CSS.
|
202
|
+
# padding: {
|
203
|
+
# x: 20,
|
204
|
+
# y: 22,
|
205
|
+
# },
|
199
206
|
}
|
200
207
|
}
|
201
208
|
end
|
@@ -310,7 +317,23 @@ module Glib::Json::Libs
|
|
310
317
|
format.json do
|
311
318
|
render json: {
|
312
319
|
glib_json_dialog_mode? ? :onLoad : :onResponse => __glib_error_dialog(
|
313
|
-
'Your session has expired', 'Please refresh the page and retry.'
|
320
|
+
'Your session has expired', 'Please refresh the page and retry.', [
|
321
|
+
{
|
322
|
+
view: 'button',
|
323
|
+
text: 'Refresh',
|
324
|
+
onClick: {
|
325
|
+
action: 'dialogs/close',
|
326
|
+
onClose: {
|
327
|
+
action: 'windows/reload',
|
328
|
+
onReload: {
|
329
|
+
action: 'snackbars/alert',
|
330
|
+
message: 'Refreshed. You can try again now.'
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
},
|
335
|
+
]
|
336
|
+
)
|
314
337
|
}
|
315
338
|
end
|
316
339
|
end
|
@@ -37,6 +37,11 @@ class Glib::JsonUi::ActionBuilder
|
|
37
37
|
required :url
|
38
38
|
end
|
39
39
|
|
40
|
+
class CloseAllWithOpen < Action
|
41
|
+
string :url
|
42
|
+
action :onOpen
|
43
|
+
end
|
44
|
+
|
40
45
|
# Any component can listen to the refresh_state event and react appropriately.
|
41
46
|
# E.g. Stripe credit card component can refresh its token to make sure it is not stale.
|
42
47
|
class RefreshState < Action
|
@@ -107,6 +107,8 @@ module Glib
|
|
107
107
|
json.url options[:url]
|
108
108
|
json.inputName options[:inputName]
|
109
109
|
json.strategy options[:strategy]
|
110
|
+
json.storagePrefix options[:storagePrefix]
|
111
|
+
json.metadata options[:metadata]
|
110
112
|
end
|
111
113
|
end
|
112
114
|
|
@@ -235,7 +237,7 @@ module Glib
|
|
235
237
|
def form(options = {})
|
236
238
|
form = Glib::JsonUi::ViewBuilder::Panels::Form.new(json, self)
|
237
239
|
form.childViews(->(view_builder) { })
|
238
|
-
panel_options = options.slice!(:url, :method, :local, :onSubmit, :paramNameForFormData, :model)
|
240
|
+
panel_options = options.slice!(:url, :method, :local, :onSubmit, :paramNameForFormData, :model, :onChange)
|
239
241
|
|
240
242
|
json.fullPageForm do
|
241
243
|
json.view 'panels/fullPageForm'
|
@@ -289,6 +289,8 @@ class Glib::JsonUi::ViewBuilder
|
|
289
289
|
string :uploadIcon # deprecated
|
290
290
|
hash :placeholderView
|
291
291
|
hash :infoSpec
|
292
|
+
string :storagePrefix
|
293
|
+
hash :metadata
|
292
294
|
|
293
295
|
def buttonLabels(obj)
|
294
296
|
@buttonLabels = ActiveSupport::HashWithIndifferentAccess.new(obj)
|
@@ -334,6 +336,9 @@ class Glib::JsonUi::ViewBuilder
|
|
334
336
|
string :strategy # can be "delegate" or "dropUpload"
|
335
337
|
string :url # http post end point if you don't want to use onFinishUpload
|
336
338
|
|
339
|
+
string :storagePrefix
|
340
|
+
hash :metadata
|
341
|
+
|
337
342
|
required :accepts, :directUploadUrl
|
338
343
|
|
339
344
|
# deprecated
|
@@ -391,6 +396,17 @@ class Glib::JsonUi::ViewBuilder
|
|
391
396
|
end
|
392
397
|
end
|
393
398
|
|
399
|
+
class Sign < AbstractField
|
400
|
+
string :directUploadUrl
|
401
|
+
|
402
|
+
required :directUploadUrl
|
403
|
+
|
404
|
+
# Override
|
405
|
+
# Signature field doesn't have default value
|
406
|
+
def value(value)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
394
410
|
# TODO
|
395
411
|
# class MultiImage < Text
|
396
412
|
# # file_rules = { fileType: 'image/*', maxFileSize: 5000 }
|
@@ -66,6 +66,15 @@ section.rows builder: ->(template) do
|
|
66
66
|
action.dialogs_open fullscreen: 'mobile', url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog')
|
67
67
|
end
|
68
68
|
|
69
|
+
template.thumbnail title: 'dialogs/reload (without url)', onClick: ->(action) do
|
70
|
+
action.runMultiple childActions: ->(saction) do
|
71
|
+
saction.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
|
72
|
+
saction.timeouts_set interval: 1000, onTimeout: ->(ssaction) do
|
73
|
+
ssaction.dialogs_reload
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
69
78
|
if !Rails.env.test? # Prevent test failure
|
70
79
|
template.thumbnail title: 'dialogs/open (page with error)', onClick: ->(action) do
|
71
80
|
action.dialogs_open url: json_ui_garage_url(path: 'forms/non_existent', mode: 'dialog')
|
@@ -96,6 +105,16 @@ section.rows builder: ->(template) do
|
|
96
105
|
action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
|
97
106
|
end
|
98
107
|
|
108
|
+
template.thumbnail title: 'dialogs/closeAll', onClick: ->(action) do
|
109
|
+
action.runMultiple childActions: ->(saction) do
|
110
|
+
saction.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
|
111
|
+
saction.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
|
112
|
+
saction.timeouts_set interval: 1000, onTimeout: ->(ssaction) do
|
113
|
+
ssaction.dialogs_closeAll
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
99
118
|
template.thumbnail title: 'dialogs/oauth', onClick: ->(action) do
|
100
119
|
if respond_to?(:user_facebook_omniauth_authorize_url)
|
101
120
|
provider = {
|
@@ -14,6 +14,11 @@ section.rows builder: ->(template) do
|
|
14
14
|
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
15
15
|
end
|
16
16
|
|
17
|
+
template.thumbnail title: 'windows/closeAllWithOpen', onClick: ->(action) do
|
18
|
+
action.windows_closeAllWithOpen url: json_ui_garage_url(path: 'home/index')
|
19
|
+
|
20
|
+
end
|
21
|
+
|
17
22
|
template.thumbnail title: 'windows/openWeb', onClick: ->(action) do
|
18
23
|
action.windows_openWeb url: 'http://www.google.com'
|
19
24
|
end
|
@@ -46,6 +46,11 @@ page.form options.merge(childViews: ->(form) do
|
|
46
46
|
directUploadUrl: rails_direct_uploads_url,
|
47
47
|
uploadTitle: 'Files uploaded:',
|
48
48
|
uploadFailedText: '(UPLOAD FAILED)',
|
49
|
+
storagePrefix: 'glib',
|
50
|
+
metadata: {
|
51
|
+
foo: 'bar',
|
52
|
+
zoo: 'baz'
|
53
|
+
},
|
49
54
|
files: [
|
50
55
|
{ name: 'File (Example)', signed_id: ActiveStorage::Attachment.last&.signed_id }
|
51
56
|
]
|
@@ -61,5 +66,13 @@ page.form options.merge(childViews: ->(form) do
|
|
61
66
|
uploadFailedText: '(UPLOAD FAILED)',
|
62
67
|
onFinishUpload: ->(action) { action.forms_submit }
|
63
68
|
form.spacer height: 16
|
69
|
+
form.label text: 'Sign'
|
70
|
+
form.spacer height: 8
|
71
|
+
form.fields_sign \
|
72
|
+
name: 'user[sign]',
|
73
|
+
directUploadUrl: rails_direct_uploads_url,
|
74
|
+
width: 300, height: 150,
|
75
|
+
validation: { required: { message: 'add your signature!' } }
|
76
|
+
form.spacer height: 24
|
64
77
|
form.fields_submit text: 'Submit'
|
65
78
|
end)
|
data/lib/glib/blob.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
::ActiveStorage::Blob.class_eval do
|
2
|
+
def service_headers_for_direct_upload
|
3
|
+
service.headers_for_direct_upload key, filename: filename, content_type: content_type, content_length: byte_size, checksum: checksum
|
4
|
+
end
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def create_before_direct_upload!(key: nil, filename:, byte_size:, checksum:, content_type: nil, metadata: nil, service_name: nil, record: nil, prefix: nil)
|
8
|
+
key_name = key || generate_unique_secure_token
|
9
|
+
if prefix.present?
|
10
|
+
key_name = "#{prefix}/#{key_name}"
|
11
|
+
end
|
12
|
+
create! key: key_name, filename: filename, byte_size: byte_size, checksum: checksum, content_type: content_type, metadata: metadata, service_name: service_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,7 +2,10 @@
|
|
2
2
|
# include Rails.application.routes.url_helpers
|
3
3
|
before_action :authenticate_user!
|
4
4
|
|
5
|
-
rescue_from StandardError do
|
5
|
+
rescue_from StandardError do |e|
|
6
|
+
if !Rails.env.production?
|
7
|
+
raise e
|
8
|
+
end
|
6
9
|
render json: { message: 'Upload failed' }, status: 500
|
7
10
|
end
|
8
11
|
|
@@ -14,11 +17,16 @@
|
|
14
17
|
render json: { message: 'Session expired. Please refresh page' }, status: 401
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
private
|
21
|
+
def blob_args
|
22
|
+
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, :prefix, metadata: {}).to_h.symbolize_keys
|
23
|
+
end
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
def authenticate_user!
|
26
|
+
current_user.present? ? nil : raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
def raise_error
|
30
|
+
raise Glib::Auth::Policy::UnauthorizedError
|
31
|
+
end
|
24
32
|
end
|
data/lib/glib/engine.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glib-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -307,6 +307,7 @@ files:
|
|
307
307
|
- lib/generators/templates/database.yml
|
308
308
|
- lib/generators/templates/dynamic_text.rb
|
309
309
|
- lib/glib-web.rb
|
310
|
+
- lib/glib/blob.rb
|
310
311
|
- lib/glib/crypt/utils.rb
|
311
312
|
- lib/glib/direct_uploads_controller.rb
|
312
313
|
- lib/glib/dynamic_text.rb
|