{% extends "base.html" %}
{% load i18n %}
{% block content %}

<div class="page-header">
  <h1>Project: {{ project.name }}</h1>
</div>

{% include 'promgen/breadcrumb.html' with project=project label='Register Exporter' only %}

<div class="row">

<form id="exporter_form" action="{% url 'project-exporter' project.id %}" method="post">{% csrf_token %}
  <div class="col-md-8">
    <div class="panel panel-default">
      <div class="panel-heading">Exporter</div>
        <table class="table">
          {{ form.as_table }}
        </table>
      <div class="panel-footer">
        <div class="input-group-btn">
          <button class="btn btn-primary">Register Exporter</button>
          <a
            class="btn btn-info"
            data-href="{% url 'exporter-scrape' project.id %}"
            data-form="#exporter_form"
            data-target="#exporterresult"
            >Test</a>
        </div>
        </div>
    </div>
  </div>
</form>

  <div class="col-md-4">
    <div class="panel panel-default">
      <div class="panel-heading">Presets</div>
      <div class="panel-body">
{% for job, port in exporters.items|dictsort:1 %}
      <form id="{{job}}_{{port}}" class="form-inline" action="{% url 'project-exporter' project.id %}" method="post">
          {% csrf_token %}
          <input type="hidden" name="job" value="{{ job }}" />
          <input type="hidden" name="port" value="{{ port }}" />
          <input type="hidden" name="path" value="" />
          <input type="hidden" name="enabled" value="1" />
          <div class="input-group-btn">
            <button style="width:80%" class="btn btn-primary">Register {{ job }} (Port: {{ port }})</button>
            <a
              style="width:20%"
              class="btn btn-info promgen-exporter"
              data-href="{% url 'exporter-scrape' project.id %}"
              data-form="#{{job}}_{{port}}"
              data-target="#exporterresult"
              >{% trans "Test" %}</a>
          </div>
      </form>
{% endfor %}
      </div>
    </div>
  </div>
</div>

<div id="exporterresult" class="panel-body" style="display:none;"></div>

{% endblock %}
