{% block selfinfo_system_info %}
    <h2 class="mt-3">
        System Information
        <button class="text-primary bg-transparent box-shadow-none border-0" onclick='copyElementContent("{{ id }}-anchor")'>
            <i class="fa fa-link fs-3" aria-hidden="true"></i>
        </button>
        <div id="{{ id }}-anchor" class="hidden d-none">
            {{ full_url ~ '#' ~ id }}
        </div>
    </h2>
    {% if data.platform_info %}
        <div class="card mb-4">
            <div class="card-header">
                {{ _('Platform Information') }}
            </div>
            <div class="card-body">
                <table class="table table-borderless mb-3">
                    <thead>
                        <tr>
                            <th scope="col">System Platform</th>
                            <th scope="col">Distribution</th>
                            <th scope="col">Python Version</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>{{ data.platform_info.platform }}</td>
                            <td>{{ data.platform_info.distro }}</td>
                            <td>{{ data.platform_info.python_version }}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    {% endif %}
{% endblock %}
{% if data.ram_usage %}
    {% block selfinfo_ram_usage %}
        <nav class="mb-3">
            <div class="nav nav-tabs" id="nav-tab" role="tablist">
                <button class="nav-link active" id="nav-ram-tab-general-tab" data-bs-toggle="tab" data-bs-target="#nav-ram-tab-general" role="tab" aria-controls="nav-ram-tab-general" aria-selected="true">General</button>
                {% if profile == 'default' %}
                    <button class="nav-link" id="nav-ram-tab-monitor-tab" data-bs-toggle="tab" data-bs-target="#nav-ram-tab-monitor" role="tab" aria-controls="nav-ram-tab-monitor" aria-selected="false">Monitor</button>
                {% endif %}
            </div>
        </nav>
        <div class="tab-content d-block">
            <div class="tab-pane fade show active" id="nav-ram-tab-general" role="tabpanel" aria-labelledby="nav-ram-tab-general-tab">
                <div class="card mb-4">
                    <div class="card-header">
                        {{ _('RAM usage') }}
                    </div>
                    <div class="card-body">
                        <table class="table table-borderless mb3">
                            <tr>
                                <th class="col">{{ _('RAM Usage in') }} %</th>
                                <th class="col">{{ _('RAM Usage') }}</th>
                                <th class="col">{{ _('RAM Total') }}</th>
                            </tr>
                            <tbody>
                                <tr>
                                    <td>{{ data.ram_usage.precent_usage }}%</td>
                                    <td>{{ data.ram_usage.used_ram }}</td>
                                    <td>{{ data.ram_usage.total_ram }}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    {% if data.ram_usage.processes %}
                        <div class="accordion-item m-3 border">
                            <div class="accordion-header" id="ram-top-processes">
                            <button class="accordion-button collapsed p-2" type="button" data-bs-toggle="collapse" data-bs-target="#ram-top-processes-acc" aria-expanded="false" aria-controls="ram-top-processes-acc">
                                <div class="d-flex">
                                    <span class="h5 mb-0">{{ _('Top 10 Processes') }}</span>
                                </div>
                            </button>
                            </div>
                            <div id="ram-top-processes-acc" class="accordion-collapse collapse" aria-labelledby="ram-top-processes-acc-heading">
                                <div class="accordion-body">
                                    <div class="row">
                                        <div class="col-lg-6">
                                            <ol start="1">
                                                {% for process in data.ram_usage.processes[:5] %}
                                                    <li>
                                                        <span title="memory">{{ process[2] }}</span>,
                                                        <span title="name">{{ process[1] }}</span>,
                                                        <span title="PID">{{ process[0] }}</span>
                                                    </li>
                                                {% endfor %}
                                            </ol>
                                        </div>
                                        {% if data.ram_usage.processes|length > 5 %}
                                            <div class="col-lg-6">
                                                <ol start="6">
                                                    {% for process in data.ram_usage.processes[5:] %}
                                                        <li>
                                                            <span title="memory">{{ process[2] }}</span>,
                                                            <span title="name">{{ process[1] }}</span>,
                                                            <span title="PID">{{ process[0] }}</span>
                                                        </li>
                                                    {% endfor %}
                                                </ol>
                                            </div>
                                        {% endif %}
                                    </div>
                            </div>
                            </div>
                        </div>
                    {% endif %}
                </div>
            </div>
            {% if profile == 'default' %}
                <div class="tab-pane fade" id="nav-ram-tab-monitor" role="tabpanel" aria-labelledby="nav-ram-tab-monitor-tab">
                    <button class="btn btn-primary my-3" id="ram-monitor">Start monitoring</button>
                    <div class="card mb-4">
                        <div class="card-header">
                            {{ _('RAM usage') }}
                        </div>
                        <div class="card-body">
                            <table class="table mb3">
                                <tr>
                                    <th class="col">{{ _('RAM Usage in') }} %</th>
                                    <th class="col">{{ _('RAM Usage') }}</th>
                                    <th class="col">{{ _('RAM Total') }}</th>
                                    <th class="col">{{ _('Processes') }}</th>
                                </tr>
                                <tbody hx-get="/selfinfo/get-ram" hx-trigger="every 5s [getRam()]" hx-swap="beforeend">
                                    <tr>
                                        <td>{{ data.ram_usage.precent_usage }}%</td>
                                        <td>{{ data.ram_usage.used_ram }}</td>
                                        <td>{{ data.ram_usage.total_ram }}</td>
                                        <td>
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <ol start="1">
                                                        {% for process in data.ram_usage.processes[:5] %}
                                                            <li>
                                                                <span title="memory">{{ process[2] }}</span>, 
                                                                <span title="name">{{ process[1] }}</span>, 
                                                                <span title="PID">{{ process[0] }}</span>
                                                            </li>
                                                        {% endfor %}
                                                    </ol>
                                                </div>
                                                <div class="col-lg-6">
                                                    <ol start="6">
                                                        {% for process in data.ram_usage.processes[5:] %}
                                                            <li>
                                                                <span title="memory">{{ process[2] }}</span>, 
                                                                <span title="name">{{ process[1] }}</span>, 
                                                                <span title="PID">{{ process[0] }}</span>
                                                            </li>
                                                        {% endfor %}
                                                    </ol>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            {% endif %}
        </div>
    {% endblock %}
{% endif %}
{% block selfinfo_disk_usage %}
    {% if data.disk_usage %}
        <div class="card mb-4">
            <div class="card-header">
                {{ _('Disk Usage') }}
            </div>
            <div class="card-body">
                <table class="table mb3">
                    <tr>
                        <th class="col">{{ _('Path') }}</th>
                        <th class="col">{{ _('Disk Usage in') }} %</th>
                        <th class="col">{{ _('Disk Total') }}</th>
                        <th class="col">{{ _('Disk Free') }}</th>
                    </tr>
                    <tbody>
                        {% for disk in data.disk_usage %}
                            <tr>
                                <td>{{ disk.path }}</td>
                                <td>{{ disk.precent_usage }}%</td>
                                <td>{{ disk.total_disk }}</td>
                                <td>{{ disk.free_space }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    {% endif %}
{% endblock %}
