{% extends 'layouts/main.html' %}
{% block title %}Run Analysis for {{ table_name }}{% endblock %}
{% block content %}

{% if stdout %}
<div class="card border-secondary mb-3" overflow="scroll" style="max-height: 36rem;">
  <div class="card-header"><strong>Output Printed by the Subprocess</strong></div>
  <div class="card-body text-secondary scroll">
    <p class="card-text">
        {% for line in stdout%}
            {{line}}<br>
        {% endfor %}
    </p>
  </div>
</div>
{% endif %}
{% if stderr %}
<hr>
<div class="card border-danger mb-3" overflow="scroll" style="max-height: 36rem;">
  <div class="card-header text-danger"><strong>Error Message from Subprocess; Read and Report!</strong></div>
  <div class="card-body text-danger scroll">
    <p class="card-text">
        {% for line in stderr%}
            {{line}}<br>
        {% endfor %}
    </p>
  </div>
</div>
<hr>
{% endif %}

<div class="page-header">
    {% from 'macros/render_form.html' import run_render_form %}
    <h2> <a href="{{ url_for('run', schema=schema, table=table) }}">Autopopulate {{table_name}}</a></h2>
    <h4>Where are you in the data pipeline?</h4>
    Click on a table to expand it.
    <div class="post-tabs">
        <object data="{{ url_for('tmpfile', filename=filename) }}" type="image/svg+xml"
                class="Svg" target="_top">
        </object>
    </div>
    <hr>
    <h4> Enter settings for Population </h4>
    {{ run_render_form(form, readonly=readonly) }}
    <hr>
    <h4>Entries already populated</h4>
    {% with data=data, toggle_off_keys=toggle_off_keys%}
        {% include 'macros/tables.html' %}
    {% endwith %}
</div>

{% endblock %}
