mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 01:04:00 -04:00
creating error page for tech difficulties
This commit is contained in:
@@ -19,6 +19,7 @@ from app.main.views.sub_navigation_dictionaries import (
|
|||||||
about_notify_nav,
|
about_notify_nav,
|
||||||
using_notify_nav,
|
using_notify_nav,
|
||||||
)
|
)
|
||||||
|
from app.utils.api_health import is_api_down
|
||||||
from app.utils.user import user_is_logged_in
|
from app.utils.user import user_is_logged_in
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -51,11 +52,11 @@ def index():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"API down when loading homepage: {e}")
|
logger.warning(f"API down when loading homepage: {e}")
|
||||||
counts = None
|
counts = None
|
||||||
print(counts)
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"views/signedout.html",
|
"views/signedout.html",
|
||||||
sms_rate=CURRENT_SMS_RATE,
|
sms_rate=CURRENT_SMS_RATE,
|
||||||
counts=counts,
|
counts=counts,
|
||||||
|
is_api_down=is_api_down()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
19
app/templates/error/technical_difficulties.html
Normal file
19
app/templates/error/technical_difficulties.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{% block content %}
|
||||||
|
<section class="grid-container usa-section margin-top-5 margin-bottom-5">
|
||||||
|
<div class="grid-row flex-justify-center">
|
||||||
|
<div class="desktop:grid-col-3 tablet:grid-col-4 mobile:grid-col-12 flex-align-center">
|
||||||
|
<img
|
||||||
|
class="width-tablet tablet:width-full"
|
||||||
|
src="{{ asset_url('images/api-error.svg') }}"
|
||||||
|
alt="Mobile phone showing error screen"/>
|
||||||
|
</div>
|
||||||
|
<div class="desktop:grid-col-6 tablet:grid-col-12 padding-left-0 desktop:padding-left-5">
|
||||||
|
<h1 class="font-body-3xl line-height-sans-2 text-bold">
|
||||||
|
There's currently a technical issue.
|
||||||
|
</h1>
|
||||||
|
<p class="font-body-lg line-height-sans-2">Thank you for your patience while we work on it. Notify will be back soon.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
@@ -6,13 +6,13 @@ import usaButton %} {% block meta %}
|
|||||||
/>
|
/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block pageTitle %} Notify.gov
|
{% block pageTitle %} Notify.gov
|
||||||
{% if counts %} - There's currently a technical issue {% endif %}
|
{% if is_api_down %} - There's currently a technical issue {% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{% block beforeContent %}{% endblock %}
|
{% block beforeContent %}{% endblock %}
|
||||||
|
|
||||||
<main id="main-content" role="main">
|
<main id="main-content" role="main">
|
||||||
{% if counts %}
|
{% if is_api_down %}
|
||||||
<div class="usa-alert usa-alert--info usa-alert--slim" aria-label="Site alert,,,,">
|
<div class="usa-alert usa-alert--info usa-alert--slim" aria-label="Site alert,,,,">
|
||||||
<div class="grid-container padding-x-0">
|
<div class="grid-container padding-x-0">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
@@ -24,24 +24,8 @@ import usaButton %} {% block meta %}
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if counts %}
|
{% if is_api_down %}
|
||||||
<section class="grid-container usa-section margin-top-5 margin-bottom-5">
|
{% include "error/technical_difficulties.html" %}
|
||||||
<div class="grid-row flex-justify-center">
|
|
||||||
<div class="desktop:grid-col-3 tablet:grid-col-4 mobile:grid-col-12 flex-align-center">
|
|
||||||
<img
|
|
||||||
class="width-tablet tablet:width-full"
|
|
||||||
src="{{ asset_url('images/api-error.svg') }}"
|
|
||||||
alt="Mobile phone showing error screen"/>
|
|
||||||
</div>
|
|
||||||
<div class="desktop:grid-col-6 tablet:grid-col-12 padding-left-0 desktop:padding-left-5">
|
|
||||||
<h1 class="font-body-3xl line-height-sans-2 text-bold">
|
|
||||||
There's currently a technical issue.
|
|
||||||
</h1>
|
|
||||||
<p class="font-body-lg line-height-sans-2">Thank you for your patience while we work on it. Notify will be back soon.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<section class="usa-section--dark usa-hero" aria-label="Introduction">
|
<section class="usa-section--dark usa-hero" aria-label="Introduction">
|
||||||
<div class="grid-container padding-y-4">
|
<div class="grid-container padding-y-4">
|
||||||
|
|||||||
13
app/utils/api_health.py
Normal file
13
app/utils/api_health.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
|
|
||||||
|
def is_api_down():
|
||||||
|
api_base_url = os.getenv("API_BASE_URL", "http://localhost:6011")
|
||||||
|
try:
|
||||||
|
response = requests.get(api_base_url, timeout=2)
|
||||||
|
return response.status_code != 200
|
||||||
|
except RequestException:
|
||||||
|
return True
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
from flask import current_app
|
|
||||||
import mistune
|
|
||||||
from notifications_utils.formatters import create_sanitised_html_for_url
|
|
||||||
import re
|
|
||||||
import html
|
import html
|
||||||
|
import re
|
||||||
|
|
||||||
|
import mistune
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
|
from notifications_utils.formatters import create_sanitised_html_for_url
|
||||||
|
|
||||||
LINK_STYLE = "word-wrap: break-word; color: #1D70B8;"
|
LINK_STYLE = "word-wrap: break-word; color: #1D70B8;"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user