<!--
SPDX-FileCopyrightText: 2017-present Tobias Kunze
SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms

This file contains Apache-2.0 licensed contributions copyrighted by the following contributors:
SPDX-FileContributor: luto
-->

{% extends "orga/schedule/base.html" %}

{% load i18n %}
{% load static %}

{% block extra_title %}{% translate "Export schedule data" %} :: {% endblock extra_title %}

{% block stylesheets %}
    <link rel="stylesheet" type="text/css" href="{% static "common/css/ui/export.css" %}" />
{% endblock stylesheets %}

{% block schedule_content %}
    <h2>{% translate "Export schedule data" %}</h2>

    {% include "orga/includes/tablist.html" %}

    <section role="tabpanel" id="tabpanel-custom" aria-labelledby="tab-custom" tabindex="0" aria-hidden="false">
        <form method="post">
            {% csrf_token %}
            {% include "common/forms/errors.html" %}
            <fieldset>
                <legend>{% translate "Export settings" %}</legend>
                {{ form.export_format.as_field_group }}
                <div id="data-delimiter">
                    {{ form.data_delimiter.as_field_group }}
                </div>
            </fieldset>
            <fieldset>
                <legend id="dataset">{% translate "Dataset" %}</legend>
                {{ form.target.as_field_group }}
            </fieldset>
            <fieldset>
                <legend id="fields">{% translate "Data fields" %}</legend>
                <div class="d-flex">
                    <div class="ml-auto form-check">
                        <input type="checkbox" id="select-all" name="select-all">
                        <label for="select-all">{% translate "Select all" %}</label>
                    </div>
                </div>
                {% for field in form.export_fields %}
                    {{ field.as_field_group }}
                {% endfor %}
            </fieldset>

            {% include "orga/includes/submit_row.html" %}
        </form>
    </section>

    <section role="tabpanel" id="tabpanel-general" aria-labelledby="tab-general" tabindex="0" aria-hidden="true">
        {% blocktranslate trimmed %}
            pretalx provides a range of exports. If none of these match what you are looking
            for, you can also provide a custom plugin to export the data – please ask
            your administrator to install the plugin.
        {% endblocktranslate %}
        {% blocktranslate trimmed %}
            If you are looking for exports of proposals, sessions or schedule data, please head
            here:
        {% endblocktranslate %}
        <a class="btn btn-outline-info btn-sm" href="{{ request.event.orga_urls.speakers }}export/">{% translate "Speaker exports" %}</a>
        {% if not request.event.current_schedule %}
            <div class="alert alert-warning">
                {% blocktranslate trimmed %}
                    You haven’t released a schedule yet – many of these data exporters only work on a released schedule.
                {% endblocktranslate %}
            </div>
        {% endif %}
        <ul>
            {% for exporter in exporters %}
                <li>
                    <a href="{{ exporter.urls.base }}">
                        {% if exporter.icon|slice:":3" == "fa-" %}
                            <i class="fa {{ exporter.icon }}"></i>
                        {% else %}
                            {{ exporter.icon }}
                        {% endif %}
                        {{ exporter.verbose_name }}
                        {% if exporter.show_qrcode %}
                            <span class="export-qrcode">
                                <i class="fa fa-qrcode"></i>
                                <div class="export-qrcode-image">{{ exporter.get_qrcode }}</div>
                            </span>
                        {% endif %}
                    </a>
                </li>
            {% endfor %}
        </ul>

        <hr>
        <h3>{% translate "HTML Export" %}</h3>

        <p>
            {% blocktranslate trimmed %}
                The event schedule can be exported to a static HTML dump, so you can upload it
                to a normal file-serving web server like nginx.
            {% endblocktranslate %}
            {% if request.export_html_on_release %}
                {% blocktranslate trimmed %}
                    This is done automatically on
                    schedule release, but you can also trigger that action here.
                {% endblocktranslate %}
            {% endif %}
        </p>
        <form action="{{ request.event.orga_urls.schedule_export_trigger }}" method="POST">
            {% csrf_token %}
            {% include "orga/includes/submit_row.html" with submit_buttons=zip_buttons %}
        </form>
    </section>
    <section role="tabpanel" id="tabpanel-api" aria-labelledby="tab-api" tabindex="0" aria-hidden="true">

        <h3>{% translate "API" %}</h3>

        <p>{% translate "You can also use the API to export or use data." %}</p>

        <p>
            {% blocktranslate trimmed %}
                Some of the general exports are only accessible for organisers, or include
                more information when accessed with your organiser account. If you want to
                access the organiser version in automatic integrations, you’ll have to
                provide your authentication token just like in the API, like this:
            {% endblocktranslate %}
        </p>

            <pre> curl -H "Authorization: Token INSERTTOKENHERE" {{ request.event.urls.frab_xml.full }}
 curl -H "Authorization: Token INSERTTOKENHERE" {{ request.event.api_urls.schedules }}latest/exporters/schedule.xml/ </pre>

        <p>
            {% blocktranslate trimmed %}
                Please note that your token will have to have the “action” permissions in order
                to access the predefined schedule exports via the API.
            {% endblocktranslate %}
        </p>


        {% include "orga/includes/submit_row.html" with submit_buttons=api_buttons %}
    </section>
{% endblock schedule_content %}
