Merge default
This commit is contained in:
		
						commit
						07a29d4dbf
					
				| 
						 | 
				
			
			@ -33,6 +33,7 @@
 | 
			
		|||
          <li><a href="#/queues">Queues</a></li>
 | 
			
		||||
          <li class="administrator-only"><a href="#/users">Users</a></li>
 | 
			
		||||
          <li class="administrator-only"><a href="#/vhosts">Virtual Hosts</a></li>
 | 
			
		||||
          <li class="administrator-only"><a href="#/policies">Policies</a></li>
 | 
			
		||||
        </ul>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -153,6 +153,21 @@ dispatcher_add(function(sammy) {
 | 
			
		|||
                update();
 | 
			
		||||
            return false;
 | 
			
		||||
        });
 | 
			
		||||
    path('#/policies', {'policies': '/parameters/policy'}, 'policies');
 | 
			
		||||
    sammy.get('#/policies/:id', function() {
 | 
			
		||||
            render({'policy': '/parameters/policy/' + esc(this.params['id'])},
 | 
			
		||||
                'policy', '#/policies');
 | 
			
		||||
        });
 | 
			
		||||
    sammy.put('#/policies', function() {
 | 
			
		||||
            put_parameter(this, ['prefix'], []);
 | 
			
		||||
            return false;
 | 
			
		||||
        });
 | 
			
		||||
    sammy.del('#/policies', function() {
 | 
			
		||||
            if (sync_delete(this, '/parameters/:component/:key'))
 | 
			
		||||
                go_to('#/policies');
 | 
			
		||||
            return false;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
    sammy.get('#/import-succeeded', function() {
 | 
			
		||||
            render({}, 'import-succeeded', '#/overview');
 | 
			
		||||
        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -210,6 +210,10 @@ function fmt_exchange_type(type) {
 | 
			
		|||
        '</acronym></div>';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function fmt_policy(policy) {
 | 
			
		||||
    return policy == 'none' ? '' : fmt_escape_html(policy);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function fmt_exchange_url(name) {
 | 
			
		||||
    return name == '' ? 'amq.default' : fmt_escape_html(name);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -455,6 +459,10 @@ function link_node(name) {
 | 
			
		|||
    return _link_to(fmt_escape_html(name), '#/nodes/' + esc(name))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function link_policy(name) {
 | 
			
		||||
    return _link_to(fmt_escape_html(name), '#/policies/' + esc(name))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function _link_to(name, url) {
 | 
			
		||||
    return '<a href="' + url + '">' + name + '</a>';
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -692,6 +692,26 @@ function maybe_remove_fields(params) {
 | 
			
		|||
    return params;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function put_parameter(sammy, mandatory_keys, num_keys) {
 | 
			
		||||
    for (var i in sammy.params) {
 | 
			
		||||
        if (i === 'length' || !sammy.params.hasOwnProperty(i)) continue;
 | 
			
		||||
        if (sammy.params[i] == '' && mandatory_keys.indexOf(i) == -1) {
 | 
			
		||||
            delete sammy.params[i];
 | 
			
		||||
        }
 | 
			
		||||
        else if (num_keys.indexOf(i) != -1) {
 | 
			
		||||
            sammy.params[i] = parseInt(sammy.params[i]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    var params = {"component": sammy.params.component,
 | 
			
		||||
                  "key":       sammy.params.key,
 | 
			
		||||
                  "value":     params_magic(sammy.params)};
 | 
			
		||||
    delete params.value.component;
 | 
			
		||||
    delete params.value.key;
 | 
			
		||||
    sammy.params = params;
 | 
			
		||||
    if (sync_put(sammy, '/parameters/:component/:key')) update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function debug(str) {
 | 
			
		||||
    $('<p>' + str + '</p>').appendTo('#debug');
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,10 @@
 | 
			
		|||
        <th>Parameters</th>
 | 
			
		||||
        <td><%= fmt_parameters(exchange) %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Policy</th>
 | 
			
		||||
        <td><%= fmt_policy(exchange.policy) %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
<% if (vhosts_interesting) { %>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Virtual host</th>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@
 | 
			
		|||
<% } %>
 | 
			
		||||
   <th><%= fmt_sort('Name',         'name') %></th>
 | 
			
		||||
   <th><%= fmt_sort('Type',         'type') %></th>
 | 
			
		||||
   <th><%= fmt_sort('Policy',       'policy') %></th>
 | 
			
		||||
   <th>Parameters</th>
 | 
			
		||||
<% if (statistics_level == 'fine') { %>
 | 
			
		||||
   <th><%= fmt_sort('Message rate',   'message_stats_in.publish_details.rate') %></th>
 | 
			
		||||
| 
						 | 
				
			
			@ -28,6 +29,7 @@
 | 
			
		|||
<% } %>
 | 
			
		||||
   <td><%= link_exchange(exchange.vhost, exchange.name) %></td>
 | 
			
		||||
   <td class="status c"><%= fmt_exchange_type(exchange.type) %></td>
 | 
			
		||||
   <td class="c"><%= fmt_policy(exchange.policy) %></td>
 | 
			
		||||
   <td class="c"><%= fmt_parameters_short(exchange) %></td>
 | 
			
		||||
   <td class="r"><%= fmt_rate(exchange.message_stats_in, 'publish', false) %></td>
 | 
			
		||||
  </tr>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
<h1>Policies</h1>
 | 
			
		||||
<div class="section">
 | 
			
		||||
  <h2>All policies</h2>
 | 
			
		||||
  <div class="hider">
 | 
			
		||||
    <div class="updatable">
 | 
			
		||||
 | 
			
		||||
<% if (policies.length > 0) { %>
 | 
			
		||||
<table class="list">
 | 
			
		||||
 <thead>
 | 
			
		||||
  <tr>
 | 
			
		||||
    <th>Name</th>
 | 
			
		||||
    <th>Virtual Host</th>
 | 
			
		||||
    <th>Prefix</th>
 | 
			
		||||
    <th>Policy</th>
 | 
			
		||||
  </tr>
 | 
			
		||||
 </thead>
 | 
			
		||||
 <tbody>
 | 
			
		||||
<%
 | 
			
		||||
 for (var i = 0; i < policies.length; i++) {
 | 
			
		||||
    var policy = policies[i];
 | 
			
		||||
%>
 | 
			
		||||
   <tr<%= alt_rows(i)%>>
 | 
			
		||||
     <td><%= link_policy(policy.key) %></td>
 | 
			
		||||
     <td><%= policy.value['vhost'] %></td>
 | 
			
		||||
     <td><%= policy.value['prefix'] %></td>
 | 
			
		||||
     <td><%= fmt_table_short(policy.value['policy']) %></td>
 | 
			
		||||
   </tr>
 | 
			
		||||
<% } %>
 | 
			
		||||
 </tbody>
 | 
			
		||||
</table>
 | 
			
		||||
<% } else { %>
 | 
			
		||||
  <p>... no policies ...</p>
 | 
			
		||||
<% } %>
 | 
			
		||||
    </div>
 | 
			
		||||
    <h3>Add / update a policy</h3>
 | 
			
		||||
    <form action="#/policies" method="put">
 | 
			
		||||
      <input type="hidden" name="component" value="policy"/>
 | 
			
		||||
      <table class="form">
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th><label>Name:</label></th>
 | 
			
		||||
          <td><input type="text" name="key"/><span class="mand">*</span></td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th><label>Prefix:</label></th>
 | 
			
		||||
          <td><input type="text" name="prefix"/></td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th><label>Virtual host:</label></th>
 | 
			
		||||
          <td><input type="text" name="vhost"/></td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th><label>Policy:</label></th>
 | 
			
		||||
          <td><span class="multifield" id="policy"></span></td>
 | 
			
		||||
        </tr>
 | 
			
		||||
      </table>
 | 
			
		||||
      <input type="submit" value="Add policy"/>
 | 
			
		||||
    </form>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
<h1>Policy: <b><%= fmt_string(policy.key) %></b></h1>
 | 
			
		||||
 | 
			
		||||
<div class="section">
 | 
			
		||||
  <h2>Overview</h2>
 | 
			
		||||
  <div class="hider">
 | 
			
		||||
    <table class="facts">
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Virtual Host</th>
 | 
			
		||||
        <td><%= policy.value.vhost %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Prefix</th>
 | 
			
		||||
        <td><%= policy.value.prefix %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Policy</th>
 | 
			
		||||
        <td><%= fmt_table_short(policy.value.policy) %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<div class="section-hidden">
 | 
			
		||||
  <h2>Delete this policy</h2>
 | 
			
		||||
  <div class="hider">
 | 
			
		||||
    <form action="#/policies" method="delete" class="confirm">
 | 
			
		||||
      <input type="hidden" name="component" value="policy"/>
 | 
			
		||||
      <input type="hidden" name="key" value="<%= fmt_string(policy.key) %>"/>
 | 
			
		||||
      <input type="submit" value="Delete this policy"/>
 | 
			
		||||
    </form>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +16,10 @@
 | 
			
		|||
        <th>Parameters</th>
 | 
			
		||||
        <td><%= fmt_parameters(queue) %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Policy</th>
 | 
			
		||||
        <td><%= fmt_policy(queue.policy) %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Exclusive owner</th>
 | 
			
		||||
        <td>
 | 
			
		||||
| 
						 | 
				
			
			@ -26,13 +30,13 @@
 | 
			
		|||
          <% } %>
 | 
			
		||||
        </td>
 | 
			
		||||
      </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
 | 
			
		||||
    <table class="facts">
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Status</th>
 | 
			
		||||
        <td><%= fmt_idle_long(queue) %></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
 | 
			
		||||
    <table class="facts">
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th>Consumers</th>
 | 
			
		||||
        <td><%= fmt_string(queue.consumers) %></td>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@
 | 
			
		|||
<table class="list">
 | 
			
		||||
 <thead>
 | 
			
		||||
  <tr>
 | 
			
		||||
    <th colspan="<% if (nodes_interesting && vhosts_interesting) { %>6<% } else if (nodes_interesting || vhosts_interesting) { %>5<% } else { %>4<% } %>">Overview</th>
 | 
			
		||||
    <th colspan="<% if (nodes_interesting && vhosts_interesting) { %>7<% } else if (nodes_interesting || vhosts_interesting) { %>6<% } else { %>5<% } %>">Overview</th>
 | 
			
		||||
    <th colspan="3">Messages</th>
 | 
			
		||||
<% if (statistics_level == 'fine') { %>
 | 
			
		||||
    <th colspan="3">Message rates</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
<% } %>
 | 
			
		||||
    <th><%= fmt_sort('Exclusive',    'owner_pid_details.name') %></th>
 | 
			
		||||
    <th>Parameters</th>
 | 
			
		||||
    <th><%= fmt_sort('Policy',       'policy') %></th>
 | 
			
		||||
    <th><%= fmt_sort('Status',       'idle_since') %></th>
 | 
			
		||||
    <th><%= fmt_sort('Ready',        'messages_ready') %></th>
 | 
			
		||||
    <th><%= fmt_sort('Unacked',      'messages_unacknowledged') %></th>
 | 
			
		||||
| 
						 | 
				
			
			@ -62,9 +63,8 @@
 | 
			
		|||
     <%= link_conn(queue.owner_pid_details.name) %>
 | 
			
		||||
     <% } %>
 | 
			
		||||
   </td>
 | 
			
		||||
   <td class="c">
 | 
			
		||||
     <%= fmt_parameters_short(queue) %>
 | 
			
		||||
   </td>
 | 
			
		||||
   <td class="c"><%= fmt_parameters_short(queue) %></td>
 | 
			
		||||
   <td class="c"><%= fmt_policy(queue.policy) %></td>
 | 
			
		||||
   <td class="c"><%= fmt_idle(queue) %></td>
 | 
			
		||||
   <td class="r"><%= fmt_string(queue.messages_ready) %></td>
 | 
			
		||||
   <td class="r"><%= fmt_string(queue.messages_unacknowledged) %></td>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -265,14 +265,16 @@ queue(#amqqueue{name            = Name,
 | 
			
		|||
                auto_delete     = AutoDelete,
 | 
			
		||||
                exclusive_owner = ExclusiveOwner,
 | 
			
		||||
                arguments       = Arguments,
 | 
			
		||||
                pid             = Pid }) ->
 | 
			
		||||
                pid             = Pid,
 | 
			
		||||
                policy          = Policy} = Q) ->
 | 
			
		||||
    format(
 | 
			
		||||
      [{name,        Name},
 | 
			
		||||
       {durable,     Durable},
 | 
			
		||||
       {auto_delete, AutoDelete},
 | 
			
		||||
       {owner_pid,   ExclusiveOwner},
 | 
			
		||||
       {arguments,   Arguments},
 | 
			
		||||
       {pid,         Pid}],
 | 
			
		||||
       {pid,         Pid},
 | 
			
		||||
       {policy,      rabbit_policy:name(Q)}],
 | 
			
		||||
      [{fun resource/1,     [name]},
 | 
			
		||||
       {fun amqp_table/1,   [arguments]}]).
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue