ThomasKoppensteiner/sidekiq-undertaker

View on GitHub
web/views/morgue.erb

Summary

Maintainability
Test Coverage
<header class="row head">
  <div class="col-sm-12">
    <h3>
      <%= "<b>#{@total_dead}</b> dead #{@total_dead == 1 ? 'job' : 'jobs'}" %>
      <%= " of <b>#{@req_job_class}</b> class" unless @req_job_class == "all" %>
      <%= " with <b>#{@req_error_class}</b> exception" unless @req_error_class == "all" %>
      <%= " with <b>#{@req_error_msg}</b> message" unless @req_error_msg == "all" %>
      <%= " in <b>#{@req_bucket_name}</b> bucket"  %>
    </h3>
  </div>
  <div class="col-sm-12">
    <div class="col-sm-4">
      <%= erb :_paging, :locals => { :url => "#{root_path}" + @undertaker_path } %>
    </div>
  </div>
</header>

<% if @dead_jobs.size > 0 %>
    <form action="<%= "#{root_path}undertaker/morgue" %>" method="post">
      <%= respond_to?(:csrf_tag) && csrf_tag %>
      <table class="table table-striped table-bordered table-white">
        <thead>
          <tr>
            <th width="20px" class="table-checkbox">
              <label>
                <input type="checkbox" class="check_all" />
              </label>
            </th>
            <th width="25%"><%= t('LastRetry') %></th>
            <th><%= t('Queue') %></th>
            <th><%= t('Job') %></th>
            <th><%= t('Arguments') %></th>
            <th><%= t('Error') %></th>
          </tr>
        </thead>
        <% @dead_jobs.each do |entry| %>
          <tr>
            <td class="table-checkbox">
              <label>
                <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' />
              </label>
            </td>
            <td>
              <a href="<%= root_path %>morgue/<%= job_params(entry.item, entry.score) %>"><%= relative_time(entry.at) %></a>
            </td>
            <td>
              <a href="<%= root_path %>queues/<%= entry.queue %>"><%= entry.queue %></a>
            </td>
            <td><%= entry.klass %></td>
            <td>
              <div class="args"><%= display_args(entry.args) %></div>
            </td>
            <td>
              <div><%= h truncate("#{entry['error_class']}: #{entry['error_message']}", 200) %></div>
            </td>
          </tr>
        <% end %>
      </table>
      <input class="btn btn-primary btn-xs pull-left" type="submit" name="retry" value="<%= t('UndertakerRevive') %>" />
      <input class="btn btn-secondary btn-xs pull-left" type="submit" name="export" value="<%= t('UndertakerExport') %>" />
      <input class="btn btn-danger btn-xs pull-left" type="submit" name="delete" value="<%= t('UndertakerBury') %>" />
    </form>

    <form action="<%= "#{root_path}undertaker/morgue/#{@req_job_class}/#{@req_error_class}/#{Base64.urlsafe_encode64(@req_error_msg)}/#{@req_bucket_name}/delete" %>" method="post">
      <%= respond_to?(:csrf_tag) && csrf_tag %>
      <input class="btn btn-danger btn-xs pull-right" type="submit" name="delete" value="<%= t('UndertakerBuryAll') %>" data-confirm="<%= t('AreYouSure') %>" />
    </form>

    <form action="<%= "#{root_path}undertaker/morgue/#{@req_job_class}/#{@req_error_class}/#{Base64.urlsafe_encode64(@req_error_msg)}/#{@req_bucket_name}/export" %>" method="post">
      <%= respond_to?(:csrf_tag) && csrf_tag %>
      <input class="btn btn-secondary btn-xs pull-right" type="submit" name="export" value="<%= t('UndertakerExportAll') %>" />
    </form>

    <form action="<%= "#{root_path}undertaker/morgue/#{@req_job_class}/#{@req_error_class}/#{Base64.urlsafe_encode64(@req_error_msg)}/#{@req_bucket_name}/retry" %>" method="post">
      <%= respond_to?(:csrf_tag) && csrf_tag %>
      <input class="btn btn-danger btn-xs pull-right" type="submit" name="retry" value="<%= t('UndertakerReviveAll') %>" data-confirm="<%= t('AreYouSure') %>" />
    </form>
<% else %>
    <div class="alert alert-success"><%= t('NoDeadJobsFound') %></div>
<% end %>