marty 6.1.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +17 -3
  4. data/.rubocop.yml +5 -0
  5. data/.rubocop_todo.yml +3 -2
  6. data/Gemfile +2 -1
  7. data/app/assets/javascripts/marty/extjs/extensions/marty.js +23 -1
  8. data/app/assets/stylesheets/marty/application.css +4 -1
  9. data/app/assets/stylesheets/marty/dark_mode.css +17 -0
  10. data/app/components/marty/auth_app.rb +10 -1
  11. data/app/components/marty/auth_app/client/auth_app.js +4 -0
  12. data/app/components/marty/extras/layout.rb +2 -2
  13. data/app/components/marty/extras/misc.rb +1 -1
  14. data/app/components/marty/log_view.rb +0 -1
  15. data/app/components/marty/main_auth_app.rb +9 -12
  16. data/app/components/marty/promise_view.rb +5 -0
  17. data/app/components/marty/promise_view/client/promise_view.js +11 -0
  18. data/app/components/marty/schedule_jobs_dashboard.rb +30 -96
  19. data/app/components/marty/schedule_jobs_grid.rb +118 -0
  20. data/app/controllers/marty/application_controller.rb +6 -2
  21. data/app/models/marty/base.rb +48 -48
  22. data/app/models/marty/config.rb +14 -2
  23. data/app/models/marty/user.rb +12 -0
  24. data/app/services/marty/background_job/fetch_missing_in_schedule_cron_jobs.rb +19 -0
  25. data/app/services/marty/enums/report.rb +18 -0
  26. data/app/services/marty/promises/delorean/create.rb +16 -27
  27. data/app/services/marty/promises/ruby/create.rb +10 -1
  28. data/app/views/layouts/marty/application.html.erb +4 -1
  29. data/app/views/marty/diagnostic/op.html.erb +3 -1
  30. data/config/locales/en.yml +2 -0
  31. data/db/migrate/512_add_promise_priority.rb +9 -0
  32. data/db/migrate/513_add_priority_to_promise_view.rb +44 -0
  33. data/db/migrate/514_remove_marty_events.rb +13 -0
  34. data/delorean/enum_report.dl +11 -0
  35. data/delorean/table_report.dl +7 -0
  36. data/docker-compose.dummy.yml +7 -4
  37. data/lib/marty.rb +5 -2
  38. data/lib/marty/api/base.rb +15 -9
  39. data/lib/marty/cache_adapters.rb +2 -0
  40. data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -5
  41. data/lib/marty/cache_adapters/memory_and_redis.rb +93 -0
  42. data/lib/marty/cache_adapters/redis.rb +63 -0
  43. data/lib/marty/delayed_job/scheduled_job_plugin.rb +33 -0
  44. data/lib/marty/diagnostic/database.rb +1 -2
  45. data/lib/marty/logger.rb +50 -17
  46. data/lib/marty/monkey.rb +26 -6
  47. data/lib/marty/promise_ruby_job.rb +2 -0
  48. data/lib/marty/rails_app.rb +29 -0
  49. data/lib/marty/railtie.rb +1 -0
  50. data/lib/marty/version.rb +1 -1
  51. data/marty.gemspec +1 -0
  52. data/spec/controllers/job_controller_spec.rb +2 -2
  53. data/spec/dummy/app/components/gemini/cm_auth_app.rb +12 -0
  54. data/spec/dummy/app/components/gemini/simple_view.rb +17 -0
  55. data/spec/dummy/app/jobs/test_failing_job.rb +14 -0
  56. data/spec/dummy/app/models/gemini/helper.rb +90 -1
  57. data/spec/dummy/config/application.rb +1 -0
  58. data/spec/dummy/db/migrate/20191101132729_add_activity_flag_to_simple.rb +10 -0
  59. data/spec/dummy/delorean/blame_report.dl +1 -0
  60. data/spec/dummy/delorean/enum_report.dl +1 -0
  61. data/spec/dummy/delorean/marty_fields.dl +1 -0
  62. data/spec/dummy/delorean/table_report.dl +1 -0
  63. data/spec/features/data_blame_report_spec.rb +66 -0
  64. data/spec/features/data_grid_spec.rb +1 -1
  65. data/spec/features/enum_values_report_spec.rb +76 -0
  66. data/spec/features/inline_editing_spec.rb +33 -0
  67. data/spec/features/rule_spec.rb +1 -1
  68. data/spec/features/schedule_jobs_dashboard_spec.rb +1 -1
  69. data/spec/features/scripting_spec.rb +1 -1
  70. data/spec/features/user_list_report_spec.rb +74 -0
  71. data/spec/fixtures/misc/struct_compare_tests.txt +15 -5
  72. data/spec/job_helper.rb +39 -0
  73. data/spec/jobs/cron_job_spec.rb +91 -0
  74. data/spec/lib/mcfly_model_spec.rb +9 -0
  75. data/spec/models/promise_spec.rb +168 -1
  76. data/spec/other/diagnostic/delayed_job_workers_spec.rb +1 -1
  77. data/spec/performance/caching_spec.rb +99 -0
  78. data/spec/services/background_job/fetch_missing_in_schedule_cron_jobs_spec.rb +34 -0
  79. data/spec/support/delayed_job_helpers.rb +3 -3
  80. data/spec/support/shared_connection.rb +9 -1
  81. data/spec/support/structure_compare.rb +19 -3
  82. metadata +39 -6
  83. data/app/components/marty/event_view.rb +0 -129
  84. data/app/models/marty/event.rb +0 -317
  85. data/spec/dummy/db/migrate/20160923183516_add_bulk_pricing_event_ops.rb +0 -8
  86. data/spec/dummy/delorean/blame_report.dl +0 -268
  87. data/spec/dummy/delorean/marty_fields.dl +0 -63
  88. data/spec/dummy/delorean/table_report.dl +0 -34
  89. data/spec/models/event_spec.rb +0 -272
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f1457a8c273c33b4b74c01a76e07fc6b690fb5dd836511c648e7e60211ae2d7
4
- data.tar.gz: 570417d238e3225b53914e99c7f293804c75bd3498bb3ce4ba90976a48d81c8b
3
+ metadata.gz: ba9d8e9da88bf08b792bd49d882e4320dc0e68f338ab5ed35577a4c1c741ae90
4
+ data.tar.gz: b9b76371c794c41b8383c52a30d03d0ecccbfc428bfe88f598c8ec6778e4e63f
5
5
  SHA512:
6
- metadata.gz: 90b58649b5c1d327798ed130f0725fec9c08b4aa1bf74cdf09b170d28d8067052563f985b3be49cf76a0a80a835845a1224682ffc973ded8f6eeee196a978318
7
- data.tar.gz: 8c73073a407a988bf6a13e7f3ec19305b0253e7e18d1f948bba4e47fbbf2993852c87858b407a6ed0c57ca63c810a5fa417723a90859fff1791b85eac10cf347
6
+ metadata.gz: ddf969f74e26013d76713537bcddeba889983d83d80ea60d5ace5cb92cc44a77096e73a356524def77ca10a00b473574fa9a94acffbfa1182bbc61c0927b413f
7
+ data.tar.gz: 4a3f20060711fc70cce936e90197f88a1256f1c814d4cf2fbadde12b28715eeffde3c096e92db1c1a7693d9ad268966e77e4aa2b1ee20b3d7078e93838869f78
data/.gitignore CHANGED
@@ -5,6 +5,7 @@ spec/dummy/db/*.sqlite3
5
5
  spec/dummy/log/*.log
6
6
  spec/dummy/log/*.sql
7
7
  spec/dummy/tmp/
8
+ spec/dummy/spec/tmp/
8
9
  spec/dummy/.sass-cache
9
10
 
10
11
  # Ignore schema
data/.gitlab-ci.yml CHANGED
@@ -1,7 +1,8 @@
1
- image: 415596832415.dkr.ecr.us-west-2.amazonaws.com/cm_tech/docker-ruby-ci-image:2.6.3-20191003
1
+ image: 415596832415.dkr.ecr.us-west-2.amazonaws.com/cm_tech/docker-ruby-ci-image:2.6.3-extjs-7-20191018143452
2
2
 
3
3
  services:
4
4
  - "postgres:9.6"
5
+ - "redis:5.0.6-alpine"
5
6
 
6
7
  before_script:
7
8
  - time bundle install --jobs $(nproc) --path vendor "${FLAGS[@]}"
@@ -24,11 +25,23 @@ rspec-without-features:
24
25
  script:
25
26
  - bundle exec rspec --exclude-pattern "spec/features/**/*_spec.rb"
26
27
 
27
- rspec-features:
28
+ rspec-features-1:
28
29
  extends: .base-test
29
30
  script:
30
31
  - ln -s /opt/support/extjs /cm_tech/marty/spec/dummy/public/extjs
31
- - bundle exec rspec spec/features
32
+ - bundle exec rspec spec/features --tag ~speed
33
+
34
+ rspec-features-2:
35
+ extends: .base-test
36
+ script:
37
+ - ln -s /opt/support/extjs /cm_tech/marty/spec/dummy/public/extjs
38
+ - bundle exec rspec spec/features --tag speed:slow
39
+
40
+ rspec-features-3:
41
+ extends: .base-test
42
+ script:
43
+ - ln -s /opt/support/extjs /cm_tech/marty/spec/dummy/public/extjs
44
+ - bundle exec rspec spec/features --tag speed:super_slow
32
45
 
33
46
  cache:
34
47
  key: 'marty_bundler_cache'
@@ -44,6 +57,7 @@ variables:
44
57
  PGTZ: "America/Los_Angeles"
45
58
  POSTGRES_USER: "runner"
46
59
  POSTGRES_PASSWORD: ""
60
+ MARTY_REDIS_URL: 'localhost:6379/1'
47
61
  RAILS_ENV: "test"
48
62
  RAILS_DUMP_SCHEMA: "false"
49
63
  REPOSITORY_URL: '415596832415.dkr.ecr.us-west-2.amazonaws.com/cm_tech/docker-ruby-ci-image'
data/.rubocop.yml CHANGED
@@ -41,3 +41,8 @@ Lint/UnusedMethodArgument:
41
41
 
42
42
  Style/SymbolArray:
43
43
  EnforcedStyle: brackets
44
+
45
+ # Marshal serialisation is used in Redis caching
46
+ Security/MarshalLoad:
47
+ Exclude:
48
+ - 'lib/marty/cache_adapters/redis.rb'
data/.rubocop_todo.yml CHANGED
@@ -175,6 +175,7 @@ Lint/DuplicateMethods:
175
175
  Lint/HandleExceptions:
176
176
  Exclude:
177
177
  - 'spec/support/netzke.rb'
178
+ - 'lib/marty/delayed_job/scheduled_job_plugin.rb'
178
179
 
179
180
  # Offense count: 19
180
181
  Lint/IneffectiveAccessModifier:
@@ -1028,7 +1029,7 @@ Style/TrailingCommaInHashLiteral:
1028
1029
 
1029
1030
  # Offense count: 12
1030
1031
  # Cop supports --auto-correct.
1031
- Style/UnneededPercentQ:
1032
+ Style/RedundantPercentQ:
1032
1033
  Exclude:
1033
1034
  - 'app/components/marty/simple_app.rb'
1034
1035
  - 'spec/features/rule_spec.rb'
@@ -1036,7 +1037,7 @@ Style/UnneededPercentQ:
1036
1037
 
1037
1038
  # Offense count: 1
1038
1039
  # Cop supports --auto-correct.
1039
- Style/UnneededSort:
1040
+ Style/RedundantSort:
1040
1041
  Exclude:
1041
1042
  - 'app/models/marty/event.rb'
1042
1043
 
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ group :default do
9
9
  gem 'daemons'
10
10
  gem 'delayed_job_active_record'
11
11
  gem 'pg'
12
- gem 'rails', '>= 5.2.3', '< 6.0.0'
12
+ gem 'rails'
13
13
  end
14
14
 
15
15
  group :default, :cmit do
@@ -20,6 +20,7 @@ group :default, :cmit do
20
20
  end
21
21
 
22
22
  group :development, :test do
23
+ gem 'benchmark-ips'
23
24
  gem 'capybara'
24
25
  gem 'connection_pool'
25
26
  gem 'database_cleaner'
@@ -907,4 +907,26 @@ Ext.define('overrides.grid.column.Column', {
907
907
  }
908
908
  return this.callParent(arguments)
909
909
  }
910
- })
910
+ }
911
+ );
912
+
913
+ Ext.define('Ext.netzke.marty.MultiSelectCombo', {
914
+ extend: 'Ext.form.ComboBox',
915
+ alias: 'widget.multiselectcombo',
916
+ separator: ",",
917
+ multiSelect: true,
918
+
919
+ setValue: function(v) {
920
+ if (Ext.isString(v)) {
921
+ var vArray = v.split(this.separator);
922
+ this.callParent([vArray]);
923
+ } else {
924
+ this.callParent(arguments);
925
+ }
926
+ },
927
+ }
928
+ );
929
+
930
+ // Fix component fetching in ExtJS 7
931
+ // This flag was false by default in ExtJS 6
932
+ Ext.USE_NATIVE_JSON = false;
@@ -1 +1,4 @@
1
- //= require_tree .
1
+ /*
2
+ *= stub marty/dark_mode
3
+ *= require_tree .
4
+ */
@@ -0,0 +1,17 @@
1
+ html {
2
+ background: #000 !important;
3
+ }
4
+
5
+ body {
6
+ background-color: #FFF !important;
7
+ filter: invert(90%) grayscale(10%) hue-rotate(180deg) !important;
8
+ -moz-filter: invert(90%) grayscale(10%) hue-rotate(180deg) !important;
9
+ -webkit-filter: invert(90%) grayscale(10%) hue-rotate(180deg) !important;
10
+ }
11
+
12
+ em, img, svg, image, video, audio, embed, iframe, object, button, canvas, figure:empty {
13
+ filter: invert(100%) !important;
14
+ -moz-filter: invert(100%) !important;
15
+ -webkit-filter: invert(100%) !important;
16
+ }
17
+
@@ -25,7 +25,7 @@ class Marty::AuthApp < Marty::SimpleApp
25
25
  end
26
26
 
27
27
  def user_menu
28
- [:sign_out]
28
+ [:sign_out, :toggle_dark_mode]
29
29
  end
30
30
 
31
31
  action :sign_in do |c|
@@ -37,6 +37,11 @@ class Marty::AuthApp < Marty::SimpleApp
37
37
  c.text = "Sign out #{Mcfly.whodunnit.name}" if Mcfly.whodunnit
38
38
  end
39
39
 
40
+ action :toggle_dark_mode do |a|
41
+ a.text = 'Toggle Dark Mode'
42
+ a.icon_cls = 'fa fa-adjust glyph'
43
+ end
44
+
40
45
  endpoint :sign_in do |params|
41
46
  user = Marty::User.try_to_login(params[:login], params[:password])
42
47
  user ? Netzke::Base.controller.set_user(user) :
@@ -49,4 +54,8 @@ class Marty::AuthApp < Marty::SimpleApp
49
54
  Netzke::Base.controller.logout_user
50
55
  true
51
56
  end
57
+
58
+ endpoint :toggle_dark_mode do
59
+ Netzke::Base.controller.toggle_dark_mode
60
+ end
52
61
  end
@@ -87,5 +87,9 @@
87
87
  window.location.href = "/";
88
88
  }
89
89
  })
90
+ },
91
+
92
+ netzkeOnToggleDarkMode: function() {
93
+ this.server.toggleDarkMode(() => { window.location.href = "/" });
90
94
  }
91
95
  }
@@ -73,7 +73,7 @@ module Layout
73
73
  ######################################################################
74
74
  # PG ENUM field handling
75
75
 
76
- def enum_column(c, class_or_array, col = nil)
76
+ def enum_column(c, class_or_array, col = nil, allow_null = true)
77
77
  col ||= c.name.demodulize.tableize.singularize
78
78
  vals = class_or_array.is_a?(Array) ? class_or_array : class_or_array::VALUES
79
79
  editor_config = {
@@ -81,7 +81,7 @@ module Layout
81
81
  xtype: :combo,
82
82
 
83
83
  # hacky: extjs has issues with forceSelection true and clearing combos
84
- store: vals + ['---'],
84
+ store: vals + (allow_null ? ['---'] : []),
85
85
 
86
86
  # we can dynamically add enums (i.e. they're not in VALUES) --
87
87
  # turn off forced selection.
@@ -3,7 +3,7 @@ module Marty::Extras::Misc
3
3
  editor_config: {
4
4
  trigger_action: :all,
5
5
  xtype: :combo,
6
- store: (1..12).map { |x| [x, '%02d' % x] },
6
+ store: (1..12).map { |x| [x, '%<x>02d' % { x: x }] },
7
7
  # FIXME: for some reason, with Netzke 0.8.2, the label show
8
8
  # up in the grid editor. This hack seems to fix the
9
9
  # problem. However, the label in the add-in-form now looks
@@ -75,7 +75,6 @@ class Marty::LogView < Marty::Grid
75
75
  end
76
76
 
77
77
  column :details do |c|
78
- c.getter = lambda { |r| CGI.escapeHTML(r.details.pretty_inspect) }
79
78
  c.filter_with = lambda { |r, v, op|
80
79
  r.where("details::text #{op} '%#{v}%'")
81
80
  }
@@ -6,7 +6,6 @@ require 'marty/data_grid_view'
6
6
  require 'marty/schedule_jobs_dashboard'
7
7
  require 'marty/schedule_jobs_logs'
8
8
  require 'marty/data_grid_user_view'
9
- require 'marty/event_view'
10
9
  require 'marty/import_type_view'
11
10
  require 'marty/new_posting_window'
12
11
  require 'marty/posting_window'
@@ -85,7 +84,6 @@ class Marty::MainAuthApp < Marty::AuthApp
85
84
  :import_type_view,
86
85
  :user_view,
87
86
  :config_view,
88
- :event_view,
89
87
  :reload_scripts,
90
88
  :load_seed,
91
89
  ] + background_jobs_menu + log_menu + api_menu
@@ -134,7 +132,7 @@ class Marty::MainAuthApp < Marty::AuthApp
134
132
  def app_title
135
133
  e = ENV['RAILS_ENV']
136
134
 
137
- title = "#{app_moniker} #{Rails.application.class.parent_name.titleize}"
135
+ title = "#{app_moniker} #{::Marty::RailsApp.application_name.titleize}"
138
136
  title += " - #{e.capitalize}" unless e == 'production'
139
137
  title += ' [TIME WARPED]' if warped
140
138
  title
@@ -202,13 +200,6 @@ class Marty::MainAuthApp < Marty::AuthApp
202
200
  !self.class.has_perm?(:user_manager)
203
201
  end
204
202
 
205
- action :event_view do |a|
206
- a.text = I18n.t('event_view')
207
- a.handler = :netzke_load_component_by_action
208
- a.icon_cls = 'fa fa-bolt glyph'
209
- a.disabled = !self.class.has_perm?(:admin)
210
- end
211
-
212
203
  action :config_view do |a|
213
204
  a.text = I18n.t('config_view')
214
205
  a.handler = :netzke_load_component_by_action
@@ -297,6 +288,14 @@ class Marty::MainAuthApp < Marty::AuthApp
297
288
  a.handler = :netzke_load_component_by_action
298
289
  end
299
290
 
291
+ action :schedule_jobs_dashboard do |a|
292
+ a.text = 'Schedule Jobs Dashboard'
293
+ a.tooltip = 'Edit Delayed Jobs Cron schedules'
294
+ a.icon_cls = 'fa fa-cog glyph'
295
+ a.disabled = !self.class.has_perm?(:admin)
296
+ a.handler = :netzke_load_component_by_action
297
+ end
298
+
300
299
  action :schedule_jobs_logs do |a|
301
300
  a.text = "Schedule Job's Logs"
302
301
  a.tooltip = "Show Scheduled Job's logs"
@@ -411,8 +410,6 @@ class Marty::MainAuthApp < Marty::AuthApp
411
410
  component :data_grid_view
412
411
  component :data_grid_user_view
413
412
 
414
- component :event_view
415
-
416
413
  component :import_type_view
417
414
 
418
415
  component :log_view do |c|
@@ -30,6 +30,7 @@ class Marty::PromiseView < Netzke::Tree::Base
30
30
  { name: :title, xtype: :treecolumn },
31
31
  :user__login,
32
32
  :job_id,
33
+ :priority,
33
34
  :start_dt,
34
35
  :end_dt,
35
36
  :status,
@@ -91,6 +92,10 @@ class Marty::PromiseView < Netzke::Tree::Base
91
92
  config.width = 100
92
93
  end
93
94
 
95
+ attribute :priority do |config|
96
+ config.width = 90
97
+ end
98
+
94
99
  attribute :job_id do |config|
95
100
  config.width = 90
96
101
  end
@@ -28,19 +28,23 @@
28
28
  if (status === true) return "green-row";
29
29
  return "orange-row";
30
30
  },
31
+
31
32
  listenFn: function (obj, search_text) {
32
33
  var lg = this.ownerCt.ownerCt;
33
34
  lg.getStore().getProxy().extraParams.live_search = search_text;
34
35
  lg.getStore().load();
35
36
  },
37
+
36
38
  netzkeOnDownload: function () {
37
39
  var jid = this.getSelectionModel().getSelection()[0].getId();
38
40
  // FIXME: seems pretty hacky
39
41
  window.location = this.jobPath(jid);
40
42
  },
43
+
41
44
  netzkeOnRefresh: function () {
42
45
  this.store.load();
43
46
  },
47
+
44
48
  netzkeOnClear: function (params) {
45
49
  var me = this;
46
50
  Ext.Msg.show({
@@ -53,5 +57,12 @@
53
57
  (btn == "ok" && value == "CLEAR") && me.server.clear({});
54
58
  }
55
59
  });
60
+ },
61
+
62
+ // Updates model's `expanded` column if it's present.
63
+ // Since promises don't have such column, we don't need to send that
64
+ // extra request for every node expand event.
65
+ netzkeOnNodeStateChange: function() {
66
+ return;
56
67
  }
57
68
  }
@@ -1,117 +1,51 @@
1
- class Marty::ScheduleJobsDashboard < Marty::Grid
2
- ACCESSIBLE_BY = [:admin]
1
+ require 'marty/schedule_jobs_grid'
3
2
 
4
- has_marty_permissions(
5
- read: ACCESSIBLE_BY,
6
- create: ACCESSIBLE_BY,
7
- update: ACCESSIBLE_BY,
8
- delete: ACCESSIBLE_BY,
9
- destroy: ACCESSIBLE_BY,
10
- job_run: ACCESSIBLE_BY,
11
- edit_window__edit_form__submit: ACCESSIBLE_BY,
12
- add_window__add_form__submit: ACCESSIBLE_BY
13
- )
3
+ class Marty::ScheduleJobsDashboard < Marty::Form
4
+ include Marty::Extras::Layout
14
5
 
15
6
  def configure(c)
16
7
  super
17
-
18
- c.title ||= I18n.t('schedule_jobs_dashboard_view_title', default: 'Schedule Jobs Dashboard')
19
- c.model = 'Marty::BackgroundJob::Schedule'
20
- c.paging = :buffered
21
- c.editing = :in_form
22
- c.multi_select = false
23
-
24
- c.attributes = [
25
- :job_class,
26
- :cron,
27
- :state
8
+ c.items = [
9
+ :schedule_jobs_grid,
10
+ :schedule_jobs_warnings
28
11
  ]
29
12
  end
30
13
 
31
- def default_context_menu
32
- []
33
- end
34
-
35
- def default_bbar
36
- super + [:do_job_run]
37
- end
38
-
39
- attribute :job_class do |c|
40
- c.width = 400
41
- end
42
-
43
- attribute :cron do |c|
44
- c.width = 400
45
- end
46
-
47
- attribute :state do |c|
48
- c.width = 150
49
- editor_config = {
50
- trigger_action: :all,
51
- xtype: :combo,
52
- store: Marty::BackgroundJob::Schedule::ALL_STATES,
53
- forceSelection: true,
54
- }
55
-
56
- c.column_config = { editor: editor_config }
57
- c.field_config = editor_config
58
- end
59
-
60
- action :do_job_run do |a|
61
- a.text = 'Run'
62
- a.tooltip = 'Run'
63
- a.icon_cls = 'fa fa-play glyph'
64
- a.disabled = true
65
- end
14
+ def prepare_warnings
15
+ djs = ::Marty::BackgroundJob::FetchMissingInScheduleCronJobs.call
66
16
 
67
- endpoint :edit_window__edit_form__submit do |params|
68
- result = super(params)
69
- next result if result.empty?
17
+ messages = djs.map do |dj|
18
+ handler_str = dj.handler[/job_class.*\n/]
19
+ job_class = handler_str.gsub('job_class:', '').strip
70
20
 
71
- obj_hash = result.first
72
- Marty::BackgroundJob::UpdateSchedule.call(id: obj_hash['id'], job_class: obj_hash['job_class'])
21
+ "#{job_class} with cron #{dj.cron} is present in delayed_jobs table, " \
22
+ 'but is missing in the Dashboard.'
23
+ end
73
24
 
74
- result
25
+ messages.join('<br>')
75
26
  end
76
27
 
77
- endpoint :add_window__add_form__submit do |params|
78
- result = super(params)
79
- next result if result.empty?
80
-
81
- obj_hash = result.first
82
- Marty::BackgroundJob::UpdateSchedule.call(id: obj_hash['id'], job_class: obj_hash['job_class'])
83
-
84
- result
28
+ client_class do |c|
29
+ c.header = false
30
+ # c.layout = :border
31
+ c.defaults = { body_style: 'padding:0px' }
85
32
  end
86
33
 
87
- endpoint :multiedit_window__multiedit_form__submit do |_params|
88
- client.netzke_notify 'Multiediting is disabled for cron schedules'
34
+ component :schedule_jobs_grid do |c|
35
+ c.klass = Marty::ScheduleJobsGrid
36
+ c.region = :north
37
+ c.min_height = 500
89
38
  end
90
39
 
91
- endpoint :destroy do |params|
92
- res = params.each_with_object({}) do |id, hash|
93
- job_class = model.find_by(id: id)&.job_class
94
- result = super([id])
95
-
96
- # Do nothing If it wasn't destroyed
97
- next hash.merge(result) unless result[id.to_i] == 'ok'
98
-
99
- Marty::BackgroundJob::UpdateSchedule.call(id: id, job_class: job_class)
100
- hash.merge(result)
101
- end
102
-
103
- res
40
+ component :schedule_jobs_warnings do |c|
41
+ c.klass = Marty::Panel
42
+ c.title = I18n.t('jobs.schedule_dashboard.warnings')
43
+ c.html = prepare_warnings
44
+ c.min_height = 200
104
45
  end
105
46
 
106
- endpoint :job_run do
107
- begin
108
- s = Marty::BackgroundJob::Schedule.find(client_config['selected'])
109
- klass = s.job_class
110
- klass.constantize.new.perform
111
- rescue StandardError => e
112
- next client.netzke_notify(e.message)
113
- end
114
- client.netzke_notify("#{klass.demodulize} ran successfully.")
47
+ def default_bbar
48
+ []
115
49
  end
116
50
  end
117
51