{% extends 'base.html' %} {% block content %} {% from '_common_fields.html' import show_token_placeholders %} {#- Notification activity: every notification that is waiting, failed or was delivered, newest first, in one list. The list on the left, the selected notification on the right. Everything is in the address (filters, page, ?id= of the selected one), so it works without JavaScript; notification-queue.js opens the filters as a dialog, closes the row menus and copies an ID. See notification_delivery/ #} {%- macro nq_url() -%} {{- url_for('settings.notifications.queue', state=kwargs.get('state', filters.state), type=kwargs.get('type', filters.type), watch=kwargs.get('watch', filters.watch), page=kwargs.get('page'), id=kwargs.get('id'), per_page=kwargs.get('per_page')) -}} {%- endmacro -%} {#- A long text is cut off (faded out) at 200px by notification-queue.js, which then shows this to open it up. Without JavaScript the text is in the page whole and this stays hidden. #} {%- macro show_all_button(target_id) -%} {%- endmacro -%} {%- macro state_pill(state, item=None) -%} {%- if state == 'sent' -%} {{ _('Delivered') }} {%- elif state == 'failed' -%} {{ _('Failed') }} {%- elif item and item.sending -%} {{ _('Sending') }} {%- elif item and item.attempts -%} {{ _('Retrying') }} {%- else -%} {{ _('Queued') }} {%- endif -%} {%- endmacro -%} {#- How an attempt went, at the start of its line: a green tick, or a red cross with the status the other end answered with when the error has one (400, 503 ...) #} {%- macro attempt_pill(attempt) -%} {%- if attempt.ok -%} {{ _('Delivered') }} {%- else -%} {{ attempt.status_code or _('Failed') }} {%- endif -%} {%- endmacro -%} {%- set state_names = {'queued': _('Queued'), 'failed': _('Failed'), 'sent': _('Delivered')} -%}
{% if list_message %}
{{ list_message }}
{% endif %} {#- Hold everything back: notifications wait, and a waiting one can be edited before it is sent #} {%- if can_pause %}
{{ _('Sending notifications') }} {%- if paused %} {{ _('Nothing is being sent. From its menu a waiting notification can be edited, or sent now on its own.') }} {%- endif %}
{%- endif %} {#- The filters: each button says what it is set to and opens the dialog #}
{%- if filters.watch %} {#- Came here for one watch (the watch list's "Notification error" link): said so, with its own way out #} {{ _('Filtering for watch: %(watch)s', watch=filter_watch_label) }} {%- endif %} {%- if filters.state or filters.type or filters.watch %} {{ _('Clear filters') }} {%- endif %} {{ _('Updated %(time)s', time=updated_at) }} · {{ _('Refresh') }}
{#- A waiting notification, changed before it is sent. A textarea and not an editable page element: what is edited is the template's source (its tokens, line breaks, markup as text), which has to go back exactly as typed. Shown as a dialog by notification-queue.js, in the page without it. #} {%- if editing %}
{%- endif %}
{%- for day in days %}

{{ day.label }}

{%- else %}

{%- if filters.state or filters.type or filters.watch %}{{ _('No notifications match these filters.') }}{% else %}{{ _('No notifications yet.') }}{% endif -%}

{%- endfor %}
{{ _('%(total)s notifications', total=total|format_int_locale) }} {%- if page_count > 1 %} {%- if page_number > 1 %}{% endif %} {{ _('Page %(page)s of %(pages)s', page=page_number, pages=page_count) }} {%- if page_number < page_count %}{% endif %} {%- endif %}
{%- for s in filters.state or [] %}{% endfor %} {%- if filters.type %}{% endif %} {%- if filters.watch %}{% endif %}
{%- if selected %}
{{ _('Notification') }}

{{ selected.type }} #{{ selected.index }} {{ state_pill(selected.state, selected) }}

{%- if selected.state != 'queued' %}
{%- if selected.state == 'failed' %} {{ _('Edit and send again') }}
{%- endif %}
{%- endif %} {%- if can_edit_selected and selected.state == 'queued' %} {%- endif %}
{{ _('Watch') }}
{#- To the watch in the watch list (found by its UUID): its state, its history and Edit are all there. On the whole list (tag=''), or the groups the list was last filtered by could hide it #} {%- if selected.watch_label %}{{ selected.watch_label }}{% else %}{{ selected.watch_url or '-' }}{% endif %} {%- if selected.watch_uuid %} · {{ _('only this watch') }}{% endif %}
{{ _('Sent to') }}
{{ selected.url_masked or '-' }}
{{ _('Queued') }}
{{ selected.queued_at|format_timestamp_timeago }}
{{ _('Attempts') }}
{{ selected.attempts }}
{{ _('Style') }}
{{ selected.style_label or '-' }}
{{ _('Screenshot') }}
{{ _('Attached') if selected.has_screenshot else '-' }}
{{ _('ID') }}
{{ selected.id }}
{%- if selected.edited %}
{{ _('Edited') }}
{{ _('Changed by hand before sending') }}
{%- endif %} {%- if selected.is_test %}
{{ _('Test') }}
{{ _('From a "Send test notification" button') }}
{%- endif %}
{#- What the other end is given: the title and body with every token filled in, made the way a send makes them. Where a rejected notification (broken JSON in the body ...) is found out. #}

{{ _('What is sent') }}

{%- if rendered and rendered.error %}

{{ _('This notification cannot be made from its template:') }}

{{ rendered.error }}
{%- elif rendered %}
{{ rendered.title }}
{{ rendered.body }}
{{ show_all_button('nq-rendered-body') }} {%- if rendered.coloured_by_service %}

{{ _('This service shows the changes in colour: what is marked (removed), (added), (changed), (into) here is a coloured block there.') }}

{%- endif %} {%- else %}

-

{%- endif %} {#- Only for one that could not be made when it was queued: everything else has no template any more, what it holds is what is sent #} {%- if not selected.tokens_rendered %}

{{ _('Template') }}

{{ selected.title or '' }}
{{ selected.body or '' }}
{{ show_all_button('nq-template-body') }} {%- endif %}

{{ _('Attempts') }}

{%- if selected.attempts_log %}
    {%- for attempt in selected.attempts_log %}
  1. {{ attempt_pill(attempt) }} {{ attempt.at|format_timestamp_timeago }} {%- if attempt.error %}
    {{ attempt.headline }}
    {%- if attempt.has_log %}
    {{ _('Full log') }}
    {{ attempt.error }}
    {%- endif %} {%- endif %}
  2. {%- endfor %}
{%- else %}

{{ _('No attempt was made yet.') }}

{%- endif %} {%- else %}

{{ _('Choose a notification on the left to see where it went and every attempt made.') }}

{%- endif %}
{% endblock %}