{% extends "base.html" %}

{% block title %}
{{ title }}
{% endblock %}

{% block content %}

  <div class="container">


<section>
<h3>Run Model</h3>
<form id="model-form" method="post" action="/projects/run-models">
  <div class="row">
    <div class="six columns">
      <label for="model">Select Model:</label>
      <select id="model" name="model">
        {% for model in models %}
          <option value="{{ model|replace(' ', '_') }}"
            {% if selected_model is defined and selected_model == model|replace(' ', '_') %}selected{% endif %}>
            {{ model }}
          </option>
        {% endfor %}
      </select>
    </div>

    <div class="six columns">
      <label for="dataset">Select Dataset:</label>
      <select id="dataset" name="dataset">
        {% for dataset in datasets %}
          <option value="{{ dataset }}"
            {% if selected_dataset is defined and selected_dataset == dataset %}selected{% endif %}>
            {{ dataset }}
          </option>
        {% endfor %}
      </select>
    </div>
  </div>

  <div id="model-params" class="row" style="margin-top:15px;"></div>

  <button type="submit">Run</button>
</form>
</section>

{% if results %}
  <h3>Last 20 Results</h3>
    <div style="overflow-x:auto; font-size: 1.2rem;">
      <table class="u-full-width">
        <thead>
          <tr>
            <th>Time</th>
            <th>Model</th>
            <th>Dataset</th>
            <th>Parameters</th>
            <th>Accuracy</th>
          </tr>
        </thead>
        <tbody>
          {% for row in results %}
            <tr>
              <td>{{ row.timestamp }}</td>
              <td>{{ row.model }}</td>
              <td>{{ row.dataset }}</td>
              <td>{{ row.parameters }}</td>
              <td>{{ row.accuracy }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
{% endif %}
  </div>



{% endblock %}