<% @subtabs = resque.queues unless partial? || params[:id].nil? %>

<% if queue = params[:id] %>

  <h1>Pending jobs on <span class='hl'><%= queue %></span></h1>
  <form method="POST" action="<%=u "/queues/#{queue}/remove" %>" class='remove-queue'>
    <input type='submit' name='' value='Remove Queue' onclick='return confirm("Are you absolutely sure? This cannot be undone.");' />
  </form>
  <p class='sub'>Showing <%= start = params[:start].to_i %> to <%= start + 20 %> of <b><%=size = resque.size(queue)%></b> jobs</p>
  <table class='jobs'>
    <tr>
      <th>Class</th>
      <th>Args</th>
    </tr>
    <% for job in (jobs = resque.peek(queue, start, 20)) %>
    <tr>
      <td class='class'><%= job['class'] %></td>
      <td class='args'><%=h job['args'].inspect %></td>
    </tr>
    <% end %>
    <% if jobs.empty? %>
    <tr>
      <td class='no-data' colspan='2'>There are no pending jobs in this queue</td>
    </tr>
    <% end %>
  </table>
  <%= partial :next_more, :start => start, :size => size %>
<% else %>

  <h1 class='wi'>Queues</h1>
  <p class='intro'>The list below contains all the registered queues with the number of jobs currently in the queue. Select a queue from above to view all jobs currently pending on the queue.</p>
  <table class='queues'>
    <tr>
      <th>Name</th>
      <th>Jobs</th>
    </tr>
    <% for queue in resque.queues.sort_by { |q| q.to_s } %>
    <tr>
      <td class='queue'><a class="queue" href="<%= u "queues/#{queue}" %>"><%= queue %></a></td>
      <td class='size'><%= resque.size queue %></td>
    </tr>
    <% end %>
    <tr class="<%= Resque::Failure.count.zero? ? "failed" : "failure" %>">
      <td class='queue failed'><a class="queue" href="<%= u :failed %>">failed</a></td>
      <td class='size'><%= Resque::Failure.count %></td>
    </tr>
  </table>

<% end %>
