{% extends "base.html" %}
{% block title %}{% if entry %}Edytuj Regex CIDR{% else %}Nowy Regex CIDR{% endif %} - /etc/hosts Manager{% endblock %}
{% block extra_css %}
  {{ super() }}
  <style>
    .tooltip-inner {
      max-width: 300px;
      text-align: left;
    }
  </style>
{% endblock %}
{% block content %}
<div class="card mb-4">
  <div class="card-header">
    <h2>{% if entry %}Edytuj Regex Host{% else %}Nowy Regex CIDR{% endif %}</h2>
  </div>
  <div class="card-body">
    <form method="POST">
      <div class="mb-3">
        <label for="cidr_range" class="form-label">CIDR/Sieć</label>
        <input type="text" class="form-control" id="cidr_range" name="cidr_range" value="{% if entry %}{{ entry.cidr_range }}{% endif %}" placeholder="np. 10.87.200.0/27" required>
      </div>
      <div class="mb-3">
        <label for="gateway_ip" class="form-label">Adres IP bramy sieci</label>
        <input type="text" class="form-control" id="gateway_ip" name="gateway_ip" value="{% if entry %}{{ entry.gateway_ip }}{% endif %}">
      </div>

      <div class="mb-3">
        <label for="gateway_hostname" class="form-label">Docelowy hostname bramy</label>
        <input type="text" class="form-control" id="gateway_hostname" name="gateway_hostname" value="{% if entry %}{{ entry.gateway_hostname }}{% endif %}">
      </div>
      <div class="form-check mb-3">
        <input type="checkbox" class="form-check-input" id="use_gateway_ip" name="use_gateway_ip" {% if entry and entry.use_gateway_ip %}checked{% endif %}>
        <label class="form-check-label" for="use_gateway_ip">Brama ma mieć swój hostname</label>
      </div>
      <div class="mb-3">
        <label for="domain_suffix" class="form-label">Domena</label>
        <input type="text" class="form-control" id="domain_suffix" name="domain_suffix" value="{% if entry %}{{ entry.domain_suffix }}{% else %}domain.com{% endif %}">
      </div>
      <div class="mb-3">
        <label for="host_prefix" class="form-label">Pefix hostów sieci</label>
        <input type="text" class="form-control" id="host_prefix" name="host_prefix" value="{% if entry %}{{ entry.host_prefix }}{% else %}ip{% endif %}">
      </div>

      <div class="mb-3">
        <label for="comment" class="form-label">Komentarz</label>
        <input type="text" class="form-control" id="comment" name="comment" value="{% if entry %}{{ entry.comment }}{% endif %}">
      </div>
      <button type="submit" class="btn btn-primary">{% if entry %}Zapisz zmiany{% else %}Utwórz{% endif %}</button>
    </form>
  </div>
</div>
<div class="mt-3 text-center">
  <a href="{{ url_for('list_regex_hosts') }}" class="btn btn-secondary">Lista Regex Hosts</a>
</div>
{% endblock %}