byceps/byceps

View on GitHub
byceps/blueprints/admin/maintenance/templates/admin/maintenance/index.html

Summary

Maintainability
Test Coverage
{% extends 'layout/admin/base.html' %}
{% from 'macros/admin/dashboard.html' import render_cell %}
{% from 'macros/icons.html' import render_icon %}
{% set current_page = 'maintenance_admin' %}
{% set page_title = _('Maintenance') %}

{% block head %}
    <link rel="stylesheet" href="{{ url_for('static', filename='style/admin_dashboard.css') }}">
    <style>
      table.index--small th,
      table.index--small td {
        font-size: 0.6875rem; /* 11px / 16px */
      }
    </style>
{%- endblock %}

{% block body %}

  <h1 class="title">{{ page_title }}</h1>

  <div class="grid">

  {%- with items = [
    (_('Background Jobs'), 'pending', url_for('jobs_admin.index'), 'jobs.view'),
  ] %}
    {%- for label, icon, url, required_permission in items %}
      {%- if has_current_user_permission(required_permission) %}
        {%- call render_cell(icon_name=icon, additional_classes='cell--fitted', href=url) %}
    <div class="row">
      <div>{{ render_icon(icon) }}</div>
      <div class="column--grow">{{ label }}</div>
    </div>
        {%- endcall %}
      {%- endif %}
    {%- endfor %}
  {%- endwith %}

  {%- call render_cell('password') %}
    <div class="row mb">
      <div>{{ render_icon('password') }}</div>
      <div class="column--grow">{{ _('Verification Tokens') }}</div>
      <div><small class="dimmed">{{ verification_token_total }}</small></div>
    </div>

    <table class="index index--small is-wide mb">
      {%- for purpose_name, count in verification_token_counts_by_purpose_name|dictsort %}
      <tr>
        <td>{{ purpose_name }}</td>
        <td class="number">{{ count }}</td>
      </tr>
      {%- endfor %}
    </table>

    <a class="button button--wrapping" href="{{ url_for('.delete_old_verification_tokens') }}" data-action="delete-old-verification-tokens">{{ render_icon('delete') }} <small style="margin-left: 0.5rem; text-align: left;">{{ _('Delete old verification tokens') }}</small></a>
  {%- endcall %}

  {%- call render_cell('log-in', 'cell--fitted') %}
    <div class="row mb">
      <div>{{ render_icon('log-in') }}</div>
      <div class="column--grow">{{ _('Login events') }}</div>
    </div>

    <a class="button button--wrapping" href="{{ url_for('.delete_old_login_log_entries') }}" data-action="delete-old-login-log-entries">{{ render_icon('delete') }} <small style="margin-left: 0.5rem; text-align: left;">{{ _('Delete old login events') }}</small></a>
  {%- endcall %}

  {%- call render_cell('log-in', 'cell--fitted') %}
    <div class="row mb">
      <div>{{ render_icon('log-in') }}</div>
      <div class="column--grow">{{ _('User sessions') }}</div>
    </div>

    <div class="mb">{{ _('This will log out all users.') }}</div>

    <a class="button button--wrapping color-danger" href="{{ url_for('.delete_all_session_tokens') }}" data-action="delete-all-session-tokens">{{ render_icon('delete') }} <small style="margin-left: 0.5rem; text-align: left;">{{ _('Delete all session tokens') }}</small></a>
  {%- endcall %}

  </div>

{%- endblock %}

{% block scripts %}
<script>
  onDomReady(() => {
    confirmed_post_on_click_then_reload('[data-action="delete-old-verification-tokens"]', '{{ _('Delete old verification tokens?') }}');
    confirmed_post_on_click_then_reload('[data-action="delete-old-login-log-entries"]', '{{ _('Delete old login events?') }}');
    confirmed_post_on_click_then_reload('[data-action="delete-all-session-tokens"]', '{{ _('Delete all session tokens?') }}');
  });
</script>
{% endblock %}