marty 2.1.5 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +4 -4
  4. data/app/components/marty/auth_app.rb +3 -3
  5. data/app/components/marty/auth_app/client/auth_app.js +1 -3
  6. data/app/components/marty/base_rule_view.rb +32 -20
  7. data/app/components/marty/data_grid_view.rb +3 -3
  8. data/app/components/marty/event_view.rb +0 -5
  9. data/app/components/marty/form.rb +8 -1
  10. data/app/components/marty/form/client/form.css +3 -0
  11. data/app/components/marty/grid.rb +174 -33
  12. data/app/components/marty/import_view.rb +151 -0
  13. data/app/components/marty/main_auth_app.rb +28 -28
  14. data/app/components/marty/mcfly_grid_panel.rb +1 -1
  15. data/app/components/marty/new_posting_form.rb +3 -3
  16. data/app/components/marty/new_posting_window.rb +5 -6
  17. data/app/components/marty/posting_grid.rb +2 -2
  18. data/app/components/marty/posting_window.rb +1 -2
  19. data/app/components/marty/promise_view.rb +11 -6
  20. data/app/components/marty/record_form_window.rb +1 -1
  21. data/app/components/marty/report_form.rb +4 -4
  22. data/app/components/marty/report_select.rb +1 -1
  23. data/app/components/marty/script_form.rb +4 -4
  24. data/app/components/marty/script_grid.rb +2 -2
  25. data/app/components/marty/script_tester.rb +1 -1
  26. data/app/components/marty/simple_app.rb +1 -2
  27. data/app/components/marty/simple_app/client/statusbar_ext.js +1 -1
  28. data/app/components/marty/tag_grid.rb +1 -1
  29. data/app/components/marty/user_view.rb +5 -5
  30. data/app/controllers/marty/job_controller.rb +5 -1
  31. data/app/models/marty/base.rb +0 -15
  32. data/app/models/marty/data_grid.rb +1 -1
  33. data/app/models/marty/log.rb +1 -0
  34. data/app/models/marty/promise.rb +27 -84
  35. data/app/models/marty/vw_promise.rb +72 -0
  36. data/app/views/layouts/marty/application.html.erb +6 -3
  37. data/config/locales/en.yml +4 -0
  38. data/db/migrate/410_jsonb_promise_result.rb +9 -0
  39. data/db/migrate/411_create_vw_promises.rb +26 -0
  40. data/lib/marty/data_change.rb +3 -4
  41. data/lib/marty/data_conversion.rb +1 -2
  42. data/lib/marty/data_importer.rb +13 -14
  43. data/lib/marty/javascript/{overrides.js → grid_view_in_form.js} +10 -6
  44. data/lib/marty/mcfly_model.rb +13 -20
  45. data/lib/marty/monkey.rb +33 -40
  46. data/lib/marty/promise_job.rb +8 -2
  47. data/lib/marty/promise_proxy.rb +6 -11
  48. data/lib/marty/rule_script_set.rb +5 -2
  49. data/lib/marty/version.rb +1 -1
  50. data/marty.gemspec +1 -1
  51. data/other/marty/diagnostic/delayed_job_workers.rb +8 -5
  52. data/spec/controllers/job_controller_spec.rb +34 -15
  53. data/spec/dummy/app/components/gemini/my_rule_view.rb +6 -0
  54. data/spec/dummy/app/models/gemini/helper.rb +2 -2
  55. data/spec/dummy/config/application.rb +1 -1
  56. data/spec/features/rule_spec.rb +100 -5
  57. data/spec/fixtures/csv/rule/MyRule.csv +1 -1
  58. data/spec/job_helper.rb +2 -4
  59. data/spec/lib/data_importer_spec.rb +10 -10
  60. data/spec/lib/delorean_query_spec.rb +13 -2
  61. data/spec/lib/logger_spec.rb +16 -14
  62. data/spec/models/data_grid_spec.rb +4 -10
  63. data/spec/models/promise_spec.rb +8 -8
  64. data/spec/models/rule_spec.rb +7 -7
  65. data/spec/spec_helper.rb +1 -1
  66. metadata +10 -5
@@ -0,0 +1,151 @@
1
+ class Marty::ImportView < Marty::Form
2
+ include Marty::Extras::Layout
3
+
4
+ action :apply do |a|
5
+ a.text = I18n.t("data_import_view.import")
6
+ a.tooltip = I18n.t("data_import_view.import")
7
+ a.icon = :database_go
8
+ end
9
+
10
+ def parent_model; end
11
+ def import_model; end
12
+ def model_view; end
13
+
14
+ def initialize args, kwargs
15
+ super(args, kwargs)
16
+ @model_view = model_view.camelize.constantize if model_view
17
+ @parent_model = parent_model.camelize.constantize if parent_model
18
+ @import_model = import_model.camelize.constantize if import_model
19
+ @record = nil
20
+ end
21
+
22
+ client_class do |c|
23
+ c.set_result = l(<<-JS)
24
+ function(html) {
25
+ var result = this.netzkeGetComponent('result');
26
+ result.updateBodyHtml(html);
27
+
28
+ var window = this.netzkeGetParentComponent();
29
+ var parent_view = window.netzkeGetParentComponent();
30
+
31
+ if (parent_view && parent_view.reload) { parent_view.reload() }
32
+ }
33
+ JS
34
+
35
+ c.init_component = l(<<-JS)
36
+ function() {
37
+ var me = this;
38
+ me.callParent();
39
+ var form = me.getForm();
40
+
41
+ var window = this.netzkeGetParentComponent();
42
+ var parent_view = window.netzkeGetParentComponent();
43
+
44
+ this.serverConfig.parent_id = parent_view.serverConfig.parent_id ||
45
+ parent_view.serverConfig.selected;
46
+
47
+ var textname = form.findField('import_data');
48
+ var importbutton = me.actions["apply"].items[0];
49
+
50
+ importbutton.on('click', function(t, e, ops) {
51
+ me.netzkeGetComponent('result').updateBodyHtml('');
52
+ });
53
+ }
54
+ JS
55
+ end
56
+
57
+ ######################################################################
58
+
59
+ def validate
60
+ return client.netzke_notify("Must provide import data.") if
61
+ @import_data.empty?
62
+ end
63
+
64
+ def process_additional_fields
65
+ nil
66
+ end
67
+
68
+ def process_import_data
69
+ CSV.new(@import_data, headers: true, col_sep: "\t")
70
+ end
71
+
72
+ def post_import
73
+ nil
74
+ end
75
+
76
+ def import data
77
+ Marty::DataImporter.
78
+ do_import_summary(@import_model, data, 'infinity', nil, nil)
79
+ end
80
+
81
+ def format_message k, v
82
+ case k
83
+ when :clean then "#{v} record(s) cleaned."
84
+ when :same then "#{v} record(s) unchanged."
85
+ when :create then "#{v} record(s) created."
86
+ when :update then "#{v} record(s) updated."
87
+ when :blank then "#{v} empty lines."
88
+ end
89
+ end
90
+
91
+ endpoint :submit do |params|
92
+ return client.netzke_notify "No Model View defined" unless @model_view
93
+
94
+ return client.netzke_notify "Permission denied" unless
95
+ @model_view.can_perform_action?(:update)
96
+
97
+ return client.netzke_notify "Can't import when time-warped" if
98
+ Marty::Util.warped?
99
+
100
+ @data = ActiveSupport::JSON.decode(params[:data])
101
+ @import_data = @data["import_data"] || ""
102
+ @record = @parent_model.try(:find_by_id, client_config['parent_id'])
103
+
104
+ validate and return
105
+ process_additional_fields and return
106
+
107
+ begin
108
+ processed = process_import_data
109
+ res = import(processed)
110
+ result = res.map{|k,v| format_message(k,v)}
111
+
112
+ messages = post_import
113
+ result << messages if messages
114
+
115
+ client.set_result result.join("<br/>")
116
+
117
+ rescue Marty::DataImporter::Error => exc
118
+ result = [
119
+ "Import failed on line(s): #{exc.lines.join(', ')}",
120
+ "Error: #{exc.to_s}",
121
+ ]
122
+
123
+ client.set_result '<font color="red">' + result.join("<br/>") + "</font>"
124
+ rescue => e
125
+ client.set_result e.message
126
+ end
127
+ end
128
+
129
+ def configure(c)
130
+ super
131
+ c.title = nil
132
+ c.items =
133
+ [
134
+ textarea_field(:import_data,
135
+ height: 300,
136
+ hide_label: true,
137
+ min_width: 10000,
138
+ ),
139
+ :result,
140
+ ]
141
+ end
142
+
143
+ component :result do |c|
144
+ c.klass = Marty::Panel
145
+ c.title = I18n.t("data_import_view.results")
146
+ c.html = ""
147
+ c.flex = 1
148
+ c.min_height = 150
149
+ c.scrollable = true
150
+ end
151
+ end
@@ -30,7 +30,7 @@ class Marty::MainAuthApp < Marty::AuthApp
30
30
  text: warped ? "#{Marty::Util.get_posting.name}" : I18n.t("postings"),
31
31
  name: "posting",
32
32
  tooltip: "Postings",
33
- icon: icon_hack(:time),
33
+ icon_cls: "fa fa-clock glyph",
34
34
  style: (warped ? "background-color: lightGrey;" : ""),
35
35
  menu: [
36
36
  :new_posting,
@@ -44,7 +44,7 @@ class Marty::MainAuthApp < Marty::AuthApp
44
44
  [
45
45
  {
46
46
  text: 'Log Maintenance',
47
- icon: icon_hack(:wrench),
47
+ icon_cls: "fa fa-wrench glyph",
48
48
  disabled: !self.class.has_admin_perm?,
49
49
  menu: [
50
50
  :log_view,
@@ -58,7 +58,7 @@ class Marty::MainAuthApp < Marty::AuthApp
58
58
  [
59
59
  {
60
60
  text: 'API Management',
61
- icon: icon_hack(:wrench),
61
+ icon_cls: "fa fa-wrench glyph",
62
62
  disabled: !self.class.has_admin_perm?,
63
63
  menu: [
64
64
  :api_auth_view,
@@ -72,7 +72,7 @@ class Marty::MainAuthApp < Marty::AuthApp
72
72
  def system_menu
73
73
  {
74
74
  text: I18n.t("system"),
75
- icon: icon_hack(:wrench),
75
+ icon_cls: "fa fa-wrench glyph",
76
76
  style: "",
77
77
  menu: [
78
78
  :import_type_view,
@@ -88,7 +88,7 @@ class Marty::MainAuthApp < Marty::AuthApp
88
88
  def applications_menu
89
89
  {
90
90
  text: I18n.t("applications"),
91
- icon: icon_hack(:application_cascade),
91
+ icon_cls: "fa fa-window-restore glyph",
92
92
  menu: [
93
93
  :data_grid_view,
94
94
  :reporting,
@@ -102,7 +102,7 @@ class Marty::MainAuthApp < Marty::AuthApp
102
102
  [
103
103
  {
104
104
  text: 'Background Jobs',
105
- icon: icon_hack(:clock),
105
+ icon_cls: "fa fa-user-clock glyph",
106
106
  disabled: !self.class.has_admin_perm?,
107
107
  menu: [
108
108
  :bg_status,
@@ -131,7 +131,7 @@ class Marty::MainAuthApp < Marty::AuthApp
131
131
  end
132
132
 
133
133
  def ident_menu
134
- "<span style='color:#3333FF;
134
+ "<span style='color:#157fcc;
135
135
  background-color:#{warped ? '#FBDF4F' : ''};
136
136
  font-size:120%;
137
137
  font-weight:bold;'>#{app_title}</span>"
@@ -160,34 +160,34 @@ class Marty::MainAuthApp < Marty::AuthApp
160
160
  a.text = I18n.t("import_type")
161
161
  a.handler = :netzke_load_component_by_action
162
162
  a.disabled = !self.class.has_admin_perm?
163
- a.icon = :table_go
163
+ a.icon_cls = "fa fa-file-import glyph"
164
164
  end
165
165
 
166
166
  action :scripting do |a|
167
167
  a.text = I18n.t("scripting")
168
168
  a.handler = :netzke_load_component_by_action
169
- a.icon = :script
169
+ a.icon_cls = "fa fa-code glyph"
170
170
  a.disabled = !self.class.has_any_perm?
171
171
  end
172
172
 
173
173
  action :reporting do |a|
174
174
  a.text = I18n.t("reports")
175
175
  a.handler = :netzke_load_component_by_action
176
- a.icon = :page_lightning
176
+ a.icon_cls = "fa fa-file-alt glyph"
177
177
  a.disabled = !self.class.has_any_perm?
178
178
  end
179
179
 
180
180
  action :promise_view do |a|
181
181
  a.text = I18n.t("jobs.promise_view")
182
182
  a.handler = :netzke_load_component_by_action
183
- a.icon = :report_magnify
183
+ a.icon_cls = "fa fa-search glyph"
184
184
  a.disabled = !self.class.has_any_perm?
185
185
  end
186
186
 
187
187
  action :user_view do |a|
188
188
  a.text = I18n.t("user_view")
189
189
  a.handler = :netzke_load_component_by_action
190
- a.icon = :group
190
+ a.icon_cls = "fa fa-users glyph"
191
191
  a.disabled = !self.class.has_admin_perm? &&
192
192
  !self.class.has_user_manager_perm?
193
193
  end
@@ -195,14 +195,14 @@ class Marty::MainAuthApp < Marty::AuthApp
195
195
  action :event_view do |a|
196
196
  a.text = I18n.t("event_view")
197
197
  a.handler = :netzke_load_component_by_action
198
- a.icon = :application_view_list
198
+ a.icon_cls = "fa fa-bolt glyph"
199
199
  a.disabled = !self.class.has_admin_perm?
200
200
  end
201
201
 
202
202
  action :config_view do |a|
203
203
  a.text = I18n.t("config_view")
204
204
  a.handler = :netzke_load_component_by_action
205
- a.icon = :cog
205
+ a.icon_cls = "fa fa-cog glyph"
206
206
  a.disabled = !self.class.has_admin_perm? &&
207
207
  !self.class.has_user_manager_perm?
208
208
  end
@@ -210,63 +210,63 @@ class Marty::MainAuthApp < Marty::AuthApp
210
210
  action :api_auth_view do |a|
211
211
  a.text = 'API Auth Management'
212
212
  a.handler = :netzke_load_component_by_action
213
- a.icon = :script_key
213
+ a.icon_cls = "fa fa-key glyph"
214
214
  a.disabled = !self.class.has_admin_perm?
215
215
  end
216
216
 
217
217
  action :api_config_view do |a|
218
218
  a.text = 'API Config Management'
219
219
  a.handler = :netzke_load_component_by_action
220
- a.icon = :script_key
220
+ a.icon_cls = "fa fa-cogs glyph"
221
221
  a.disabled = !self.class.has_admin_perm?
222
222
  end
223
223
 
224
224
  action :api_log_view do |a|
225
225
  a.text = 'API Log View'
226
226
  a.handler = :netzke_load_component_by_action
227
- a.icon = :script_key
227
+ a.icon_cls = "fa fa-cogs glyph"
228
228
  a.disabled = !self.class.has_admin_perm?
229
229
  end
230
230
 
231
231
  action :data_grid_view do |a|
232
232
  a.text = I18n.t("data_grid_view", default: "Data Grids")
233
233
  a.handler = :netzke_load_component_by_action
234
- a.icon = :table_multiple
234
+ a.icon_cls = "fa fa-table glyph"
235
235
  a.disabled = !self.class.has_any_perm?
236
236
  end
237
237
 
238
238
  action :reload_scripts do |a|
239
239
  a.text = 'Reload Scripts'
240
240
  a.tooltip = 'Reload and tag Delorean scripts'
241
- a.icon = :arrow_refresh
241
+ a.icon_cls = "fa fa-sync-alt glyph"
242
242
  a.disabled = !self.class.has_admin_perm?
243
243
  end
244
244
 
245
245
  action :load_seed do |a|
246
246
  a.text = 'Load Seeds'
247
247
  a.tooltip = 'Load Seeds'
248
- a.icon = :arrow_rotate_clockwise
248
+ a.icon_cls = "fa fa-retweet glyph"
249
249
  a.disabled = !self.class.has_admin_perm?
250
250
  end
251
251
 
252
252
  action :bg_status do |a|
253
253
  a.text = 'Show Delayed Jobs Status'
254
254
  a.tooltip = 'Run delayed_job status script'
255
- a.icon = :monitor
255
+ a.icon_cls = "fa fa-desktop glyph"
256
256
  a.disabled = !self.class.has_admin_perm?
257
257
  end
258
258
 
259
259
  action :bg_stop do |a|
260
260
  a.text = 'Stop Delayed Jobs'
261
261
  a.tooltip = 'Run delayed_job stop script'
262
- a.icon = :stop
262
+ a.icon_cls = "fa fa-skull glyph"
263
263
  a.disabled = !self.class.has_admin_perm?
264
264
  end
265
265
 
266
266
  action :bg_restart do |a|
267
267
  a.text = 'Restart Delayed Jobs'
268
268
  a.tooltip = 'Run delayed_job restart script using DELAYED_JOB_PARAMS'
269
- a.icon = :arrow_rotate_clockwise
269
+ a.icon_cls = "fa fa-power-off glyph"
270
270
  a.disabled = !self.class.has_admin_perm?
271
271
  end
272
272
 
@@ -274,14 +274,14 @@ class Marty::MainAuthApp < Marty::AuthApp
274
274
  a.text = 'View Log'
275
275
  a.tooltip = 'View Log'
276
276
  a.handler = :netzke_load_component_by_action
277
- a.icon = :cog
277
+ a.icon_cls = "fa fa-cog glyph"
278
278
  a.disabled = !self.class.has_admin_perm?
279
279
  end
280
280
 
281
281
  action :log_cleanup do |a|
282
282
  a.text = 'Cleanup Log Table'
283
283
  a.tooltip = 'Delete old log records'
284
- a.icon = :cog
284
+ a.icon_cls = "fa fa-cog glyph"
285
285
  a.disabled = !self.class.has_admin_perm?
286
286
  end
287
287
 
@@ -333,7 +333,7 @@ class Marty::MainAuthApp < Marty::AuthApp
333
333
  action :new_posting do |a|
334
334
  a.text = I18n.t('new_posting')
335
335
  a.tooltip = I18n.t('new_posting')
336
- a.icon = :time_add
336
+ a.icon_cls = "fa fa-plus glyph"
337
337
  a.disabled = Marty::Util.warped? || !self.class.has_posting_perm?
338
338
  end
339
339
 
@@ -486,7 +486,7 @@ class Marty::MainAuthApp < Marty::AuthApp
486
486
  action :select_posting do |a|
487
487
  a.text = I18n.t('select_posting')
488
488
  a.tooltip = I18n.t('select_posting')
489
- a.icon = :timeline_marker
489
+ a.icon_cls = "fa fa-history glyph"
490
490
  end
491
491
 
492
492
  endpoint :select_posting do |params|
@@ -500,7 +500,7 @@ class Marty::MainAuthApp < Marty::AuthApp
500
500
 
501
501
  action :select_now do |a|
502
502
  a.text = I18n.t('go_to_now')
503
- a.icon = :arrow_in
503
+ a.icon_cls = "fa fa-globe glyph"
504
504
  a.disabled = Marty::Util.get_posting_time == Float::INFINITY
505
505
  end
506
506
 
@@ -65,7 +65,7 @@ class Marty::McflyGridPanel < Marty::Grid
65
65
 
66
66
  action :dup_in_form do |a|
67
67
  a.hidden = !config[:permissions][:create]
68
- a.icon = :page_copy
68
+ a.icon_cls = "fa fa-copy glyph"
69
69
  a.disabled = true
70
70
  end
71
71
 
@@ -14,9 +14,9 @@ class Marty::NewPostingForm < Marty::Form
14
14
  end
15
15
 
16
16
  action :apply do |a|
17
- a.text = I18n.t("create_posting")
18
- a.tooltip = I18n.t("create_posting")
19
- a.icon = :time_add
17
+ a.text = I18n.t("create_posting")
18
+ a.tooltip = I18n.t("create_posting")
19
+ a.icon_cls = 'fa fa-clock glyph'
20
20
  end
21
21
 
22
22
  ######################################################################
@@ -4,12 +4,11 @@ class Marty::NewPostingWindow < Netzke::Window::Base
4
4
  def configure(c)
5
5
  super
6
6
 
7
- c.title = I18n.t('new_posting')
8
- c.modal = true
9
- c.items = [:new_posting_form]
10
- c.lazy_loading = true
11
- c.width = 350
12
- c.height = 130
7
+ c.title = I18n.t('new_posting')
8
+ c.modal = true
9
+ c.items = [:new_posting_form]
10
+ c.layout = 'fit'
11
+ c.lazy_loading = true
13
12
  end
14
13
 
15
14
  component :new_posting_form do |c|
@@ -17,7 +17,7 @@ class Marty::PostingGrid < Marty::Grid
17
17
  action :delete do |a|
18
18
  a.text = "Select"
19
19
  a.tooltip = "Select"
20
- a.icon = :time_go
20
+ a.icon_cls = "fa fa-clock glyph"
21
21
  a.disabled = true
22
22
  end
23
23
 
@@ -82,7 +82,7 @@ class Marty::PostingGrid < Marty::Grid
82
82
 
83
83
  action :detail do |a|
84
84
  a.text = "Detail"
85
- a.icon = :application_view_detail
85
+ a.icon_cls = "fa fa-th-large glyph"
86
86
  a.handler = :detail
87
87
  a.disabled = true
88
88
  end
@@ -6,7 +6,7 @@ class Marty::PostingWindow < Netzke::Window::Base
6
6
  c.modal = true
7
7
  c.items = [:posting_grid]
8
8
  c.lazy_loading = true
9
- c.width = 400
9
+ c.width = 600
10
10
  c.height = 350
11
11
  end
12
12
 
@@ -20,7 +20,6 @@ class Marty::PostingWindow < Netzke::Window::Base
20
20
  }
21
21
  # c.bbar = []
22
22
  end
23
-
24
23
  end
25
24
 
26
25
  PostingWindow = Marty::PostingWindow