Hide and show 'return' columns as needed.

This commit is contained in:
Marek Majkowski 2011-02-17 15:23:08 +00:00
parent 7b16227db4
commit bbf5f91950
2 changed files with 21 additions and 3 deletions

View File

@ -109,6 +109,14 @@ function fmt_rate0(obj, name, fmt, show_total) {
return res;
}
function fmt_empty(obj, name) {
if (obj == undefined
|| obj[name] == undefined
|| obj[name + '_details'] == undefined
|| obj[name + '_details'].rate < 0.00001) return true;
return false;
}
function fmt_exchange(name) {
return name == '' ? '<i>(AMQP default)</i>' : name;
}

View File

@ -1,4 +1,8 @@
<h3><%= label %></h3>
<%
var col_return_unroutable = !fmt_empty(totals, 'return_unroutable');
var col_return_not_delivered = !fmt_empty(totals, 'return_not_delivered');
%>
<% if (object && object.length > 0) { %>
<table class="list list-with-total">
<tr>
@ -13,8 +17,10 @@
<% } %>
<th>publish</th>
<th>confirm</th>
<% if (mode == 'channel' || mode == 'exchange-incoming') { %>
<% if (col_return_unroutable) { %>
<th>return (mandatory)</th>
<% } %>
<% if (col_return_not_delivered) { %>
<th>return (immediate)</th>
<% } %>
</tr>
@ -35,8 +41,10 @@
<% } %>
<td class="r"><%= fmt_rate(pub.stats, 'publish') %></td>
<td class="r"><%= fmt_rate(pub.stats, 'confirm') %></td>
<% if (mode == 'channel' || mode == 'exchange-incoming') { %>
<% if (col_return_unroutable) { %>
<td class="r"><%= fmt_rate(pub.stats, 'return_unroutable') %></td>
<% } %>
<% if (col_return_not_delivered) { %>
<td class="r"><%= fmt_rate(pub.stats, 'return_not_delivered') %></td>
<% } %>
</tr>
@ -45,10 +53,12 @@
<th>Total:</th>
<td><span class="mini-highlight"><%= fmt_rate(totals, 'publish') %></span></td>
<td><span class="mini-highlight"><%= fmt_rate(totals, 'confirm') %></span></td>
<% if (mode == 'channel' || mode == 'exchange-incoming') { %>
<% if (col_return_unroutable) { %>
<td><span class="mini-highlight">
<%= fmt_rate(totals, 'return_unroutable') %>
</span></td>
<% } %>
<% if (col_return_not_delivered) { %>
<td><span class="mini-highlight">
<%= fmt_rate(totals, 'return_not_delivered') %>
</span></td>