{% extends "course_flow/base.html" %}
<!-- -->
{% load static i18n %} {% load course_flow_templatetags %}
<!-- -->
{% block header %} {% endblock %}
<!-- -->
{% block title %}{% trans "SALTISE Analytics" %} - CourseFlow{% endblock %}
<!-- -->
{% block metadescription %} {% endblock %}
<!-- -->
{% block body %}
<div class="saltise-menu-container">
    <h1>CourseFlow Analytics</h1>
    <hr>
    <div id="tabs" class="home-tabs">
      <button><a href="{% url 'course_flow:get-saltise-download' %}">Download</a></button>
      <ul>
        <li class="tab-header"><a href="#analytics">{% trans "Overview" %}</a></li>
        <li class="tab-header"><a href="#user-data">{% trans "User Info" %}</a></li>
        <li class="tab-header"><a href="#notified-users">{% trans "Notifications List" %}</a></li>
      </ul>
      <div id="analytics">
        <p>{% trans "Analytics on CourseFlow usage" %}</p>
        <h3>{% trans "Workflow Information:" %}</h3>
        <p>Total content created by month. Only content-rich objects are shown (bracketed numbers)</p>
        {% get_saltise_admin_workflows %}
        <h3>{% trans "User Information:" %}</h3>
        <p>Number of users who have created at least one of each the given objects within the given month.</p>
        {% get_saltise_admin_users %}
      </div>
      <div id="user-data">
        <h3>{% trans "User Details:" %}</h3>
        <p>Details on the content created by users.</p>
        {% get_saltise_admin_user_details %}
      </div>
      <div id="notified-users">
        <p>{% trans "Users who have subscribed to notifications:" %}</p>
        <div>
          <table>
            {% for user in notified_users %}
              <tr><td>{{ user.email }}</td></tr>
            {% endfor %}
          </table>
        </div>
      </div>
    </div>
</div>

<!-- -->
{% endblock %}
<!-- -->
{% block foot %} {% endblock %}
<!-- -->
{% csrf_token %}
<!-- -->

{% block scripts %} {{ block.super }}
<script nonce="{{request.csp_nonce}}">
  $(".saltise-menu-container").detach().appendTo("#container");

  $(window).on("load",()=>{
    $("#tabs").tabs({active:0});

    $("table.analytics-details tr th:contains('Month Total')").parent().addClass("month-row");
    $("table.analytics-details tr th:contains('Year Total')").parent().addClass("year-row");
    $("table.analytics-details tr th:contains('Domain Total')").parent().addClass("domain-row");
    $("table.analytics-details tr th:contains('Grand Total')").parent().addClass("total-row");
  });
</script>
{% endblock %}
