Update document.title

This commit is contained in:
Pēteris Caune 2018-08-19 13:33:21 +03:00
parent 8fa9a6f3f6
commit 8ab8e15c4e
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
4 changed files with 17 additions and 2 deletions

View File

@ -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:

View File

@ -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
}

View File

@ -45,6 +45,10 @@ $(function () {
$("#log-container").html(data.events);
switchDateFormat(lastFormat);
}
if (document.title != data.title) {
document.title = data.title;
}
}
});
}, true);

View File

@ -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 %}