Browse Source

Update document.title

pull/193/head
Pēteris Caune 6 years ago
parent
commit
8ab8e15c4e
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 17 additions and 2 deletions
  1. +9
    -0
      hc/front/templatetags/hc_extras.py
  2. +3
    -1
      hc/front/views.py
  3. +4
    -0
      static/js/details.js
  4. +1
    -1
      templates/front/details.html

+ 9
- 0
hc/front/templatetags/hc_extras.py View File

@ -82,6 +82,15 @@ def num_down_title(num_down):
else: else:
return settings.SITE_NAME 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 @register.filter
def break_underscore(s): def break_underscore(s):
if len(s) > 30: if len(s) > 30:


+ 3
- 1
hc/front/views.py View File

@ -24,7 +24,8 @@ from hc.front.forms import (AddWebhookForm, NameTagsForm,
TimeoutForm, AddUrlForm, AddEmailForm, TimeoutForm, AddUrlForm, AddEmailForm,
AddOpsGenieForm, CronForm, AddSmsForm) AddOpsGenieForm, CronForm, AddSmsForm)
from hc.front.schemas import telegram_callback 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 hc.lib import jsonschema
from pytz import all_timezones from pytz import all_timezones
from pytz.exceptions import UnknownTimeZoneError from pytz.exceptions import UnknownTimeZoneError
@ -391,6 +392,7 @@ def status_single(request, code):
doc = { doc = {
"status": status, "status": status,
"status_text": STATUS_TEXT_TMPL.render({"check": check}), "status_text": STATUS_TEXT_TMPL.render({"check": check}),
"title": down_title(check),
"updated": updated "updated": updated
} }


+ 4
- 0
static/js/details.js View File

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


+ 1
- 1
templates/front/details.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load compress humanize static hc_extras %} {% load compress humanize static hc_extras %}
{% block title %}My Checks - {% site_name %}{% endblock %}
{% block title %}{{ check|down_title }}{% endblock %}
{% block content %} {% block content %}


Loading…
Cancel
Save