{% extends 'layouts/default.twig' %}

{% block title %}Test: {{ test.title }}{% endblock %}

{% block scripts %}
  <script src="/js/test.js" type="text/javascript"></script>
{% endblock %}

{% block content %}
<div class="row">
  <div class="col-12">
    <h2>Test: {{ test.title }}</h2>

    <h4>Hardware tested: <a href="/hardware/{{ test.getHardware().id }}">{{ test.getHardware().name }}</a></h4>
  </div>
</div>

<hr>

<div class="row">
  <form id="test-result-form" class="col-12" action="/api/v1/result/add" method="post">
    <input type="hidden" name="result_test" value="{{ test.id }}">

    <div class="row">
      <div class="col-4">
        <label class="form-label" for="result_benchmark">Benchmark:</label>
        <select id="result_benchmark" class="form-select" name="result_benchmark">
          {% for b in test.getBenchmarks() %}
            <option value="{{ b.id }}">{{ b.name }}</option>
          {% endfor %}
        </select>
      </div>

      <div class="col-2">
        <label class="form-label" for="result_avg">Average:</label>
        <input id="result_avg" class="form-control" type="number" name="result_avg" step="0.01" required>
      </div>

      <div class="col-2">
        <label class="form-label" for="result_min">Minimum:</label>
        <input id="result_min" class="form-control" type="number" name="result_min" step="0.01">
      </div>

      <div class="col-2">
        <label class="form-label" for="result_max">Maximum:</label>
        <input id="result_max" class="form-control" type="number" name="result_max" step="0.01">
      </div>

      <div class="col-2">
        <input type="submit" class="btn btn-primary" value="Add Result">
      </div>
    </div>
  </form>
</div>

<hr>

<div class="row">
  <div class="col-12">
    <h3 class="mb-3">Benchmarks</h3>
    <table id="results-table" class="table table-hover table-responsive" data-test-id="{{ test.id }}">
      <thead class="table-light">
        <tr>
          <td>Benchmark</td>
          <td>Scoring type</td>
          <td># Results</td>
          <td>Avg.</td>
          <td>Min.</td>
          <td>Max.</td>
        </tr>
      </thead>
      <tbody>
        {% for b in test.getBenchmarks() %}
          <tr data-benchmark-id="{{ b.id }}"></tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <hr>

  <p><a href="/test">Back</a></p>
</div>
{% endblock %}
