{% extends "base.html.j2" %}
{% import "materialize/wtf.html.j2" as wtf %}
{% from "contributions/_breadcrumbs.html.j2" import breadcrumbs with context %}

{% block main_attribs %} class="service-scheme" data-service="tesseract-ocr-pipeline"{% endblock main_attribs %}

{% block page_content %}
<div class="container">
  <div class="row">
    <div class="col s12">
      <h1 id="title">{{ title }}</h1>
    </div>

    <div class="col s12 m3 push-m9">
      <div class="center-align">
        <p class="hide-on-small-only">&nbsp;</p>
        <p class="hide-on-small-only">&nbsp;</p>
        <a class="btn-floating btn-large btn-scale-x2 waves-effect waves-light">
          <i class="nopaque-icons service-color darken service-icon" data-service="spacy-nlp-pipeline"></i>
        </a>
      </div>
    </div>

    <div class="col s12 m9 pull-m3">
      <div class="card service-color-border border-darken" data-service="spacy-nlp-pipeline" style="border-top: 10px solid;">
        <div class="card-content">
          <div class="row">
            <div class="col s12">
              <div class="card-panel z-depth-0">
                <span class="card-title"><i class="left material-icons">layers</i>spaCy NLP Models</span>
                <p>You can add more Tesseract OCR models using the form below. They will automatically appear in the list of usable models.</p>
                <p><a href="">Edit already uploaded models</a></p>
                <p><a class="modal-trigger" href="#models-modal">Information about the already existing models.</a></p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="col s12">
      <h2>Add a model</h2>
      <div class="card">
        <form class="create-contribution-form" enctype="multipart/form-data" method="POST">
          <div class="card-content">
            {{ form.hidden_tag() }}
            <div class="row">
              <div class="col s12 l5">
                {{ wtf.render_field(form.spacy_model_file, accept='.tar.gz', placeholder='Choose a .tar.gz file') }}
              </div>
              <div class="col s12 l7">
                {{ wtf.render_field(form.title, material_icon='title') }}
              </div>
              <div class="col s12">
                {{ wtf.render_field(form.description, material_icon='description') }}
              </div>
              <div class="col s12 l6">
                {{ wtf.render_field(form.publisher,  material_icon='account_balance') }}
              </div>
              <div class="col s12 l6">
                {{ wtf.render_field(form.publishing_year, material_icon='calendar_month') }}
              </div>
              <div class="col s12">
                {{ wtf.render_field(form.publisher_url, material_icon='link') }}
              </div>
              <div class="col s12">
                {{ wtf.render_field(form.publishing_url, material_icon='link') }}
              </div>
              <div class="col s12 l10">
                {{ wtf.render_field(form.version, material_icon='apps') }}
              </div>
              <div class="col s12 l6">
                {{ wtf.render_field(form.compatible_service_versions) }}
              </div>
              <div class="col s12 l6 right-align" style="padding-right:20px;">
                <p></p>
                <br>
                {{ wtf.render_field(form.shared) }}
              </div>
            </div>
          </div>
          <div class="card-action right-align">
            {{ wtf.render_field(form.submit, material_icon='send') }}
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
{% endblock page_content %}

{% block modals %}
{{ super() }}
<div id="models-modal" class="modal">
  <div class="modal-content">
    <h4>spaCy NLP Pipeline models</h4>
    <table>
      <thead>
        <tr>
          <th>Title</th>
          <th>Description</th>
          <th>Biblio</th>
        </tr>
      </thead>
      <tbody>
        {% for m in spacy_nlp_pipeline_models %}
        <tr id="spacy-nlp-pipeline-model-{{ m.hashid }}">
          <td>{{ m.title }}</td>
          {% if m.description == '' %}
          <td>Description is not available.</td>
          {% else %}
          <td>{{ m.description }}</td>
          {% endif %}
          <td><a href="{{ m.publisher_url }}">{{ m.publisher }}</a> ({{ m.publishing_year }}), {{ m.title }} {{ m.version}}, <a href="{{ m.publishing_url }}">{{ m.publishing_url }}</a></td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  <div class="modal-footer">
    <a href="#!" class="modal-close waves-effect waves-light btn">Close</a>
  </div>
</div>
{% endblock modals %}
