forked from GithubBackups/healthchecks
More efficient log updates.
This commit is contained in:
parent
a883fe38aa
commit
ecba1eb40b
@ -386,14 +386,18 @@ def status_single(request, code):
|
|||||||
events = _get_events(check, 20)
|
events = _get_events(check, 20)
|
||||||
updated = None
|
updated = None
|
||||||
if len(events):
|
if len(events):
|
||||||
updated = events[0].created.isoformat()
|
updated = events[0].created.replace(tzinfo=None).isoformat()
|
||||||
|
|
||||||
return JsonResponse({
|
doc = {
|
||||||
"status": status,
|
"status": status,
|
||||||
"status_text": STATUS_TEXT_TMPL.render({"check": check}),
|
"status_text": STATUS_TEXT_TMPL.render({"check": check}),
|
||||||
"events": EVENTS_TMPL.render({"check": check, "events": events}),
|
|
||||||
"updated": updated
|
"updated": updated
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if updated != request.GET.get("u"):
|
||||||
|
doc["events"] = EVENTS_TMPL.render({"check": check, "events": events})
|
||||||
|
|
||||||
|
return JsonResponse(doc)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -30,7 +30,7 @@ $(function () {
|
|||||||
var lastUpdated = "";
|
var lastUpdated = "";
|
||||||
adaptiveSetInterval(function() {
|
adaptiveSetInterval(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: statusUrl,
|
url: statusUrl + (lastUpdated ? "?u=" + lastUpdated : ""),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
@ -40,7 +40,7 @@ $(function () {
|
|||||||
$("#log-status-text").text(data.status_text);
|
$("#log-status-text").text(data.status_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.updated != lastUpdated) {
|
if (data.events) {
|
||||||
lastUpdated = data.updated;
|
lastUpdated = data.updated;
|
||||||
$("#events").html(data.events);
|
$("#events").html(data.events);
|
||||||
switchDateFormat(lastFormat);
|
switchDateFormat(lastFormat);
|
||||||
@ -67,7 +67,7 @@ $(function () {
|
|||||||
prompt("Press Ctrl+C to select:", text)
|
prompt("Press Ctrl+C to select:", text)
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#log tr.ok").on("click", function() {
|
$("#events").on("click", "tr.ok", function() {
|
||||||
$("#ping-details-body").text("Updating...");
|
$("#ping-details-body").text("Updating...");
|
||||||
$('#ping-details-modal').modal("show");
|
$('#ping-details-modal').modal("show");
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div id="log-container">
|
|
||||||
<table class="table" id="log">
|
<table class="table" id="log">
|
||||||
{% for event in events %}
|
{% for event in events %}
|
||||||
{% if event.n %}
|
{% if event.n %}
|
||||||
@ -103,7 +102,6 @@
|
|||||||
<a href="{% url 'hc-log' check.code %}">Show More…</a>
|
<a href="{% url 'hc-log' check.code %}">Show More…</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<h2>Log</h2>
|
<h2>Log</h2>
|
||||||
<div class="alert alert-info">This check has not received any pings yet.</div>
|
<div class="alert alert-info">This check has not received any pings yet.</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user