{% extends "layout.html" %}
{% block headers %}
<script src="/static/js/jquery-3.6.0.min.js"></script>
<script src="/static/js/utils.js"></script>
<script>
jQuery(document).ready(function () {
    jQuery(".hide-for-javascript").removeClass("hide-for-javascript");
    jQuery("#users-table").show();
    jQuery("#recalculate-statistics").on("click", function (event) {
        event.preventDefault();
        event.stopPropagation();
        jQuery.ajax({
            url:  "/admin/maintenance/recalculate-statistics",
            type: "GET"
        }).done(function () {
            show_message ("success", "<p>Recalculated statistics.</p>");
        }).fail(function () {
            show_message ("failure", "<p>Failed recalculate statistics.</p>");
        });
    });
    jQuery("#clear-cache").on("click", function (event) {
        event.preventDefault();
        event.stopPropagation();
        jQuery.ajax({
            url:  "/admin/maintenance/clear-cache",
            type: "GET",
        }).done(function () {
            show_message ("success", "<p>Cache has been cleared.</p>");
        }).fail(function () {
            show_message ("failure", "<p>Could not clear the cache.</p>");
        });
    });
});
</script>
{% endblock %}
{% block submenu %}
<ul>
  <li><a href="/admin/dashboard">Dashboard</a>
  <li><a href="/admin/users">Users</a>
  <li class="active corporate-identity-submenu-active">Maintenance
  <li><a href="/admin/exploratory">Exploratory</a>
  <li><a href="/admin/reports">Reports</a>
  {% if may_query %}<li><a href="/admin/sparql">Query</a>{% endif %}
  {% if may_review_quotas %}<li><a href="/admin/quota-requests">Quota requests</a>{% endif %}
</ul>
{% endblock %}
{% block body %}
<noscript>
  <p class="no-script">Sorry, this page requires JavaScript to function properly.</p>
</noscript>
<div class="hide-for-javascript">
<h1>Maintenance</h1>
<div class="center">
  <a id="clear-cache" href="/admin/maintenance/clear-cache" class="button corporate-identity-standard-button">Clear cache</a>
  <a id="recalculate-statistics" href="/admin/maintenance/recalculate-statistics" class="button corporate-identity-standard-button">Recalculate statistics</a>
  <a id="repair-missing-dois" href="/admin/maintenance/repair-doi-registrations" class="button corporate-identity-standard-button">Repair {{missing_dois}} missing DOIs</a></div>
</div>
{% endblock %}
