{% extends "base.html" %}
{% block title %}Run confirmation{% endblock %}
{% load view %}
{% load colour_table_rows %}
{% load natural_time_difference %}
{% load naturaltime from humanize %}
{% load static %}

{% block body %}
    {% if runs and not error %}
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <div class="panel-title">
                            Successfully submitted
                            {% if runs|length == 1 %}
                             run
                            {% else %}
                             runs
                            {% endif %}
                            for reduction:
                            <ul>
                                {% for run in runs %}
                                <li>
                                    {{ run.0 }} version {{ run.1 }} <a href="{% url 'runs:summary' instrument_name=instrument_name run_number=run.0 run_version=run.1 %}" target="_blank">View</a>
                                </li>
                                {% endfor %}
                            </ul>

                        </div>
                    </div>
                    <div class="panel-body">
                        {% if queued %}
                            <div class="row">
                                <div class="col-md-12 text-center">
                                    There are currently {{ queued }} runs queued.
                                </div>
                            </div>
                        {% endif %}
                        <fieldset>
                            <div class="row">
                                <div class="col-md-12">
                                    <strong>Description:</strong> {% if run_description %}{{ run_description }}{% else %}<em>No description provided</em>{% endif %}
                                </div>
                            </div>
                            <br>
                            <div class="row col-md-12">
                            <legend>Standard Variables</legend>
                                {% for name, value in variables.standard_vars.items %}
                                <div class="row">
                                    <div class="col-md-12">
                                        <strong>{{ name }}:</strong> {{value}}
                                    </div>
                                </div>
                                {% endfor %}
                            </div>
                            <div class="row col-md-12">
                                <legend>Advanced Variables</legend>
                                {% for name, value in variables.advanced_vars.items %}
                                    <div class="row">
                                        <div class="col-md-12">
                                            <strong>{{ name }}:</strong> {{value}}
                                        </div>
                                    </div>
                                {% endfor %}
                            </div>
                        </fieldset>
                    </div>
                </div>
            </div>
        </div>
    {% else %}
        <div class="row" id="error_container">
            <div class="col-md-8 col-md-offset-2">
                <div class="alert alert-danger">
                    <div class="row">
                        <div class="col-md-12 text-center">
                            <span id="error_message">{{ error }}</span><a href="#back">Go Back</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}
{% endblock %}