diff --git a/hc/front/views.py b/hc/front/views.py index 7c01173e..a1dadbd1 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -386,14 +386,18 @@ def status_single(request, code): events = _get_events(check, 20) updated = None if len(events): - updated = events[0].created.isoformat() + updated = events[0].created.replace(tzinfo=None).isoformat() - return JsonResponse({ + doc = { "status": status, "status_text": STATUS_TEXT_TMPL.render({"check": check}), - "events": EVENTS_TMPL.render({"check": check, "events": events}), "updated": updated - }) + } + + if updated != request.GET.get("u"): + doc["events"] = EVENTS_TMPL.render({"check": check, "events": events}) + + return JsonResponse(doc) @login_required diff --git a/static/js/details.js b/static/js/details.js index e192884c..15ce68ae 100644 --- a/static/js/details.js +++ b/static/js/details.js @@ -30,7 +30,7 @@ $(function () { var lastUpdated = ""; adaptiveSetInterval(function() { $.ajax({ - url: statusUrl, + url: statusUrl + (lastUpdated ? "?u=" + lastUpdated : ""), dataType: "json", timeout: 2000, success: function(data) { @@ -40,7 +40,7 @@ $(function () { $("#log-status-text").text(data.status_text); } - if (data.updated != lastUpdated) { + if (data.events) { lastUpdated = data.updated; $("#events").html(data.events); switchDateFormat(lastFormat); @@ -67,7 +67,7 @@ $(function () { 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-modal').modal("show"); diff --git a/templates/front/details_events.html b/templates/front/details_events.html index c467f30d..99f7e0b7 100644 --- a/templates/front/details_events.html +++ b/templates/front/details_events.html @@ -16,94 +16,92 @@ -
- #{{ event.n }} - | -- | - | - {% if event.fail %} - Failure - {% else %} - OK - {% endif %} - | -
-
- {% if event.scheme == "email" %}
- {{ event.ua }}
-
- {% if event.body %}
- - {{ event.body|trunc }}
- {% endif %}
-
- {% else %}
- {{ event.scheme|upper }}
- {{ event.method }}
- {% if event.remote_addr %}
- from {{ event.remote_addr }}
+
+ Error: {{ event.error }} + {% endif %} + |
+
- Show More… -
- {% endif %} -+ Show More… +
+ {% endif %} {% else %}