Sha256: b64e9a53a8b87c5ae8f1f74b4aca73a89bfc773d90922214b2e6e458d7ef2bf6

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'marty/schedule_jobs_grid'

class Marty::ScheduleJobsDashboard < Marty::Form
  include Marty::Extras::Layout

  def configure(c)
    super
    c.items = [
      :schedule_jobs_grid,
      :schedule_jobs_warnings
    ]
  end

  def prepare_warnings
    djs = ::Marty::BackgroundJob::FetchMissingInScheduleCronJobs.call

    messages = djs.map do |dj|
      handler_str = dj.handler[/job_class.*\n/]
      job_class = handler_str.gsub('job_class:', '').strip

      "#{job_class} with cron #{dj.cron} is present in delayed_jobs table, " \
        'but is missing in the Dashboard.'
    end

    messages.join('<br>')
  end

  client_class do |c|
    c.header   = false
    # c.layout   = :border
    c.defaults = { body_style: 'padding:0px' }
  end

  component :schedule_jobs_grid do |c|
    c.klass = Marty::ScheduleJobsGrid
    c.region = :north
    c.min_height = 500
  end

  component :schedule_jobs_warnings do |c|
    c.klass = Marty::Panel
    c.title = I18n.t('jobs.schedule_dashboard.warnings')
    c.html = prepare_warnings
    c.min_height = 200
  end

  def default_bbar
    []
  end
end

ScheduleJobsDashboard = Marty::ScheduleJobsDashboard

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marty-8.3.1 app/components/marty/schedule_jobs_dashboard.rb
marty-8.2.0 app/components/marty/schedule_jobs_dashboard.rb
marty-8.0.0 app/components/marty/schedule_jobs_dashboard.rb