Sha256: 0c2ad6afaa25b7a6ee8a36a7a07455eda550daeca0022e844a8009835a9522ac

Contents?: true

Size: 917 Bytes

Versions: 3

Compression:

Stored size: 917 Bytes

Contents

module RocketJobMissionControl
  class RunningJobsDatatable < JobsDatatable
    private

    def data
      jobs.map do |job|
        {
          '0' => class_with_link(job),
          '1' => h(job.description.try(:truncate, 50)),
          '2' => progress(job),
          '3' => h(job.priority),
          '4' => h(started(job)),
          'DT_RowClass' => "card callout callout-#{job.state}"
        }
      end
    end

    def sort_column(index)
      columns = %w[_type description percent_complete priority started_at]
      columns[index.to_i]
    end

    def progress(job)
      <<-EOS
        <div class='progress'>
          <div class='progress-bar' style="width: #{job.percent_complete}%;", title="#{job.percent_complete}% complete."></div>
        </div>
      EOS
    end

    def started(job)
      "#{RocketJob.seconds_as_duration(Time.now - job.started_at)} ago" if job.started_at
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rocketjob_mission_control-2.0.0 app/datatables/rocket_job_mission_control/running_jobs_datatable.rb
rocketjob_mission_control-2.0.0.rc2 app/datatables/rocket_job_mission_control/running_jobs_datatable.rb
rocketjob_mission_control-2.0.0.rc1 app/datatables/rocket_job_mission_control/running_jobs_datatable.rb