{% extends 'layout.html' %}

{% block title %} Информация о машине {% endblock %}

{% block style %}
    .vm-heading {
        background-color: #3498db;
        padding: 25px;
        border-radius: 20px;
        color: white;
        text-align: center;
        margin-bottom: 20px;
    }

    .vm-section {
        padding: 20px;
        border: 1px solid #e0e0e0;
        border-radius: 20px;
        box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
        background-color: #ffffff;
        margin-bottom: 20px;
    }

    .vm-section h3 {
        font-size: 1.5rem;
        margin-bottom: 20px;
        text-align: center;
        color: #3498db;
        text-transform: uppercase;
    }

    .vm-form-group {
        margin-bottom: 20px;
    }

    .vm-label {
        font-weight: bold;
    }

    .vm-input {
        width: 100%;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
    }

    .vm-submit-button {
        background-color: #3498db;
        border: none;
        border-radius: 5px;
        padding: 10px 20px;
        color: #ffffff;
        font-size: 1rem;
        text-decoration: none;
        transition: background-color 0.2s;
    }

    .vm-input-info {
        width: 100%;
        height: 200px;
        resize: vertical;
    }

    .vm-status-image {
        width: 30px;
        vertical-align: middle;
    }
{% endblock %}

{% block body %}
    <div class="vm-heading">
        {% if all_data_vm.technical == True %}
            <h4>Данная виртуальная машина является технической</h4>
        {% endif %}
        <h1>{{ all_data_vm.name }}</h1>
    </div>

    <div class="vm-section">
        <p><strong>IP-адрес:</strong> {% if all_data_vm.ip_addres == None %} Данных нет {% else %} {{ all_data_vm.ip_addres }} {% endif %}</p>
        <p><strong>Гипервизор:</strong> {{ all_data_vm.hyper }}</p>
        <p><strong>Операционная система:</strong> {{ all_data_vm.os }}</p>
        <p><strong>Память:</strong>{% if all_data_vm.memory < 1024 %} {{ all_data_vm.memory }} МБ {% else %} {{ (all_data_vm.memory // 1024) | int }} ГБ {% endif %} </p>
        <p><strong>CPU:</strong> {{ all_data_vm.cpu }}</p>
        <p><strong>Статус питания:</strong>
            {% if all_data_vm.power_status == 'poweredOn' %}
                <img src="{{ url_for('static', filename='on.png') }}" width="20" height="20">
            {% else %}
                <img src="{{ url_for('static', filename='off.png') }}" width="20" height="20">
            {% endif %}
        </p>
        {% if all_data_vm.technical != True %}
            <p><strong>Статус:</strong> {% if all_data_vm.status == 'Занято' %} Виртуальная машина занята <strong>{{ all_data_vm.who_borrowed }}</strong> {% else %} Свободно {% endif %}</p>
        {% endif %}
    </div>

    <div class="vm-section">
        <form method="POST" action="{{ url_for('vm.vm_info', name=all_data_vm.name, hyper=all_data_vm.hyper) }}" id="vm-info-form">
            <div class="vm-form-group">
                <label for="information" class="vm-label">Добавить комментарий:</label>
                <textarea id="information" class="vm-input-info" name="information" required>{{ information }}</textarea>
            </div>
            <button type="submit" class="vm-submit-button">Сохранить</button>
        </form>
    </div>
{% endblock %}
