{% extends "framework.html" %}
{% load static %}
{% block content %}
  <div id="searchContent">
    <form id="admin-form" action="{{ SERVER_BASE }}/admin" method="post">
      <div class="form-group">
        <label for="textarea">Query</label>
        <textarea
          id="textarea"
          class="form-control"
          rows="10"
          placeholder="Paste query here"
          required
        >
PREFIX pps: <http://localhost:8080/vocabulary#>
SELECT ?name (count(?objId) as ?xcnt)
WHERE {
    ?packageId pps:objectId 'package' .
    ?packageId pps:name ?name .
    ?packageId pps:reviewStatus 'reviewed' .
    ?packageId pps:pathway ?objId .
} GROUP BY ?name
            </textarea
        >
      </div>
      <button id="submit" type="button" class="btn btn-primary">Submit</button>
    </form>
    <p></p>
  </div>
  <div id="results"></div>
  <div id="loading"></div>
  <script>
    $(function () {
      $("#submit").on("click", function () {
        makeLoadingGif("#loading", "{% static '/images/wait.gif' %}");

        data = {
          query: $("#textarea").val(),
        };

        $.post("{{ SERVER_BASE }}/expire", data, function (result) {
          $("#loading").empty();
          queryResultToTable("results", result);
        });
      });
    });
  </script>
{% endblock content %}
