<% url = "#{x.root_path}morgue" %>
<header class="row">
  <div class="col-sm-5">
    <h3><%= x.t("DeadJobs") %></h3>
  </div>
  <% if dead.size > 0 && total_size > count %>
    <div class="col-sm-4">
      <%= ecr "_paging" %>
    </div>
  <% end %>
  <%= x.filtering("dead") %>
</header>

<% if dead.size > 0 %>
  <form action="<%= root_path %>morgue" method="post">
    <%= x.csrf_tag %>
    <div class="table_container">
      <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><%= x.t("LastRetry") %></th>
            <th><%= x.t("Queue") %></th>
            <th><%= x.t("Job") %></th>
            <th><%= x.t("Arguments") %></th>
            <th><%= x.t("Error") %></th>
          </tr>
        </thead>
        <% dead.each do |entry| %>
          <tr>
            <td class="table-checkbox">
              <label>
                <input type="checkbox" name="key[]" value="<%= x.job_params(entry, entry.score) %>" />
              </label>
            </td>
            <td>
              <a href="<%= x.root_path %>morgue/<%= x.job_params(entry, entry.score) %>"><%= x.relative_time(entry.at) %></a>
            </td>
            <td>
              <a href="<%= x.root_path %>queues/<%= entry.queue %>"><%= entry.queue %></a>
            </td>
            <td><%= entry.display_class %></td>
            <td>
              <div class="args"><%= x.display_args(entry.display_args) %></div>
            </td>
            <td>
              <div><%= x.h x.truncate("#{entry.error_class}: #{entry.error_message}", 200) %></div>
            </td>
          </tr>
        <% end %>
      </table>
    </div>
    <input class="btn btn-primary btn-xs pull-left" type="submit" name="retry" value="<%= x.t("RetryNow") %>" />
    <input class="btn btn-danger btn-xs pull-left" type="submit" name="delete" value="<%= x.t("Delete") %>" />
  </form>

  <form action="<%= x.root_path %>morgue/all/delete" method="post">
    <%= x.csrf_tag %>
    <input class="btn btn-danger btn-xs pull-right" type="submit" name="delete" value="<%= x.t("DeleteAll") %>" data-confirm="<%= x.t("AreYouSure") %>" />
  </form>
  <form action="<%= x.root_path %>morgue/all/retry" method="post">
    <%= x.csrf_tag %>
    <input class="btn btn-danger btn-xs pull-right" type="submit" name="retry" value="<%= x.t("RetryAll") %>" data-confirm="<%= x.t("AreYouSure") %>" />
  </form>

<% else %>
  <div class="alert alert-success"><%= x.t("NoDeadJobsFound") %></div>
<% end %>
