<% if (channels.length > 0) { %>
<%
     var col_return_unroutable = !is_col_empty(channels, 'return_unroutable');
     var col_redeliver = !is_col_empty(channels, 'redeliver');
     var ratesWidth = col_return_unroutable ? 5 : 4;
%>
<table class="list">
 <thead>
  <tr>
<% if (mode == 'standalone') { %>
   <th colspan="<% if (nodes_interesting) { %>2<% } else { %>1<% } %>"></th>
   <th colspan="<% if (vhosts_interesting) { %>7<% } else { %>6<% } %>">Details</th>
<% } else { %>
   <th></th>
   <th colspan="5">Details</th>
<% } %>
<% if (statistics_level == 'fine') { %>
   <th colspan="<%= ratesWidth %>">Message rates</th>
<% } %>
  </tr>
  <tr>
<% if (mode == 'standalone') { %>
    <th><%= fmt_sort('Channel',         'name') %></th>
<% if (nodes_interesting) { %>
    <th><%= fmt_sort('Node',            'node') %></th>
<% } %>
<% if (vhosts_interesting) { %>
    <th><%= fmt_sort('Virtual host',    'vhost') %></th>
<% } %>
    <th><%= fmt_sort('User name',       'user') %></th>
    <th>Mode <span class="help" id="channel-mode"></span></th>
    <th><%= fmt_sort('Prefetch',        'prefetch_count') %></th>
    <th><%= fmt_sort('Unacked',         'messages_unacknowledged') %></th>
    <th><%= fmt_sort('Unconfirmed',     'messages_unconfirmed') %></th>
    <th><%= fmt_sort('Status',          'idle_since') %></th>
<% if (statistics_level == 'fine') { %>
    <th><%= fmt_sort('publish', 'message_stats.publish_details.rate') %></th>
    <th><%= fmt_sort('confirm', 'message_stats.confirm_details.rate') %></th>
    <th>
      <%= fmt_sort('deliver / get', 'message_stats.deliver_get_details.rate') %>
      <% if (col_redeliver) { %>
        <sub><%= fmt_sort('of which redelivered', 'message_stats.redeliver_details.rate') %></sub>
      <% } %>
    </th>
    <th><%= fmt_sort('ack', 'message_stats.ack_details.rate') %></th>
    <% if (col_return_unroutable) { %>
        <th><%= fmt_sort('return (mandatory)', 'message_stats.return_unroutable_details.rate') %></th>
    <% } %>
<% } %>
<% } else { %>
<!-- TODO make sortable after bug 23401 -->
    <th>Channel</th>
    <th>Mode <span class="help" id="channel-mode"></span></th>
    <th>Prefetch</th>
    <th>Unacked</th>
    <th>Unconfirmed</th>
    <th>Status</th>
<% if (statistics_level == 'fine') { %>
    <th>publish</th>
    <th>confirm</th>
    <th>
      deliver / get
      <% if (col_redeliver) { %>
        <sub>of which redelivered</sub>
        <% } %>
    </th>
    <th>ack</th>
    <% if (col_return_unroutable) { %>
        <th>return (mandatory)</th>
    <% } %>
<% } %>
<% } %>
  </tr>
 </thead>
 <tbody>
<%
  for (var i = 0; i < channels.length; i++) {
    var channel = channels[i];
%>
  <tr<%= alt_rows(i)%>>
    <td>
      <%= link_channel(channel.name) %>
    </td>
<% if (mode == 'standalone' && nodes_interesting) { %>
    <td><%= fmt_node(channel.node) %></td>
<% } %>
<% if (mode == 'standalone') { %>
<% if (vhosts_interesting) { %>
    <td class="c"><%= fmt_string(channel.vhost) %></td>
<% } %>
    <td class="c"><%= fmt_string(channel.user) %></td>
<% } %>
    <td class="l">
      <%= fmt_channel_mode(channel) %>
      <% if (channel.transactional) { %>
      <small><acronym title="<%= channel.messages_uncommitted %> uncommitted messages"><%= channel.messages_uncommitted %>m</acronym>/<acronym title="<%= channel.acks_uncommitted %> uncommitted acks"><%= channel.acks_uncommitted %>a</acronym></small>
      <% } %>
    </td>
    <td class="c"><%= channel.prefetch_count %></td>
    <td class="c"><%= channel.messages_unacknowledged %></td>
    <td class="c"><%= channel.messages_unconfirmed %></td>
    <td class="c"><%= fmt_idle(channel) %></td>
<% if (statistics_level == 'fine') { %>
    <td class="r"><%= fmt_rate(channel.message_stats, 'publish') %></td>
    <td class="r"><%= fmt_rate(channel.message_stats, 'confirm') %></td>
    <td class="r"><%= fmt_deliver_rate(channel.message_stats, col_redeliver) %></td>
    <td class="r"><%= fmt_rate(channel.message_stats, 'ack') %></td>
    <% if (col_return_unroutable) { %>
    <td class="r"><%= fmt_rate(channel.message_stats, 'return_unroutable') %></td>
    <% } %>
<% } %>
  </tr>
  <% } %>
 </tbody>
</table>
<% } else { %>
  <p>... no channels ...</p>
<% } %>
