{% extends "base.html" %}
{% block title %}Kiln Queue Stats{% endblock title %}
{% block extra_head %}
<link rel="stylesheet" href="{{ url_for('static', filename='jquery.terminal.css') }}" />
<script type="text/javascript" src="{{ url_for('static', filename='jquery.mousewheel.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='jquery.color.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='jquery.terminal-0.3.3.min.js') }}"></script>
<script type="text/javascript">
function updateStats() {
$.get('{{ url_for("queuestats") }}', function (data, status, xhr) {
$('#table_stats tbody tr').each(function(i, e) {
tds = $(e).find('td');
key = tds.eq(0).text().trim();
value = data[key];
if (value !== undefined) {
val_cell = tds.eq(1).find('span');
if (val_cell.text().trim() != value) {
val_cell.text(value)
.clearQueue()
.css({backgroundColor: '#9ff'})
.animate({backgroundColor: '#fff'}, 2000);
}
}
});
}, 'json');
}
$(function() {
var terminal = $('#redis_term').terminal(function(cmd, term) {
if (cmd) {
term.pause();
$.post("{{ url_for('cli') }}", {cmd: cmd}, function(data, status, xhr) {
term.resume();
if (data.type === 'error') {
term.error(data.response);
}
else {
term.echo(data.response);
}
updateStats();
}, 'json');
}
}, {
greetings: '[[;#0f0;]Welcome to the Redis Interactive Shell\nType `help` for a list of commands.]',
name: 'redis_cli',
height: 600,
width: 800,
prompt: '[[;#0ff;](Redis)]',
enabled: false
});
$(window).click(function() { terminal.disable(); return false; });
$('#start_term').click(function() {
if (confirm('WARNING: Only use the Redis terminal if you really know what you are doing.\n\nAre you sure you want to continue?'))
{
$(this).attr({disabled: 'disabled'});
$('#redis_term').slideDown('normal', function() {
terminal.enable();
$(this).focus();
});
}
}).attr({disabled: false});
setInterval(updateStats, 2000);
});
</script>
{% endblock extra_head %}
{% block content %}
<h1>Kiln Queue Stats</h1>
<table id="table_stats">
<thead>
<tr>
<th align="left">Key</th>
<th align="right">Count</th>
</tr>
</thead>
<tbody>
{% for row in data|dictsort %}
<tr>
<td>{{ row[0] }}</td>
<td align="right"><span>{{ row[1] }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
<button id="start_term">Start Redis Shell</button>
<div id="redis_term" style="display: none; overflow-y: scroll; overflow-x: auto;"></div>
{% endblock content %}
|
Loading...