Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhances status page to show all keys in status hash #60

Merged
merged 1 commit into from Apr 9, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions lib/resque/server/views/status.erb
Expand Up @@ -10,6 +10,19 @@
</div>
<div class="status-message"><%= @status.message %></div>
<div class="status-time"><%= @status.time? ? @status.time : 'Not started' %></div>
<h2>Details</h2>
<div class="status-details">
<table>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody class="status-details-body">
</tbody>
</table>
</div>
</div>

<script type="text/javascript" charset="utf-8">
Expand Down Expand Up @@ -43,6 +56,15 @@
if (json.time) {
$status.find('.status-time').text(new Date(json.time * 1000).toString())
}

var $details = $status.find('.status-details-body');
$details.empty();

for (key in json) {
var $row = $("<tr>").appendTo($details);
$("<td>").text(key).appendTo($row);
$("<td>").text(printValue(key, json[key])).appendTo($row);
}
};
var status = $status.attr('rel');
if (status == 'working' || status == 'queued' || status == "") {
Expand All @@ -53,5 +75,15 @@
});
};

function printValue(key, value) {
if (/(^|_)time$/.test(key) && typeof value == 'number') {
var time = new Date();
time.setTime(value * 1000);
return time.toUTCString();
} else {
return JSON.stringify(value);
}
}

});
</script>