{% extends 'layout/admin_page.html' %}

{% from 'forms/_form.html' import form_footer, form_header, form_row_static, form_rows %}
{% from 'message_box.html' import message_box %}

{% block title %}{% trans %}Community Hub{% endtrans %}{% endblock %}

{% block content %}
    {% call message_box('info', fixed_width=true) %}
        <strong>{% trans %}Let us know that you exist!{% endtrans %}</strong>
        <p>
            {%- trans -%}
                By registering your Indico server with the community hub, you will receive news on the latest releases
                as well as important security advisories. The data in the form below will be sent to the community hub.
            {%- endtrans -%}
        </p>
        {% trans %}Alongside, the following public information will be periodically collected as well:{% endtrans %}
        <ul>
            <li>{% trans %}Server default language{% endtrans %} ({{ language }})</li>
            <li>{% trans %}Indico version installed{% endtrans %} ({{ indico_version }})</li>
            <li>{% trans %}Python version used{% endtrans %} ({{ python_version }})</li>
            <li>{% trans %}Postgres version used{% endtrans %} ({{ postgres_version }})</li>
            <li>{% trans %}Operating system used{% endtrans %} ({{ operating_system }})</li>
            <li>{% trans %}Debug mode{% endtrans %} ({{ _('enabled') if config.DEBUG else _('disabled') }})</li>
            <li>{% trans %}Basic statistics (number of events, contributions and users){% endtrans %}</li>
        </ul>
    {% endcall %}

    <div id="tracking-status" class="action-box">
        <div class="section">
            <span class="icon"></span>
            <div class="text">
                <div class="label">{% trans %}Loading&hellip;{% endtrans %}</div>
                <div>{% trans %}Contacting the community hub.{% endtrans %}</div>
            </div>
            <div class="toolbar">
                <button id="sync-tracking" class="i-button warning icon-loop" style="display: none;"
                        data-href="{{ url_for('cephalopod.sync') }}"
                        data-method="POST">
                    {%- trans %}Synchronize{% endtrans -%}
                </button>
            </div>
        </div>
    </div>
    {% if show_local_warning %}
        {% include 'cephalopod/not_prod_warning.html' %}
    {% endif %}
    <div class="i-box">
        {{ form_header(form, id='cephalopod-form')}}
        {{ form_rows(form, fields=('joined', 'contact_name', 'contact_email')) }}
        {% call form_row_static(_('URL')) %}
            <span id="server-url" class="mono">{{ instance_url }}</span>
            <p class="form-field-description"><em>{% trans %}URL of your Indico server{% endtrans %}</em></p>
        {% endcall %}
        {% call form_row_static(_('Affiliation')) %}
            <span id="affiliation">{{ affiliation }}</span>
            <p class="form-field-description">
                <em>{% trans %}Affiliation of your Indico server{% endtrans %}</em>
            </p>
        {% endcall %}
        {% call form_footer(form) %}
            <input class="i-button big highlight" type="submit" value="{% trans %}Save{% endtrans %}">
        {% endcall %}
    </div>

    <script>
        setupCephalopodSettings({{ hub_url|tojson }}, {{ enabled|tojson }});
    </script>
{% endblock %}
