glib-web 0.5.18 → 0.5.19

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: 481c51fde9d25ee4f8b4470c126f26c957c04209acdb37b1a52db6faecba9f4e
4
- data.tar.gz: d2258e2069c804b9ad232bb157c657260352bdf3eabab1342562040f165c1ffa
3
+ metadata.gz: 97f06c521e0f5efa16bf64c4ba849e86a0c5747899e32880dc596d443b2def46
4
+ data.tar.gz: 24ffcd3e25128ba56c8e12f34f5b51a7f1669119c3e70d177e389390d3186462
5
5
  SHA512:
6
- metadata.gz: cc9c9bb53e07b9ef3031167aa3f72d901e2b07098ee4a90f285969c2fc1ee548d966c2947a165fd3c519f8d0cbad13cebc3c7e70498d90cbdc4db220c3a4ad92
7
- data.tar.gz: 9b5fc5e2d30f03fe433425f3d4594eb0acfb3bb48774a73e161feae7bca2ea87cae450a291a32a29fd1b4acfcfdf057752be9e0c04386b570bb59ea925a24fec
6
+ metadata.gz: 383c668d259de6923c5ea2f5792644a52ff2d25d240f950f5b5bc553be180b425a86d93c5a95783c84c54cda02aef15c3d97239ccc80d72ab1fb3bdfdd8c51ed
7
+ data.tar.gz: c8ccd39d3062284afda5443766c9d42955bdbf120d127bb51b289da78d3c7cde49bc0bcba1b8dfb10b6473082f67c59b192818d991884e01d74b076394530d77
@@ -66,12 +66,9 @@ module Glib::Json::Ui
66
66
  end
67
67
 
68
68
  private
69
-
70
- def __json_ui_vue(hash, options)
71
- renderer_path = options[:renderer_path]
72
- @__json_ui_orig_page = response.body
73
- response.body = render_to_string(template: renderer_path, layout: 'json_ui/renderer', content_type: 'text/html', locals: { page: hash, options: options })
74
-
75
- # response.body = render_to_string(template: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
76
- end
69
+ def __json_ui_vue(hash, options)
70
+ renderer_path = options[:renderer_path]
71
+ @__json_ui_orig_page = response.body
72
+ response.body = render_to_string(template: renderer_path, layout: 'json_ui/renderer', content_type: 'text/html', locals: { page: hash, options: options })
73
+ end
77
74
  end
File without changes
@@ -73,8 +73,11 @@ module Glib
73
73
 
74
74
  module Devices
75
75
  class GetPushToken < Action
76
- action :onGet
76
+ string :postUrl
77
77
  string :paramNameForToken
78
+
79
+ # Use postUrl instead
80
+ # action :onGet
78
81
  end
79
82
  end
80
83
 
@@ -15,8 +15,8 @@ module Glib
15
15
  bool :disabled
16
16
  singleton_array :styleClass, :styleClasses
17
17
 
18
- def childItems(block)
19
- json.childItems do
18
+ def childButtons(block)
19
+ json.childButtons do
20
20
  block.call page.menu_builder
21
21
  end
22
22
  end
@@ -43,10 +43,15 @@ module Glib
43
43
  end
44
44
  end
45
45
 
46
- class MenuLeftBottom < Button
47
- icon :icon
48
- array :buttons
49
- end
46
+ # class MenuLeftBottom < Button
47
+ # icon :icon
48
+ # array :buttons
49
+ # end
50
+
51
+ # class Select < Button
52
+ # icon :icon
53
+ # array :buttons
54
+ # end
50
55
  end
51
56
  end
52
57
  end
@@ -10,6 +10,10 @@ 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)
@@ -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
@@ -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
@@ -7,14 +7,6 @@ json_ui_page json do |page|
7
7
  form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
8
8
  form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
9
9
 
10
- # form.panels_split width: 'matchParent', leftViews: ->(split) do
11
- # if params[:mode] == 'dialog'
12
- # split.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
13
- # end
14
- # end, rightViews: ->(split) do
15
- # split.button text: 'Submit', onClick: ->(action) { action.forms_submit }
16
- # end
17
-
18
10
  form.panels_split width: 'matchParent', content: ->(split) do
19
11
  split.left childViews: ->(left) do
20
12
  if params[:mode] == 'dialog'
@@ -22,13 +14,9 @@ json_ui_page json do |page|
22
14
  end
23
15
  end
24
16
  split.right childViews: ->(right) do
25
- right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
17
+ # right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
18
+ right.fields_submit text: 'Submit'
26
19
  end
27
20
  end
28
-
29
21
  end
30
- # , paramNameForFormData: 'formData', onSubmit: ->(action) do
31
- # action.http_post url: json_ui_garage_url(path: 'forms/generic_post')
32
- # end
33
-
34
22
  end
@@ -5,7 +5,26 @@ liked = params[:liked] == 'true'
5
5
  page = json_ui_page json
6
6
  render "#{@path_prefix}/nav_menu", json: json, page: page
7
7
 
8
- page.list firstSection: ->(section) do
8
+ json.ws({
9
+ "socket" => {
10
+ "endpoint" => "/socket/websocket",
11
+ "params" => {
12
+ vsn: '2.0.0',
13
+ token: 'TOKEN'
14
+ }
15
+ },
16
+ "topic" => "rooms",
17
+ "events" => [],
18
+ # "events" => ["new_link_added"],
19
+ # "header" => {
20
+ # "user_id" => 2,
21
+ # "prev_item_id" => nil,
22
+ # "last_item_id" => nil
23
+ # }
24
+ })
25
+
26
+ list_ws = { topic: 'rooms', events: ['comments_updated'] }
27
+ page.list ws: list_ws, firstSection: ->(section) do
9
28
  section.header padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: ->(header) do
10
29
  header.h3 text: 'Chat with John Doe'
11
30
  end
@@ -73,18 +92,15 @@ page.footer padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: -
73
92
 
74
93
  footer.panels_form width: 'matchParent', url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, paramNameForFormData: 'formData', onSubmit: ->(action) do
75
94
  json.action "ws/push"
76
- json.topic "links"
77
- json.event "new_link"
95
+ json.topic "rooms"
96
+ json.event "create_comment"
78
97
  json.payload({
79
- "club_id": "2",
80
98
  "room_id": "30",
81
99
  "user_id": "2"
82
- # title: "TITLE",
83
- # url: "URL"
84
100
  })
85
101
 
86
102
  end, childViews: ->(form) do
87
- form.fields_text name: 'message[body]', width: 'matchParent', label: 'Message'
103
+ form.fields_text name: 'user[message]', width: 'matchParent', label: 'Message'
88
104
 
89
105
  form.panels_split width: 'matchParent', content: ->(split) do
90
106
  split.right childViews: ->(right) do
@@ -1,54 +1,46 @@
1
- if (server_key = ENV['GCM_SERVER_KEY'])
2
- fcm = FCM.new(server_key)
3
1
 
4
- # you can set option parameters in here
5
- # - all options are pass to HTTParty method arguments
6
- # - ref: https://github.com/jnunemaker/httparty/blob/master/lib/httparty.rb#L29-L60
7
- # fcm = FCM.new("my_server_key", timeout: 3)
8
-
9
- registration_ids = [params[:token]] # an array of one or more client registration tokens
10
-
11
-
12
-
13
- # # dataJson = Jbuilder.new
14
- # data = json_ui_response nil do |action|
15
- # action.snackbars_alert message: 'TEST'
16
- # end
17
- # # data = dataJson.attributes!
18
-
19
-
20
- # action = json_ui_action nil do |action|
21
- # action.snackbars_alert message: 'TEST'
22
- # end
23
-
24
- payload = json_ui_action_payload do |action|
25
- action.snackbars_alert message: 'TEST'
26
- end
27
-
28
- puts "D: #{payload}"
29
-
30
- # See https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages for all available options.
31
- options = {
32
- notification: {
33
- title: params[:title],
34
- body: "Message from server"
35
- },
36
- data: {
37
- channelId: 'default',
38
- notificationId: 1,
39
- onClick: payload
2
+ if (server_key = ENV['FCM_SERVER_KEY'])
3
+ if defined? FCM
4
+ # Introduce delay so that we have time to place the app to background
5
+ # before receiving push notification.
6
+ sleep 2
7
+
8
+ fcm = FCM.new(server_key)
9
+ registration_ids = [params[:token]] # An array of one or more client registration tokens
10
+
11
+ payload = json_ui_action_payload do |action|
12
+ action.dialogs_alert message: 'Opened'
13
+ end
14
+
15
+ # See https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages for all available options.
16
+ options = {
17
+ notification: {
18
+ title: params[:title],
19
+ body: 'Message from server'
20
+ # title: 'Offer from Ajisen Ramen',
21
+ # body: 'Free side order of Gyoza'
22
+ },
23
+ data: {
24
+ channelId: 'default',
25
+ notificationId: 1,
26
+ openUrl: json_ui_garage_url(path: 'home/blank'),
27
+ onOpen: payload
28
+ # openUrl: 'http://10.0.2.2:3000/offers.json?_render=v1',
29
+ }
40
30
  }
41
- }
42
- response = fcm.send(registration_ids, options)
43
-
44
- body = JSON.parse(response[:body])
45
- if (errors = body['results'].map { |i| i['error'] }.compact).any?
46
- message = errors.join(', ')
31
+ response = fcm.send(registration_ids, options)
32
+
33
+ body = JSON.parse(response[:body])
34
+ if (errors = body['results'].map { |i| i['error'] }.compact).any?
35
+ message = errors.join(', ')
36
+ else
37
+ message = 'Sent'
38
+ end
47
39
  else
48
- message = 'Sent'
40
+ message = 'FCM gem needed'
49
41
  end
50
42
  else
51
- message = 'Need to set env var: GCM_SERVER_KEY'
43
+ message = 'Env var needed: GCM_SERVER_KEY'
52
44
  end
53
45
 
54
46
  json_ui_response json do |action|
@@ -13,12 +13,15 @@ page.list firstSection: ->(section) do
13
13
 
14
14
  template.thumbnail title: 'Send Android Notification', onClick: ->(action) do
15
15
  action.auth_saveCsrfToken token: form_authenticity_token, onSave: ->(subaction) do
16
- subaction.devices_getPushToken paramNameForToken: 'formData[token]', onGet: ->(subsubaction) do
17
- formData = {
18
- title: 'Title from formData'
19
- }
20
- subsubaction.http_post url: json_ui_garage_url(path: 'notifications/android_post'), formData: formData
21
- end
16
+ # subaction.devices_getPushToken paramNameForToken: 'formData[token]', onGet: ->(subsubaction) do
17
+ # formData = {
18
+ # title: 'Title from formData'
19
+ # }
20
+ # subsubaction.http_post url: json_ui_garage_url(path: 'notifications/android_post'), formData: formData
21
+ # end
22
+
23
+ post_url = json_ui_garage_url(path: 'notifications/android_post', title: 'Title from formData')
24
+ subaction.devices_getPushToken postUrl: post_url, paramNameForToken: 'token'
22
25
  end
23
26
  end
24
27
 
@@ -4,30 +4,18 @@ page = json_ui_page json
4
4
 
5
5
  render "#{@path_prefix}/nav_menu", json: json, page: page
6
6
 
7
- page.navBar backgroundColor: '#a8c4e3', rightButtons: ->(menu) do
8
- menu.button icon: 'search', onClick: ->(action) do
7
+ page.navBar backgroundColor: '#a8c4e3', color: '#ffffff', rightButtons: ->(menu) do
8
+ menu.button icon: 'search', onClick: ->(action) do
9
9
  action.dialogs_alert message: 'Perform some action'
10
10
  end
11
- menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
11
+ menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
12
12
  action.dialogs_alert message: 'Perform some action'
13
13
  end
14
- menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
14
+ menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
15
15
  action.dialogs_alert message: 'Perform some action'
16
16
  end
17
17
  end
18
18
 
19
- # page.rightNavButtons do |menu|
20
- # menu.button icon: 'search', onClick: ->(action) do
21
- # action.dialogs_alert message: 'Perform some action'
22
- # end
23
- # menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
24
- # action.dialogs_alert message: 'Perform some action'
25
- # end
26
- # menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
27
- # action.dialogs_alert message: 'Perform some action'
28
- # end
29
- # end
30
-
31
19
  page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
32
20
  scroll.label text: 'See the right menu buttons on the nav bar'
33
21
  end
@@ -1,26 +1,25 @@
1
1
  json.title 'Tables'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
5
5
 
6
- page.list firstSection: ->(section) do
7
- section.rows builder: ->(template) do
8
- template.thumbnail title: 'Layout', onClick: ->(action) do
9
- action.windows_open url: json_ui_garage_url(path: 'tables/layout')
10
- end
11
- template.thumbnail title: 'Horizontal Scroll', onClick: ->(action) do
12
- action.windows_open url: json_ui_garage_url(path: 'tables/horizontal_scroll')
13
- end
14
- template.thumbnail title: 'Export/Import', onClick: ->(action) do
15
- action.windows_open url: json_ui_garage_url(path: 'tables/export_import')
16
- end
17
- template.thumbnail title: 'Autoload as Needed', onClick: ->(action) do
18
- action.windows_open url: json_ui_garage_url(path: 'tables/autoload_as_needed')
19
- end
20
- template.thumbnail title: 'Autoload All', onClick: ->(action) do
21
- action.windows_open url: json_ui_garage_url(path: 'tables/autoload_all')
22
- end
6
+ page.list firstSection: ->(section) do
7
+ section.rows builder: ->(template) do
8
+ template.thumbnail title: 'Layout', onClick: ->(action) do
9
+ action.windows_open url: json_ui_garage_url(path: 'tables/layout')
10
+ end
11
+ template.thumbnail title: 'Horizontal Scroll', onClick: ->(action) do
12
+ action.windows_open url: json_ui_garage_url(path: 'tables/horizontal_scroll')
13
+ end
14
+ template.thumbnail title: 'Export/Import', onClick: ->(action) do
15
+ action.windows_open url: json_ui_garage_url(path: 'tables/export_import')
16
+ end
17
+ template.thumbnail title: 'Autoload as Needed', onClick: ->(action) do
18
+ action.windows_open url: json_ui_garage_url(path: 'tables/autoload_as_needed')
19
+ end
20
+ template.thumbnail title: 'Autoload All', onClick: ->(action) do
21
+ action.windows_open url: json_ui_garage_url(path: 'tables/autoload_all')
23
22
  end
24
-
25
23
  end
24
+
26
25
  end
@@ -1,38 +1,36 @@
1
1
  json.title 'Tables'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- column_indexes = (1..5)
7
- page.table sections: [
8
- ->(section) do
9
- section.rows builder: ->(row) do
10
- row.default colSpans: [3, 2], cellViews: ->(cell) do
11
- cell.label text: 'Spans 3 columns'
12
- cell.panels_horizontal width: 'matchParent', backgroundColor: '#dddddd', padding: { top: 10, right: 10, bottom: 10, left: 10 }, childViews: ->(horizontal) do
13
- horizontal.label text: 'Spans 2 columns'
14
- end
6
+ column_indexes = (1..5)
7
+ page.table sections: [
8
+ ->(section) do
9
+ section.rows builder: ->(row) do
10
+ row.default colSpans: [3, 2], cellViews: ->(cell) do
11
+ cell.label text: 'Spans 3 columns'
12
+ cell.panels_horizontal width: 'matchParent', backgroundColor: '#dddddd', padding: { top: 10, right: 10, bottom: 10, left: 10 }, childViews: ->(horizontal) do
13
+ horizontal.label text: 'Spans 2 columns'
15
14
  end
16
15
  end
17
- end,
18
- ->(section) do
19
- section.header cellViews: ->(header) do
20
- column_indexes.each do |i|
21
- header.label text: "Heading#{i}"
22
- end
16
+ end
17
+ end,
18
+ ->(section) do
19
+ section.header cellViews: ->(header) do
20
+ column_indexes.each do |i|
21
+ header.label text: "Heading#{i}"
23
22
  end
23
+ end
24
24
 
25
- items = [1, 2, 3]
26
- section.rows objects: items, builder: ->(row, item, index) do
27
- row.default colStyles: [{ width: 200, backgroundColor: '#eeeeee' }], cellViews: ->(cell) do
28
- column_indexes.each do |i|
29
- cell.label text: "Data #{item}"
30
- end
31
- end, onClick: ->(action) do
32
- action.windows_open url: json_ui_garage_url(path: 'home/blank')
25
+ items = [1, 2, 3]
26
+ section.rows objects: items, builder: ->(row, item, index) do
27
+ row.default colStyles: [{ width: 200, backgroundColor: '#eeeeee' }], cellViews: ->(cell) do
28
+ column_indexes.each do |i|
29
+ cell.label text: "Data #{item}"
33
30
  end
31
+ end, onClick: ->(action) do
32
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
34
33
  end
35
34
  end
36
- ]
37
-
38
- end
35
+ end
36
+ ]
@@ -19,15 +19,27 @@ json_ui_page json do |page|
19
19
  scroll.h2 text: 'With select options'
20
20
  scroll.spacer height: 6
21
21
  scroll.banners_select width: 'matchParent', icon: 'info', message: 'This is a select banner', buttons: ->(menu) do
22
- menu.button text: 'Option1', onClick: ->(action) do
22
+ menu.button icon: 'add', text: 'Add', onClick: ->(action) do
23
23
  action.windows_open url: json_ui_garage_url(path: 'home/blank')
24
24
  end
25
- menu.button text: 'Option2', onClick: ->(action) do
25
+ menu.button icon: 'edit', text: 'Edit', onClick: ->(action) do
26
26
  action.windows_open url: json_ui_garage_url(path: 'home/slow')
27
27
  end
28
- menu.button text: 'Option3', onClick: ->(action) do
28
+ menu.button icon: 'delete', text: 'Delete', onClick: ->(action) do
29
29
  action.dialogs_alert message: 'Alert'
30
30
  end
31
+
32
+ menu.button icon: 'more_vert', childButtons: ->(submenu) do
33
+ submenu.button icon: 'add', text: 'Option1', onClick: ->(action) do
34
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
35
+ end
36
+ submenu.button icon: 'edit', text: 'Option2', onClick: ->(action) do
37
+ action.windows_open url: json_ui_garage_url(path: 'home/slow')
38
+ end
39
+ submenu.button icon: 'delete', text: 'Option3', onClick: ->(action) do
40
+ action.dialogs_alert message: 'Alert'
41
+ end
42
+ end
31
43
  end
32
44
 
33
45
  scroll.spacer height: 20
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: 0.5.18
4
+ version: 0.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''