{% extends 'layout.html' %}

{% block title %} Информация о пользователе {% endblock %}


{% block style %}
    body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    }
    .jumbotron {
        background-color: #f8f9fa;
        padding: 20px;
        margin: 20px;
        border-radius: 5px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    .jumbotron h1 {
        color: #ff7077;
    }
    .jumbotron h2 {
        color: #007bff;
    }
    .info-block {
        margin: 10px;
        padding: 10px;
        background-color: #f1f1f1;
        border-radius: 5px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    .tile-container {
        display: flex;
        flex-wrap: nowrap; /* Ensure tiles stay in a single line */
    }
    .info-block.stable-version {
        flex: 1; /* Distribute space equally among tiles */
    }
    table {
        width: 100%;
        border-collapse: collapse;
    }
    th, td {
        padding: 8px;
        text-align: left;
        border-bottom: 1px solid #ddd;
    }
    th {
        background-color: #f2f2f2;
        color: #333;
    }
{% endblock %}

{% block body %}
    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>Тип действия</th>
                <th>ВМ</th>
                <th>Гипер</th>
                <th>Информация</th>
                <th>Время действия</th>
            </tr>
        </thead>
        <tbody>
            {% for user in user_data.items %}
                <tr>
                    <td>{{ user[0].user_id }}</td>
                    {% if user[0].action_type == 'login_user' %}
                        <td>Авторизация</td>
                    {% elif user[0].action_type == 'release_vm' %}
                        <td>ВМ освобождена</td>
                    {% elif user[0].action_type == 'occupy_vm' %}
                        <td>ВМ занята</td>
                    {% elif user[0].action_type == 'del_vm' %}
                        <td>ВМ удалена</td>
                    {% elif user[0].action_type == 'edit_vm' %}
                        <td>ВМ отредактирована</td>
                    {% elif user[0].action_type == 'start_vm' %}
                        <td>ВМ запущена</td>
                    {% elif user[0].action_type == 'stop_vm' %}
                        <td>ВМ остановлена</td>
                    {% elif user[0].action_type == 'restart_vm' %}
                        <td>ВМ перезагружена</td>
                    {% endif %}
                    {% if user[0].action_type == 'login_user' %}
                        <td>х</td>
                        <td>х</td>
                    {% else %}
                        <td>{{ user[1] }}</td>
                        <td>{{ user[2] }}</td>
                    {% endif %}
                    {% if user[0].action_info == None %}
                        <td>х</td>
                    {% else %}
                        <td>{{ user[0].action_info }}</td>
                    {% endif %}
                    <td>{{ user[0].action_timestamp }}</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>

    <div class="pagination">
        <span>Страницы:</span>
        {% for page_num in user_data.iter_pages() %}
            {% if page_num %}
                <a href="{{ url_for('user.user_info', username=user_pg, page=page_num) }}">{{ page_num }}</a>
            {% else %}
                <span class="current">{{ page_num }}</span>
            {% endif %}
        {% endfor %}
    </div>
{% endblock %}
