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

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

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

{% block stylesheets %}
    <link rel="stylesheet" href="{% static "common/css/ui/stages.css" %}">
    <link rel="stylesheet" href="{% static "orga/css/ui/dashboard.css" %}">
    <link rel="stylesheet" href="{% static "orga/css/forms/i18n.css" %}">
    <link rel="stylesheet" href="{% static "orga/css/ui/history.css" %}">
{% endblock stylesheets %}

{% block scripts %}
    <script defer src="{% static "vendored/htmx.min.js" %}"></script>
    <script defer src="{% static "common/js/ui/dialog.js" %}"></script>
    <script defer src="{% static "common/js/ui/history-dialog.js" %}"></script>
{% endblock scripts %}

{% block content %}
    {% has_perm "person.orga_list_speakerprofile" request.user request.event as can_view_speakers %}
    {% has_perm "event.update_event" request.user request.event as can_change_settings %}
    {% if "congratulations" in request.GET %}
        <div class="alert alert-success congratulations">
            <span></span>
            {% blocktranslate trimmed %}
                Your event has been created and you’re ready to go! Check out the
                event settings, set up your Call for Papers with session types and custom fields,
                and you’re ready to go!
            {% endblocktranslate %}
        </div>
    {% endif %}
    <h2 id="main-title">
        <span>
            {{ request.event.name }}
            <small class="text-muted small">{{ request.event.get_date_range_display }}</small>
        </span>
    </h2>
    <div id="timeline-steps" class="stages">
        {% for stp in timeline %}
            <div {% if stp.phase == "done" and stp.url %}href="{{ stp.url }}"{% endif %} class="step step-{{ stp.phase }}">
                <div class="step-icon">
                    <span class="fa {% if stp.icon %}fa-{{ stp.icon }}{% else %}fa-check{% endif %}"></span>
                </div>
                <div class="step-label">
                    {{ stp.label }}
                </div>
                {% if stp.links and can_change_settings %}
                    <div class="step-links">
                        <ul>
                            {% for link in stp.links %}
                                <li>
                                    <a {% if link.url %}href="{{ link.url }}"{% endif %}>
                                        {{ link.title }}
                                    </a>
                                </li>
                            {% endfor %}
                        </ul>
                    </div>
                {% endif %}
            </div>
        {% endfor %}
    </div>

    <div class="dashboard-list">
        {% if can_change_settings %}
            <a href="{{ request.event.orga_urls.live }}" class="dashboard-block">
                <div class="dashboard-live-text">
                    {% translate "Your event is currently" %}
                </div>
                {% if request.event.is_public %}
                    <div class="dashboard-live text-success">
                        <i class="fa fa-check-circle"></i>
                        {% translate "live" %}
                    </div>
                {% else %}
                    <div class="dashboard-live text-danger">
                        <i class="fa fa-times-circle"></i>
                        {% translate "not live" %}
                    </div>
                {% endif %}
                <div class="dashboard-live-text">
                    {% translate "Click here to change" %}
                </div>
            </a>
        {% endif %}
        {% for tile in tiles %}
            <div class="dashboard-block-wrapper">
                <{% if tile.url %}a href="{{ tile.url }}"{% else %}div{% endif %} class="dashboard-block{% if tile.left or tile.right %} dashboard-block-extended{% endif %}">
                <h1>{{ tile.large }}</h1>
                <div class="dashboard-description">
                    {{ tile.small }}
                </div>
            </{% if tile.url %}a{% else %}div{% endif %}>
            {% if tile.left or tile.right %}
                <div class="dashboard-block-extension">
                    {% if tile.left %}
                        <{% if tile.left.url %}a href="{{ tile.left.url }}"{% else %}div{% endif %} class="dashboard-block-addon{% if tile.left.color %} dashboard-block-addon-{{ tile.left.color }}{% endif %}">
                        {{ tile.left.text }}

                        </{% if tile.left.url %}a{% else %}div{% endif %}>
                    {% endif %}
                    {% if tile.right %}
                        <{% if tile.right.url %}a href="{{ tile.right.url }}"{% else %}div{% endif %} class="dashboard-block-addon{% if tile.right.color %} dashboard-block-addon-{{ tile.right.color }}{% endif %}">
                        {{ tile.right.text }}

                        </{% if tile.right.url %}a{% else %}div{% endif %}>
                    {% endif %}
                </div>
            {% endif %}
            </div>

        {% endfor %}
    </div>

    {% if history and can_change_settings %}
        <div class="dashboard-history">
            <div class="d-flex align-items-center">
                <h2>{% translate "History" %}</h2>
                {% if can_change_settings %}
                    <small>
                        <a href="{{ request.event.orga_urls.history }}" class="text-muted ml-2">
                            ({% translate "Full history" %})
                        </a>
                    </small>
                {% endif %}
            </div>

            {% include "common/logs.html" with entries=history %}

        </div>
    {% endif %}
{% endblock content %}
