diff --git a/hc/front/templatetags/hc_extras.py b/hc/front/templatetags/hc_extras.py index 41634b58..d3d62026 100644 --- a/hc/front/templatetags/hc_extras.py +++ b/hc/front/templatetags/hc_extras.py @@ -82,6 +82,15 @@ def num_down_title(num_down): else: return settings.SITE_NAME + +@register.filter +def down_title(check): + s = "%s – %s" % (check.name_then_code(), settings.SITE_NAME) + if check.get_status() == "down": + s = "DOWN – " + s + return s + + @register.filter def break_underscore(s): if len(s) > 30: diff --git a/hc/front/views.py b/hc/front/views.py index 25c22381..361079fd 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -24,7 +24,8 @@ from hc.front.forms import (AddWebhookForm, NameTagsForm, TimeoutForm, AddUrlForm, AddEmailForm, AddOpsGenieForm, CronForm, AddSmsForm) from hc.front.schemas import telegram_callback -from hc.front.templatetags.hc_extras import num_down_title, sortchecks +from hc.front.templatetags.hc_extras import (num_down_title, down_title, + sortchecks) from hc.lib import jsonschema from pytz import all_timezones from pytz.exceptions import UnknownTimeZoneError @@ -391,6 +392,7 @@ def status_single(request, code): doc = { "status": status, "status_text": STATUS_TEXT_TMPL.render({"check": check}), + "title": down_title(check), "updated": updated } diff --git a/static/js/details.js b/static/js/details.js index 9dd872ba..6c6befd7 100644 --- a/static/js/details.js +++ b/static/js/details.js @@ -45,6 +45,10 @@ $(function () { $("#log-container").html(data.events); switchDateFormat(lastFormat); } + + if (document.title != data.title) { + document.title = data.title; + } } }); }, true); diff --git a/templates/front/details.html b/templates/front/details.html index bce0507e..9b4f63f0 100644 --- a/templates/front/details.html +++ b/templates/front/details.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% load compress humanize static hc_extras %} -{% block title %}My Checks - {% site_name %}{% endblock %} +{% block title %}{{ check|down_title }}{% endblock %} {% block content %}