glib-web 0.5.16 → 0.5.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/concerns/glib/analytics/funnel.rb +60 -0
- data/app/controllers/concerns/glib/json/libs.rb +4 -4
- data/app/controllers/concerns/glib/json/traversal.rb +1 -0
- data/app/controllers/concerns/glib/json/ui.rb +16 -8
- data/app/controllers/glib/home_controller.rb +0 -0
- data/app/helpers/glib/json_ui/action_builder.rb +12 -0
- data/app/helpers/glib/json_ui/menu_builder.rb +48 -6
- data/app/helpers/glib/json_ui/page_helper.rb +21 -0
- data/app/helpers/glib/json_ui/response_helper.rb +0 -0
- data/app/helpers/glib/json_ui/view_builder.rb +36 -19
- data/app/helpers/glib/json_ui/view_builder/fields.rb +2 -0
- data/app/helpers/glib/json_ui/view_builder/panels.rb +1 -1
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +0 -1
- data/app/views/json_ui/garage/actions/_http.json.jbuilder +9 -3
- data/app/views/json_ui/garage/actions/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/basic.json.jbuilder +2 -14
- data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +31 -16
- data/app/views/json_ui/garage/forms/pickers.json.jbuilder +0 -0
- data/app/views/json_ui/garage/home/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/chat_ui.json.jbuilder +112 -0
- data/app/views/json_ui/garage/lists/index.json.jbuilder +2 -2
- data/app/views/json_ui/garage/notifications/android_post.json.jbuilder +48 -0
- data/app/views/json_ui/garage/notifications/index.json.jbuilder +14 -0
- data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +4 -16
- data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +6 -2
- data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +2 -0
- data/app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder +13 -2
- data/app/views/json_ui/garage/tables/index.json.jbuilder +19 -20
- data/app/views/json_ui/garage/tables/layout.json.jbuilder +26 -28
- data/app/views/json_ui/garage/views/banners.json.jbuilder +18 -6
- data/app/views/json_ui/garage/views/icons.json.jbuilder +1439 -11
- data/app/views/json_ui/garage/views/index.json.jbuilder +6 -3
- data/app/views/layouts/json_ui/renderer.html.erb +7 -4
- metadata +5 -3
- data/app/views/json_ui/garage/lists/chat.json.jbuilder +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d40fabbd2b44ff3a4c13a7095ea2f19b6b560de5d0c5d6a58616c94d000df1a
|
4
|
+
data.tar.gz: 1c4b8787db5d9fa131b18346e6b4d201b6c9b279f5a5e58d5debf6c4024475c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d75eca6f60a6cfe859d529216300a16987fde43fc4960df8a1923080c0142be524f21e0ddf32e6f3c66182fa0c12d9f6d8f85bd65d2671ad34e921dd02c89f9
|
7
|
+
data.tar.gz: 1c0225f8bd8979c62e74e69941b033afc98067c93e1a699d4402a347c9e7f7bb3076df798d88fd79d02216da6c067112950249cd1b0d0740c23b895911cdf143
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Glib::Analytics
|
2
|
+
module Funnel
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# include Overrides
|
7
|
+
extend ClassMethods
|
8
|
+
|
9
|
+
helper_method :glib_analytics_feature_segment
|
10
|
+
helper_method :glib_analytics_feature_referer
|
11
|
+
end
|
12
|
+
|
13
|
+
# module Overrides
|
14
|
+
|
15
|
+
# # Expose protected method
|
16
|
+
# public # Override
|
17
|
+
# def policy_scope(*args)
|
18
|
+
# super
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
|
22
|
+
def glib_analytics_included?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def glib_analytics_feature_segment
|
27
|
+
# To be overridden
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def glib_analytics_feature_referer
|
32
|
+
group = request.headers['GApp-Analytics-Referer-Group']
|
33
|
+
action = request.headers['GApp-Analytics-Referer-Action']
|
34
|
+
segment = request.headers['GApp-Analytics-Referer-Segment']
|
35
|
+
placement = request.headers['GApp-Analytics-Referer-Placement']
|
36
|
+
|
37
|
+
if group && action
|
38
|
+
return { group: group, action: action, segment: segment, placement: placement }
|
39
|
+
end
|
40
|
+
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
module ClassMethods
|
47
|
+
# def glib_auth_inited?
|
48
|
+
# @@__glib_auth_init ||= false
|
49
|
+
# end
|
50
|
+
|
51
|
+
# def glib_analytics_init
|
52
|
+
# @@__glib_analytics_init = true
|
53
|
+
# end
|
54
|
+
|
55
|
+
# def glib_analytics_inited?
|
56
|
+
# @@__glib_analytics_init ||= false
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -9,17 +9,17 @@ module Glib::Json::Libs
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def json_ui_app_bundle_id
|
12
|
-
@json_ui_app_bundle_id ||= request.headers['JsonUiApp-Bundle-Id']
|
12
|
+
@json_ui_app_bundle_id ||= request.headers['GApp-Bundle-Id'] || request.headers['JsonUiApp-Bundle-Id']
|
13
13
|
end
|
14
14
|
|
15
15
|
def json_ui_app_build_version
|
16
|
-
@json_ui_app_build_version ||= request.headers['JsonUiApp-Build-Version']
|
16
|
+
@json_ui_app_build_version ||= request.headers['GApp-Build-Version'] || request.headers['JsonUiApp-Build-Version']
|
17
17
|
@json_ui_app_build_version = params[:build_version] if @json_ui_app_build_version.nil? && Rails.env.development? # For easy testing
|
18
18
|
@json_ui_app_build_version
|
19
19
|
end
|
20
20
|
|
21
21
|
def json_ui_app_device_os
|
22
|
-
@json_ui_app_device_os ||= request.headers['JsonUiApp-Device-Os']
|
22
|
+
@json_ui_app_device_os ||= request.headers['GApp-Device-Os'] || request.headers['JsonUiApp-Device-Os']
|
23
23
|
@json_ui_app_device_os = params[:device_os] if @json_ui_app_device_os.nil? && Rails.env.development? # For easy testing
|
24
24
|
@json_ui_app_device_os || 'web'
|
25
25
|
end
|
@@ -59,7 +59,7 @@ module Glib::Json::Libs
|
|
59
59
|
# raise exception
|
60
60
|
# end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def glib_json_handle_500(exception)
|
64
64
|
if json_ui_activated? && Rails.env.production?
|
65
65
|
Rollbar.error(exception) if defined?(Rollbar)
|
@@ -38,6 +38,17 @@ module Glib::Json::Ui
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def json_ui_response_lifecycle_prop
|
42
|
+
prop_name = 'onResponse'
|
43
|
+
if (hash = json_transformation_start).is_a?(Hash) && hash[prop_name] # A valid response
|
44
|
+
if hash[prop_name]['action'] != 'runMultiple'
|
45
|
+
childActions = [hash[prop_name]]
|
46
|
+
hash[prop_name] = { 'action' => 'runMultiple', 'childActions' => childActions }
|
47
|
+
childActions
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
41
52
|
def __json_ui_start(options)
|
42
53
|
@__json_ui_activated = false
|
43
54
|
@__json_ui_rendering = nil
|
@@ -66,12 +77,9 @@ module Glib::Json::Ui
|
|
66
77
|
end
|
67
78
|
|
68
79
|
private
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
# response.body = render_to_string(template: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
|
76
|
-
end
|
80
|
+
def __json_ui_vue(hash, options)
|
81
|
+
renderer_path = options[:renderer_path]
|
82
|
+
@__json_ui_orig_page = response.body
|
83
|
+
response.body = render_to_string(template: renderer_path, layout: 'json_ui/renderer', content_type: 'text/html', locals: { page: hash, options: options })
|
84
|
+
end
|
77
85
|
end
|
File without changes
|
@@ -16,6 +16,7 @@ module Glib
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Action < JsonUiElement
|
19
|
+
# TODO: Deprecated
|
19
20
|
def analytics(value)
|
20
21
|
if value.is_a?(String)
|
21
22
|
@analyticsEnabled = true
|
@@ -27,6 +28,7 @@ module Glib
|
|
27
28
|
|
28
29
|
# Override
|
29
30
|
def created
|
31
|
+
# TODO: Deprecated
|
30
32
|
if @analyticsEnabled
|
31
33
|
suffix = @analyticsId
|
32
34
|
# TODO: recognize_path() needs `method` as a second argument for POST request
|
@@ -71,6 +73,16 @@ module Glib
|
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
76
|
+
module Devices
|
77
|
+
class GetPushToken < Action
|
78
|
+
string :postUrl
|
79
|
+
string :paramNameForToken
|
80
|
+
|
81
|
+
# Use postUrl instead
|
82
|
+
# action :onGet
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
74
86
|
module Analytics
|
75
87
|
class LogEvent < Action
|
76
88
|
string :name
|
@@ -6,6 +6,36 @@ module Glib
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class MenuItem < JsonUiElement
|
9
|
+
hash :analytics
|
10
|
+
|
11
|
+
# def initialize(json, page)
|
12
|
+
# super(json, page)
|
13
|
+
|
14
|
+
# # Can be improved by making it configurable site-wide.
|
15
|
+
# @analyticsEnabled = true
|
16
|
+
# end
|
17
|
+
|
18
|
+
# def analytics(value)
|
19
|
+
# if value.is_a?(Hash)
|
20
|
+
# @analyticsEnabled = true
|
21
|
+
# @analyticsId = value
|
22
|
+
# else
|
23
|
+
# @analyticsEnabled = value == true
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
# # Override
|
28
|
+
# def created
|
29
|
+
# json.analytics do
|
30
|
+
# if @analyticsEnabled
|
31
|
+
# if @analyticsId
|
32
|
+
# json.placement @analyticsId
|
33
|
+
# end
|
34
|
+
# else
|
35
|
+
# json.disabled true
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# end
|
9
39
|
end
|
10
40
|
|
11
41
|
class Button < MenuItem
|
@@ -15,13 +45,16 @@ module Glib
|
|
15
45
|
bool :disabled
|
16
46
|
singleton_array :styleClass, :styleClasses
|
17
47
|
|
18
|
-
def
|
19
|
-
json.
|
48
|
+
def childButtons(block)
|
49
|
+
json.childButtons do
|
20
50
|
block.call page.menu_builder
|
21
51
|
end
|
22
52
|
end
|
23
53
|
|
54
|
+
# Override
|
24
55
|
def created
|
56
|
+
super
|
57
|
+
|
25
58
|
json.type 'button'
|
26
59
|
end
|
27
60
|
end
|
@@ -29,6 +62,8 @@ module Glib
|
|
29
62
|
class Divider < MenuItem
|
30
63
|
# Override
|
31
64
|
def created
|
65
|
+
super
|
66
|
+
|
32
67
|
json.type 'divider'
|
33
68
|
end
|
34
69
|
end
|
@@ -39,14 +74,21 @@ module Glib
|
|
39
74
|
|
40
75
|
# Override
|
41
76
|
def created
|
77
|
+
super
|
78
|
+
|
42
79
|
json.type 'label'
|
43
80
|
end
|
44
81
|
end
|
45
82
|
|
46
|
-
class MenuLeftBottom < Button
|
47
|
-
|
48
|
-
|
49
|
-
end
|
83
|
+
# class MenuLeftBottom < Button
|
84
|
+
# icon :icon
|
85
|
+
# array :buttons
|
86
|
+
# end
|
87
|
+
|
88
|
+
# class Select < Button
|
89
|
+
# icon :icon
|
90
|
+
# array :buttons
|
91
|
+
# end
|
50
92
|
end
|
51
93
|
end
|
52
94
|
end
|
@@ -10,9 +10,24 @@ module Glib
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
|
+
def json_ui_garage_current_url(options = {})
|
14
|
+
json_ui_garage_url(options.merge(path: params[:path]))
|
15
|
+
end
|
16
|
+
|
13
17
|
# TODO: Remove the block
|
14
18
|
def json_ui_page(json, &block)
|
15
19
|
@__json_ui_page ||= Page.new(json, self)
|
20
|
+
|
21
|
+
if try(:glib_analytics_included?)
|
22
|
+
json.analytics do
|
23
|
+
json.feature do
|
24
|
+
json.group controller_name
|
25
|
+
json.action action_name
|
26
|
+
json.segment glib_analytics_feature_segment
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
16
31
|
block&.call @__json_ui_page
|
17
32
|
@__json_ui_page
|
18
33
|
end
|
@@ -45,6 +60,12 @@ module Glib
|
|
45
60
|
@__json_ui_section.action_builder
|
46
61
|
end
|
47
62
|
|
63
|
+
def json_ui_action_payload(&block)
|
64
|
+
dataJson = Jbuilder.new
|
65
|
+
block&.call Page.new(dataJson, self).action_builder
|
66
|
+
dataJson.attributes!
|
67
|
+
end
|
68
|
+
|
48
69
|
class Page
|
49
70
|
attr_reader :json, :context, :view_builder, :action_builder, :menu_builder
|
50
71
|
attr_reader :list_section_builder, :table_section_builder, :drawer_content_builder, :split_content_builder
|
File without changes
|
@@ -28,29 +28,46 @@ module Glib
|
|
28
28
|
length :height
|
29
29
|
color :backgroundColor
|
30
30
|
hash :padding
|
31
|
-
# array :styleClasses
|
32
31
|
singleton_array :styleClass, :styleClasses
|
33
32
|
hash :showIf
|
33
|
+
hash :analytics
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
@analyticsEnabled = true
|
38
|
-
@analyticsId = value
|
39
|
-
else
|
40
|
-
@analyticsEnabled = value == true
|
41
|
-
end
|
42
|
-
end
|
35
|
+
# def initialize(json, page)
|
36
|
+
# super(json, page)
|
43
37
|
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
38
|
+
# # Can be improved by making it configurable site-wide.
|
39
|
+
# @analyticsEnabled = true
|
40
|
+
# end
|
41
|
+
|
42
|
+
# def analytics(value)
|
43
|
+
# if value.is_a?(String)
|
44
|
+
# @analyticsEnabled = true
|
45
|
+
# @analyticsId = value
|
46
|
+
# else
|
47
|
+
# @analyticsEnabled = value == true
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
|
51
|
+
# # Override
|
52
|
+
# def created
|
53
|
+
# # if @analyticsEnabled
|
54
|
+
# # context = page.context
|
55
|
+
# # json.analytics do
|
56
|
+
# # content = @analyticsId || (@text || @icon)&.gsub(/\s+/, '_')&.downcase || 'nil'
|
57
|
+
# # json.namePrefix [context.controller_name, context.action_name, content].join('_')
|
58
|
+
# # end
|
59
|
+
# # end
|
60
|
+
|
61
|
+
# json.analytics do
|
62
|
+
# if @analyticsEnabled
|
63
|
+
# if @analyticsId
|
64
|
+
# json.placement @analyticsId
|
65
|
+
# end
|
66
|
+
# else
|
67
|
+
# json.disabled true
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
# end
|
54
71
|
|
55
72
|
end
|
56
73
|
|
@@ -95,6 +95,7 @@ class Glib::JsonUi::ViewBuilder
|
|
95
95
|
# - It has a default onClick so no need to specify `onClick: ->(action) { action.forms_submit }`
|
96
96
|
class Submit < AbstractField
|
97
97
|
string :text
|
98
|
+
color :color
|
98
99
|
end
|
99
100
|
|
100
101
|
class CheckGroup < AbstractField
|
@@ -157,6 +158,7 @@ class Glib::JsonUi::ViewBuilder
|
|
157
158
|
class DynamicGroup < AbstractField
|
158
159
|
string :titlePrefix
|
159
160
|
panels_builder :content, :template
|
161
|
+
hash :groupFieldProperties
|
160
162
|
|
161
163
|
# NOTE: Consider using sub-panel instead (e.g. groupTemplate)
|
162
164
|
# views :groupTemplateViews
|
@@ -89,7 +89,6 @@ class Glib::JsonUi::ViewBuilder
|
|
89
89
|
@childViewsBlock.call(page.view_builder)
|
90
90
|
page.current_form = nil
|
91
91
|
end
|
92
|
-
|
93
92
|
end
|
94
93
|
|
95
94
|
def childViews(block)
|
@@ -98,6 +97,7 @@ class Glib::JsonUi::ViewBuilder
|
|
98
97
|
end
|
99
98
|
|
100
99
|
class List < View
|
100
|
+
hash :ws
|
101
101
|
hash :nextPage
|
102
102
|
action :onScrollToTop
|
103
103
|
action :onScrollToBottom
|
@@ -5,14 +5,20 @@ end
|
|
5
5
|
|
6
6
|
section.rows builder: ->(template) do
|
7
7
|
template.thumbnail title: 'http/post', onClick: ->(action) do
|
8
|
-
action.
|
8
|
+
action.auth_saveCsrfToken token: form_authenticity_token, onSave: ->(subaction) do
|
9
|
+
subaction.http_post url: json_ui_garage_url(path: 'forms/basic_post'), formData: { 'user[name]' => 'New Joe' }
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
template.thumbnail title: 'http/patch', onClick: ->(action) do
|
12
|
-
action.
|
14
|
+
action.auth_saveCsrfToken token: form_authenticity_token, onSave: ->(subaction) do
|
15
|
+
subaction.http_patch url: json_ui_garage_url(path: 'forms/basic_post'), formData: { 'user[name]' => 'Edit Joe' }
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
template.thumbnail title: 'http/delete', onClick: ->(action) do
|
16
|
-
action.
|
20
|
+
action.auth_saveCsrfToken token: form_authenticity_token, onSave: ->(subaction) do
|
21
|
+
subaction.http_delete url: json_ui_garage_url(path: 'forms/basic_post'), formData: { 'user[name]' => 'Delete Joe' }
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
File without changes
|