{% extends 'base.jinja.html' %}


{% block page_title %}
    {{ l.sysinfo_page_title }}
{% endblock %}

{% block add_js %}
    <script src="{{ STATIC_PREFIX }}js/restart.js"></script>
{% endblock %}

{% block page %}
    <div class="toolbar">
        <h2>{{ l.sysinfo_page_title }}</h2>
        <div class="toolbar-actions">
            {{ HOOK(H_SYSINFO_TOOLBAR_ACTIONS_START) }}
            <button class="purple sysinfo-restart"><i class="fa fa-refresh icon-left"></i>{{ l.sysinfo_panel_button_restart }}</button>
            {{ HOOK(H_SYSINFO_TOOLBAR_ACTIONS_END) }}
        </div>
    </div>
    <div class="panel">
        <div class="panel-body">
            <h3>{{ l.sysinfo_panel_title }}</h3>
            <table class="active-slides">
                <thead>
                    <tr>
                        <th>{{ l.sysinfo_panel_th_attribute }}</th>
                        <th>{{ l.sysinfo_panel_th_value }}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td colspan="2">
                            <h3>
                                <i class="fa fa-server icon-left"></i> {{ l.sysinfo_panel_table_section_system }}
                            </h3>
                        </td>
                    </tr>

                    {% for sysinfo_label, sysinfo_value in sysinfo.items() %}
                        <tr>
                            <td>{{ l[sysinfo_label] }}</td>
                            <td>{{ t(sysinfo_value) }}</td>
                        </tr>
                    {% endfor %}


                    {% for ro_variable in ro_variables %}
                        <tr>
                            <td>{{ ro_variable.description }}</td>
                            <td>
                                {% if ro_variable.value %}
                                    {% if ro_variable.type.value == 'bool' %}
                                        {% if ro_variable.display() %}
                                            ✅
                                        {% else %}
                                            ❌
                                        {% endif %}
                                    {% else %}
                                        {{ ro_variable.display() }}
                                    {% endif %}
                                {% else %}
                                        <span class="empty">{{ l.common_empty }}</span>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}

                     <tr>
                        <td colspan="2">
                            <h3>
                                <i class="fa fa-box-open icon-left"></i> {{ l.sysinfo_panel_table_section_application }}
                            </h3>
                        </td>
                    </tr>
                    {% for env_key, env_value in env_variables.items() %}
                        <tr>
                            <td>{{ env_key.replace('_',' ')|capitalize }}</td>
                            <td>
                                {% if env_value == true %}
                                    ✅
                                {% elif env_value == false %}
                                    ❌
                                {% elif env_value == none %}
                                    <span class="empty">{{ l.common_empty }}</span>
                                {% else %}
                                    {{ env_value }}
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <div class="panel panel-inactive panel-logs">
        <div class="panel-body">
            <h3>{{ l.sysinfo_panel_last_logs }}</h3>
            <pre style="">{%- for log_line in last_logs.split("\n") %}{{ log_line ~ "\n" }}{%- endfor %}</pre>
        </div>
    </div>
{% endblock %}
