{% load i18n sizeformat %}

<div class="detail">
  <dl class="dl-horizontal">
    <dt>{% trans "Name" %}</dt>
    <dd>{{ instance.name }}</dd>
    <dt>{% trans "ID" %}</dt>
    <dd>{{ instance.id }}</dd>
    <dt>{% trans "Datastore" %}</dt>
    <dd>{{ instance.datastore.type }}</dd>
    <dt>{% trans "Datastore Version" %}</dt>
    <dd>{{ instance.datastore.version }}</dd>
    <dt>{% trans "Status" %}</dt>
    <dd>{{ instance.status|title }}</dd>
    <dt>{% trans "Operating Status" %}</dt>
    <dd>{{ instance.operating_status|title }}</dd>
    {% if instance.configuration %}
    <dt>{% trans "Configuration Group" %}</dt>
    <dd>
        <a href="{% url 'horizon:project:database_configurations:detail' instance.configuration.id %}">
            {{ instance.configuration.id }}
        </a>
    </dd>
    {% endif %}
    <dt>{% trans "Root Enabled" %}</dt>
    <dd>{{ root_enabled|capfirst }}</dd>
    {% if instance.locality %}
      <dt>{% trans "Locality" %}</dt>
      <dd>{{ instance.locality }}</dd>
    {% endif %}
  </dl>

  {% if instance.fault %}
    <h4>{% trans "Fault" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      <dt>{% trans "Message" %}</dt>
      <dd>{{ instance.fault.message }}</dd>
      {% if instance.fault.details %}
        <dt>{% trans "Details" %}</dt>
        <dd>
          <pre>{{ instance.fault.details }}</pre>
        </dd>
      {% endif %}
      <dt>{% trans "Created" %}</dt>
      <dd>{{ instance.fault.created|parse_isotime }}</dd>
    </dl>
  {% endif %}

  <h4>{% trans "Specs" %}</h4>
  <hr class="header_rule">
  <dl class="dl-horizontal">
    <dt>{% trans "Flavor" %}</dt>
    <dd>{{ instance.full_flavor.name }}</dd>
    <dt>{% trans "RAM" %}</dt>
    <dd>{{ instance.full_flavor.ram|mb_float_format }}</dd>
    {% if instance.volume %}
      <dt>{% trans "Volume Size" %}</dt>
      <dd>{{ instance.volume.size|diskgbformat }}</dd>
    {% endif %}
    <dt>{% trans "Created" %}</dt>
    <dd>{{ instance.created|parse_isotime }}</dd>
    <dt>{% trans "Updated" %}</dt>
    <dd>{{ instance.updated|parse_isotime }}</dd>
    <dt>{% trans "Service Status Updated" %}</dt>
    <dd>{{ instance.service_status_updated|parse_isotime }}</dd>
  </dl>

  {% if instance.addresses|length > 0 %}
    <h4>{% trans "Networking Information" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      <dt>{% trans "Is Public" %}</dt>
      <dd>{{ instance.access.is_public|yesno|capfirst }}</dd>
      <dt>{% trans "Allowed CIDRs" %}</dt>
        {% if instance.access.allowed_cidrs|length > 0 %}
          <dd>
           {% for cidr in instance.access.allowed_cidrs %}
              {% if not forloop.last %}
                {{ cidr }},&nbsp;
              {% else %}
                {{ cidr }}
              {% endif %}
            {% endfor %}
          </dd>
        {% else %}
        <dd>0.0.0.0/0</dd>
        {% endif %}
        {% for addr in instance.addresses %}
          <dt>{{ addr.type }}</dt>
          <dd>{{ addr.address }}</dd>
        {% endfor %}
    </dl>
  {% endif %}

{% block connection_info %}
{% endblock %}

{% if instance.replica_of or instance.replicas %}
  <h4>{% trans "Replication" %}</h4>
  <hr class="header_rule">
  <dl>
    {% if instance.replica_of %}
      <dt>{% trans "Is a Replica Of" %}</dt>
      <dd>
        {% url 'horizon:project:databases:detail' instance.replica_of.id as instance_url %}
        <a href="{{ instance_url }}">{{ instance.replica_of.id }}</a>
      </dd>
    {% endif %}

    {% if instance.replicas %}
      <dt>{% trans "Replicas" %}</dt>
      {% for replica in instance.replicas %}
        <dd>
          {% url 'horizon:project:databases:detail' replica.id as instance_url %}
          <a href="{{ instance_url }}">{{ replica.id }}</a>
        </dd>
      {% endfor %}
    {% endif %}
  </dl>
{% endif %}
</div>
