<!--
 Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

{% extends 'base.html' %}

{% block content %}
    <h1>This is the home page</h1>
    <p>Here we have have several things.</p>

    {% for field, message in context_form.errors.items() %}
        <div class="alert alert-dismissible fade show" role="alert">
        <b>{{ field }}</b>: {{ message }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>

    {% endfor %}

    <form id="select_context" method="POST" enctype="multipart/form-data">
        {{ context_form.hidden_tag() }}
        <fieldset class="form-group">
            <legend>Select the working context, or upload a JSON descriptors file</legend>
            <div class="row mb-3">
                <div class="row mb-3">
                    {{ context_form.context.label(class="col-sm-2 col-form-label") }}
                    <div class="col-sm-10">
                        {% if context_form.context.errors %}
                            {{ context_form.context(class="form-select is-invalid") }}
                            <div class="invalid-feedback">
                                {% for error in context_form.context.errors %}
                                    <span>{{ error }}</span>
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ context_form.context(class="form-select") }}
                        {% endif %}
                    </div>
                </div>

                {{ context_form.descriptors.label(class="col-sm-2 col-form-label") }}
                <div class="col-sm-10">
                    {% if context_form.descriptors.errors %}
                        {{ context_form.descriptors(class="form-control is-invalid") }}
                        <div class="invalid-feedback">
                            {% for error in context_form.descriptors.errors %}
                                <span>{{ error }}</span>
                            {% endfor %}
                        </div>
                    {% else %}
                        {{ context_form.descriptors(class="form-control") }}
                    {% endif %}
                </div>
            </div>

            <div class="d-grid gap-2 d-md-flex justify-content-md-start">
                {{ context_form.submit(class='btn btn-primary') }}
            </div>
        </fieldset>
    </form>

{% endblock %}