{% extends "base.html" %}
{% block title %}Edit HAProxy Config{% endblock %}
{% block nav_edit %} active{% endblock %}
{% block extra_css %}
        #editor_container{
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
        }
        .dark-mode #editor_container{
            box-shadow: 0 0 15px 5px rgba(43, 185, 199, 0.05);
        }
        .dark-mode textarea{
            background-color: #25354e;
            color: white;
        }
{% endblock %}
{% block content %}
    <div style="margin-top: 20px;" class="container">
        <div style="border-radius: 5px; padding: 20px;" id="editor_container" class="container mt-5">
            <h3><i style="margin: 8px;" class="fas fa-edit"></i>Edit HAProxy Configuration</h3>
            <form method="post" action="/edit">
                <div class="form-group">
                    <textarea style="padding: 15px;" class="form-control" name="haproxy_config" rows="25" cols="120">{{ config_content }}</textarea>
                </div>
                <button type="submit" name="save_check" value="1" class="btn btn-primary"><i style="margin: 8px;" class="fas fa-check"></i>Save & Check</button>
                <button type="submit" name="save_reload" value="1" class="btn btn-success"><i style="margin: 8px;" class="fas fa-sync-alt"></i>Save & Reload</button>
            </form>
            {% if check_output %}
            <div class="mt-3">
                {% if 'Fatal errors' in check_output %}
                <div class="alert alert-danger" role="alert">
                    <pre class="mb-0">{{ check_output }}</pre>
                </div>
                {% elif 'Warnings' in check_output %}
                <div class="alert alert-warning" role="alert">
                    <pre class="mb-0">{{ check_output }}</pre>
                </div>
                {% elif 'error detected while parsing an' in check_output %}
                <div class="alert alert-danger" role="alert">
                    <pre class="mb-0">{{ check_output }}</pre>
                </div>
                {% else %}
                <div class="alert alert-success" role="alert">
                    <pre class="mb-0">{{ check_output }}</pre>
                </div>
                {% endif %}
            </div>
            {% endif %}
        </div>
    </div>
{% endblock %}
