Sha256: 0a4c5847ec684121676c36c8c5f22d4e3e484ce645130c0ba94f6bf139438821

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

module RocketJobMissionControl
  module JobsHelper
    def job_icon(job)
      state = job_state(job)
      state_icon(state)
    end

    def job_state(job)
      if job.scheduled?
        :scheduled
      elsif job.sleeping?
        :sleeping
      else
        job.state
      end
    end

    def job_states
      @job_states ||= RocketJob::Job.aasm.states.map { |state| state.name.to_s }
    end

    def job_states_with_scheduled
      @job_states_with_scheduled ||= ["scheduled"] + job_states
    end

    def job_counts_by_state(state)
      @job_counts ||= begin
        counts          = RocketJob::Job.counts_by_state
        counts[:queued] = counts[:queued_now] || 0
        counts
      end
      @job_counts.fetch(state.downcase.to_sym, 0)
    end

    def job_action_link(action, path, http_method = :get)
      link_to(
        action,
        path,
        method: http_method,
        title:  "#{action} job",
        class:  "btn btn-default",
        data:   {confirm: t(:confirm, scope: %i[job action], action: action)}
      )
    end

    def job_action_links_for_show(action, path, http_method = :get)
      link_to(
        action,
        path,
        method: http_method,
        title:  "#{action} job",
        class:  "btn btn-primary",
        data:   {confirm: t(:confirm, scope: %i[job action], action: action)}
      )
    end

    def job_selected_class(job, selected_job)
      if selected_job.present? && job.id == selected_job.id
        "selected"
      else
        ""
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rocketjob_mission_control-5.0.1 app/helpers/rocket_job_mission_control/jobs_helper.rb
rocketjob_mission_control-5.0.0 app/helpers/rocket_job_mission_control/jobs_helper.rb
rocketjob_mission_control-5.0.0.beta1 app/helpers/rocket_job_mission_control/jobs_helper.rb